[FFmpeg-devel] avformat/flvdec: Change packet loop to return EAGAIN instead of looping until a valid packet is foud

Nicolas George george at nsup.org
Sun Nov 22 20:57:22 CET 2015

Le nonidi 19 vendémiaire, an CCXXIV, Michael Niedermayer a écrit :
> Yes, they simplified the loop and EAGAIN was used before these changes
> in flvdec. Also other demuxers use EAGAIN to no other reason then to
> simplify their main loop.
> They also provide much more fine grained access for
> applications (like when there is a long string of skiped packets)
> and avoid long locking/waiting for a demuxer & protocol to return.
> but that was not the reason for these IIRC
> maybe some other error code should be added and or used for these
> cases than EAGAIN, but iam also not against replacing the EAGAIN
> by a loop (this other error code can be intercepted by the calling
> utils.c  code and the loop performed there so user apps dont need
> to deal with an additional special error code)
> note, simply reverting the commits will break the loop, theres extra
> code at the end which checks if packet synchronization has been lost
> and resync is needed, this would be skiped by simply calling continue

EAGAIN usually means that data will become available depending on external
conditions (network packet, device event or data added somewhere by the
application). Retrying immediately is useless and harmful.

This is the complete opposite: if the application wants a packet, it must
retry immediately.

There is no way of handling both cases the same way, therefore another error
code MUST be chosen.

Furthermore, since it was not part of the API until now, this error code
MUST be handled internally by utils.c and not returned to the application.
(Of course, a flag can be added to get the fine-grained access you suggest.)

Do you remember which demuxers are affected by the same bug?


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151122/382df2aa/attachment.sig>

More information about the ffmpeg-devel mailing list