[MPlayer-dev-eng] [PATCH] ad_spdif.c: Flush output buffer after processing frame, fixes audio stutter

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Jun 28 20:22:04 CEST 2014


On Sat, Jun 28, 2014 at 08:08:37PM +0200, Jan Andres wrote:
> > > The patch adds a call to avio_flush() after passing each audio frame to
> > > lavf to ensure that the write callback is never asked to process more
> > > than one frame's worth of data, which is guaranteed to completely fit
> > > into the output buffer so partial writes do not occur.
> > 
> > There is no guarantee this will always work reliably, in the future buffering might be added at even higher layers.
> > I think there is some special flag you are supposed to set to get unbuffered behaviour from lavf.
> 
> Thanks for the pointer, there's an option called "flush_packets" and the
> funny thing is, it's enabled by default. The real issue seems to be that
> ad_spdif.c directly calls the output format's write_packet function
> instead of using av_write_frame(), and doing so, the code that's
> supposed to handle the automatic flushing never gets executed.

This is very confusing (and I posted a few questions on it on the ffmpeg
list), but that was the wrong one.
There is also a flush_packet flag for fflags which maps to
AVFMT_FLAG_FLUSH_PACKETS.
That one flushes automatically, the other one only flushes if you
explicitly send in NULL packets as far as I understand it (which would
possibly be an option as well).


More information about the MPlayer-dev-eng mailing list