[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 17:59:39 CEST 2014
Just quick comments since I didn't have time to look up some details.
On 28.06.2014, at 12:55, Jan Andres <jandres at gmx.net> wrote:
> Additionally, the lavf write callback doesn't really work in the way the
> code in ad_spdif.c expects it to; the write callback cannot perform a
> partial write and expect lavf code to handle this situation. It must
> always process the full amount of data passed to it. The current write
> callback however does sometimes perform a partial write and this will
> result in some data being dropped from the output data stream,
> ultimately leading to badly stuttering audio.
Hm, I am not convinced this isn't a bug. Common functions like send() can cause partial writes, so I think lavf must support it in principle.
> 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.
More information about the MPlayer-dev-eng
mailing list