[FFmpeg-devel] [PATCH] aviobuf: Retry if the read/write function returns AVERROR(EAGAIN)

Martin Storsjö martin
Fri Jan 7 14:00:54 CET 2011


On Fri, 7 Jan 2011, Michael Niedermayer wrote:

> > As for whether they are allowed to return EAGAIN - url_read_complete
> > already handles EAGAIN, so url_read seems to be allowed to return it, 
> > which ByteIOContext uses directly at the moment.
> 
> > Not sure if write_packet
> > is allowed to return it though - url_write hides it at least.
> 
> If none of the current protocols can generate EAGAIN on write_packet() then
> we could just disallow it for future protocols to do it
> 
> If some of the current protocols can generate EAGAIN on write_packet() then we
> need to handle this somewhere, either in the protocols or the callers. Where
> its easier depends probably on how many protocols are affected and if the
> code could benefit from being protocol specific

I assume this (and/or the paragraph above) refers to read_packet(), since 
it's more of an issue there than in write_packet() I think.

I'm not sure if any of the current protocols do return it - I was about to 
add a codepath where it would be returned, triggering me to write this 
patch, but I managed to avoid that particular case.

> We also could change the API to use 2 size parameters.
> One that specifies the minimum that we need and one the maximum we could accept
> then all the retry code could be put inside protocols and still allow flexible
> blocking and non blocking reads. It of course doesnt really avoid the retry
> need but it might simplify API by reducing the duplication of complete and non
> complete IO functions

Perhaps, although the current API is quite acceptable I think.

> In the end i dont know what is best, i know though what is worst and that is
> leaving it buggy ...

Agreed.

Another way of solving it is as in attached. This has much less code 
duplication, but adds a new public function instead.

// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libavformat-Add-a-new-function-url_read_retry.patch
Type: text/x-diff
Size: 3231 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110107/a02028fe/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-aviobuf-Use-url_read_retry-in-url_fdopen.patch
Type: text/x-diff
Size: 988 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110107/a02028fe/attachment-0001.patch>



More information about the ffmpeg-devel mailing list