[FFmpeg-devel] [RFC][PATCH] avformat/flvdec: avoid reseting eof_reached to 0 silently

Zhang Rui bbcallen at gmail.com
Fri Apr 10 15:43:47 CEST 2015

2015-04-10 19:25 GMT+08:00 Hendrik Leppkes <h.leppkes at gmail.com>:
> On Wed, Apr 8, 2015 at 5:28 PM, Zhang Rui <bbcallen at gmail.com> wrote:
>> avio_feof() and avio_seek() could reset eof_reached to 0,
>> after some silent IO error in avio_r*(). And the reconnection
>> caused by seek makes demuxer to continue read at wrong position.
> While this may technically be a problem somehow, your replacement seek
> function is kinda weird.

I don't think this problem is only technically in network environment.
And I can't agree more about the 'weird' point.

> If its using SEEK_SET or SEEK_CUR with a positive offset, it could
> easily set or retain the current EOF flag, and that should be fixed
> inside that function.

There is nothing wrong inside avio_seek()/avio_skip(),
Actually, flvdec is the wrong side, in which error is ignored
and next IO is carried on at wrong position.

> The same thing really applies to avio_skip. If its at EOF before the
> skip, then it definitely will be at EOF after the skip as well, and
> the function should be fixed accordingly, and not some wrapper built
> around it.
> The only "odd" case is seeking backwards from EOF. It may be wanted or
> unwanted behaviour.

Yes, it's very likely to be unwanted.
If we don't want to check return code of every call to avio_r8(),
we need some thing to indicate between EOF,
recoverable error (EAGAIN) and unrecoverable error (EIO).

More information about the ffmpeg-devel mailing list