mirror of https://gitee.com/openkylin/qemu.git
audio: pulseaudio fixes for 4.0
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJcj4pSAAoJEEy22O7T6HE4n58P/i8gyfM/aDaSGDeLEvtcsXAX fmlqBT7iU6qu7Ts2yssHLsqJI202vD7Ji9s3s1KRtVs5UJwg7XMYliZjg6LOBJQ7 VgGtLF1KqmMG7uPAFq2N7ctaBYtEj03hAqEeDljkOI6cbbfQgdusr4ixtk6h7buT eCTrYSAUqVHwcErKLCfaDll/+pNxEtaObnBXz4cuNd0B1Hkcc/zWCeZ/XXTZCH+z uP2T3qK40Q7Hf7wzQeMtQ/2w+Rel4AxwvpGR13evabkNP7t1l/6X884bHk70PxI0 tsHLqmOnjsBrc43AJBoOx3CFlLDQ7IapnThZz9kxRN5ZFEzXZAJD3gVhtZ5cNqmV I1+Hk16Wea+zDYdY8VytburFwEj9Jixu0pZXpD+u+ZTZ0b3iv8mflktAASu9qU9O uN7bYUs7U2Ol9Q9xLwnYUIUthhVjOpdMpWtiYa6X7MoqFw7YqRCFmdLGUjHWWV3l mQ6QKlmi05OgKRlVaZbTdoWL+NHd4iTBy3HDjNHghT7Whex6bD6ZJILFuEKSgKNk FORGS0WFME6aM0I7YT+KA7DDNinUw06MX6l/PFiLByOA2tW8B+HRtnAM+BOy9pQ1 RHyvGfl9LEgdPIES0oBHQyLFwI6y76X4/EBpgGU5tvIHVcoopJ8CQPH5YqY+a3rW Mw7pS+97cIVHQubmU7It =R4aN -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kraxel/tags/audio-20190318-pull-request' into staging audio: pulseaudio fixes for 4.0 # gpg: Signature made Mon 18 Mar 2019 12:08:50 GMT # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/audio-20190318-pull-request: audio/paaudio: fix microphone input being unusable audio/paaudio: prolong and make latency configurable audio/paaudio: fix ignored buffer_length setting Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
a9d1cc9f56
|
@ -549,12 +549,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
|
|||
ss.channels = as->nchannels;
|
||||
ss.rate = as->freq;
|
||||
|
||||
/*
|
||||
* qemu audio tick runs at 100 Hz (by default), so processing
|
||||
* data chunks worth 10 ms of sound should be a good fit.
|
||||
*/
|
||||
ba.tlength = pa_usec_to_bytes (10 * 1000, &ss);
|
||||
ba.minreq = pa_usec_to_bytes (5 * 1000, &ss);
|
||||
ba.tlength = pa_usec_to_bytes(ppdo->latency, &ss);
|
||||
ba.minreq = -1;
|
||||
ba.maxlength = -1;
|
||||
ba.prebuf = -1;
|
||||
|
||||
|
@ -577,7 +573,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
|
|||
|
||||
audio_pcm_init_info (&hw->info, &obt_as);
|
||||
hw->samples = pa->samples = audio_buffer_samples(
|
||||
qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440);
|
||||
qapi_AudiodevPaPerDirectionOptions_base(ppdo),
|
||||
&obt_as, ppdo->buffer_length);
|
||||
pa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
||||
pa->rpos = hw->rpos;
|
||||
if (!pa->pcm_buf) {
|
||||
|
@ -608,6 +605,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
|
|||
{
|
||||
int error;
|
||||
pa_sample_spec ss;
|
||||
pa_buffer_attr ba;
|
||||
struct audsettings obt_as = *as;
|
||||
PAVoiceIn *pa = (PAVoiceIn *) hw;
|
||||
paaudio *g = pa->g = drv_opaque;
|
||||
|
@ -618,6 +616,11 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
|
|||
ss.channels = as->nchannels;
|
||||
ss.rate = as->freq;
|
||||
|
||||
ba.fragsize = pa_usec_to_bytes(ppdo->latency, &ss);
|
||||
ba.maxlength = -1;
|
||||
ba.minreq = -1;
|
||||
ba.prebuf = -1;
|
||||
|
||||
obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);
|
||||
|
||||
pa->stream = qpa_simple_new (
|
||||
|
@ -627,7 +630,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
|
|||
ppdo->has_name ? ppdo->name : NULL,
|
||||
&ss,
|
||||
NULL, /* channel map */
|
||||
NULL, /* buffering attributes */
|
||||
&ba, /* buffering attributes */
|
||||
&error
|
||||
);
|
||||
if (!pa->stream) {
|
||||
|
@ -637,7 +640,8 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
|
|||
|
||||
audio_pcm_init_info (&hw->info, &obt_as);
|
||||
hw->samples = pa->samples = audio_buffer_samples(
|
||||
qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440);
|
||||
qapi_AudiodevPaPerDirectionOptions_base(ppdo),
|
||||
&obt_as, ppdo->buffer_length);
|
||||
pa->pcm_buf = audio_calloc(__func__, hw->samples, 1 << hw->info.shift);
|
||||
pa->wpos = hw->wpos;
|
||||
if (!pa->pcm_buf) {
|
||||
|
@ -809,7 +813,20 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* common */
|
||||
static int qpa_validate_per_direction_opts(Audiodev *dev,
|
||||
AudiodevPaPerDirectionOptions *pdo)
|
||||
{
|
||||
if (!pdo->has_buffer_length) {
|
||||
pdo->has_buffer_length = true;
|
||||
pdo->buffer_length = 46440;
|
||||
}
|
||||
if (!pdo->has_latency) {
|
||||
pdo->has_latency = true;
|
||||
pdo->latency = 15000;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void *qpa_audio_init(Audiodev *dev)
|
||||
{
|
||||
paaudio *g;
|
||||
|
@ -836,6 +853,13 @@ static void *qpa_audio_init(Audiodev *dev)
|
|||
g = g_malloc(sizeof(paaudio));
|
||||
server = popts->has_server ? popts->server : NULL;
|
||||
|
||||
if (!qpa_validate_per_direction_opts(dev, popts->in)) {
|
||||
goto fail;
|
||||
}
|
||||
if (!qpa_validate_per_direction_opts(dev, popts->out)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
g->dev = dev;
|
||||
g->mainloop = NULL;
|
||||
g->context = NULL;
|
||||
|
|
|
@ -206,12 +206,16 @@
|
|||
#
|
||||
# @name: name of the sink/source to use
|
||||
#
|
||||
# @latency: latency you want PulseAudio to achieve in microseconds
|
||||
# (default 15000)
|
||||
#
|
||||
# Since: 4.0
|
||||
##
|
||||
{ 'struct': 'AudiodevPaPerDirectionOptions',
|
||||
'base': 'AudiodevPerDirectionOptions',
|
||||
'data': {
|
||||
'*name': 'str' } }
|
||||
'*name': 'str',
|
||||
'*latency': 'uint32' } }
|
||||
|
||||
##
|
||||
# @AudiodevPaOptions:
|
||||
|
|
Loading…
Reference in New Issue