qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] pulseaudio: reduce 24s recording latency


From: Marc-André Lureau
Subject: Re: [Qemu-devel] [PATCH] pulseaudio: reduce 24s recording latency
Date: Sat, 12 Sep 2015 14:07:26 +0200

Hi

On Fri, Sep 11, 2015 at 9:03 PM, Volker Rümelin <address@hidden> wrote:
> Current code doesn't provide pulseaudio buffer attributes for
> recording. Without buffer attributes pulseaudio uses a default
> buffer of 4MB. 4MB is approximately 24s 16bit stereo audio
> data at 44.1kHz.
>
> This patch fixes bug #1492649
>
> |Signed-off-by: Volker Rümelin <address@hidden>|
> ---
>  audio/paaudio.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/audio/paaudio.c b/audio/paaudio.c
> index fea6071..c1169d4 100644
> --- a/audio/paaudio.c
> +++ b/audio/paaudio.c
> @@ -608,6 +608,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;
> @@ -616,6 +617,12 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings 
> *as, void *drv_opaque)
>      ss.channels = as->nchannels;
>      ss.rate = as->freq;
>
> +    ba.fragsize = pa_frame_size (&ss) * g->conf.samples;
> +    ba.maxlength = 5 * ba.fragsize;

This 5 value is a bit arbitrary, I suppose it may increase max latency
up to 5 times the g->conf.samples. (what about using
PA_STREAM_ADJUST_LATENCY?)

Otherwise, the change looks good to me.

> +    ba.tlength = -1;
> +    ba.prebuf = -1;
> +    ba.minreq = -1;
> +
>      obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);
>
>      pa->stream = qpa_simple_new (
> @@ -625,7 +632,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings 
> *as, void *drv_opaque)
>          g->conf.source,
>          &ss,
>          NULL,                   /* channel map */
> -        NULL,                   /* buffering attributes */
> +        &ba,                    /* buffering attributes */
>          &error
>          );
>      if (!pa->stream) {
> --
> 1.8.4.5
>
>



-- 
Marc-André Lureau



reply via email to

[Prev in Thread] Current Thread [Next in Thread]