[FFmpeg-devel] [PATCH] lavd/pulse_audio_enc: add buffer length control options

Lukasz M lukasz.m.luki at gmail.com
Sat Nov 23 17:48:49 CET 2013


On 23 November 2013 17:41, Timothy Gu <timothygu99 at gmail.com> wrote:

> On Nov 23, 2013 6:32 AM, "Lukasz Marek" <lukasz.m.luki at gmail.com> wrote:
> >
> > Add options to control the length of the PulseAudio buffer.
> >
> > Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
> > ---
> >  doc/outdevs.texi              |    8 ++++++++
> >  libavdevice/pulse_audio_enc.c |   21 +++++++++++++++++++++
> >  libavdevice/version.h         |    2 +-
> >  3 files changed, 30 insertions(+), 1 deletion(-)
> >
> > diff --git a/doc/outdevs.texi b/doc/outdevs.texi
> > index c737225..0e7309e 100644
> > --- a/doc/outdevs.texi
> > +++ b/doc/outdevs.texi
> > @@ -164,6 +164,14 @@ by default it is set to the specified output name.
> >  Specify the device to use. Default device is used when not provided.
> >  List of output devices can be obtained with command @command{pactl list
> sinks}.
> >
> > + at item buffer_length
> > + at item buffer_duration
> > +Controls the length of the PulseAudio buffer. Small buffer gives more
> control,
> > +but requires more frequent updates.
> > +buffer_length specifies length in bytes while buffer_duration specifies
> length in miliseconds.
> > +When both options are provided then higher value is used.
> > +By default PulseAudio set buffer length to around 2 seconds.
>
> Add:
> If both options are set, it will print out a warning and
> @option{buffer_duration} is used.
>
> > +
> >  @end table
> >
> >  @subsection Examples
>
> [...]
>
> > +    else if (s->buffer_length) {
> > +        attr.tlength = s->buffer_length;
> > +        if (s->buffer_duration)
> > +            av_log(s, AV_LOG_WARNING, "buffer_duration parameter is
> ignored.\n");
>
> A few problems here:
> a) it is an else if, which means that this will not execute if
>    buffer_duration is set, and this will not override buffer_duration
> b) even if you changed this to plain if, if user sets both options,
>    the code spent time calculating buffer_duration, but at
>    the end it is overridden. So you should move buffer_length to the front
> of buffer_duration.


in first if there is
attr.tlength = FFMAX(s->buffer_length, av_clip64_c(bytes, 0, 0xFFFFFFFE));
So it applies bigger length value from provided.
I forgot to remove warning from second if. I will fix it later.


More information about the ffmpeg-devel mailing list