[FFmpeg-devel] [PATCH] mpegts: Return AVERROR(EAGAIN) instead of -1 if there isn't enough data
Martin Storsjö
martin
Wed Oct 13 20:25:18 CEST 2010
On Wed, 13 Oct 2010, Reimar D?ffinger wrote:
> On Wed, Oct 13, 2010 at 11:52:39AM +0300, Martin Storsjo wrote:
> > This makes the rtpdec queue code able to process packets more efficiently,
> > keeping the queue shorter, by parsing the next packet instead of returning
> > the unidentified error code -1 as an error.
> > ---
> > libavformat/mpegts.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > index d2f9f1e..13a9908 100644
> > --- a/libavformat/mpegts.c
> > +++ b/libavformat/mpegts.c
> > @@ -1742,7 +1742,7 @@ int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
> > if (ts->stop_parse>0)
> > break;
> > if (len < TS_PACKET_SIZE)
> > - return -1;
> > + return AVERROR(EAGAIN);
> > if (buf[0] != 0x47) {
> > buf++;
> > len--;
>
> I'm not sure that matches the semantics of EAGAIN.
> I'd assume EAGAIN to mean "please try the exact
> same thing again until it succeeds", whereas
> here it would mean "give me more data"?
> Maybe that's okay because only one meaning is
> certain to make sense in this case, but
> I guess it should at least be documented.
Yes, I've also noticed this slight deviation from the original meaning of
EAGAIN, but I'm not aware of any other error code that would be better fit
for this purpose. We already use this error code consistently within the
rtpdec code for this purpose. (Which of course doesn't mean it shouldn't
be changed to something else, if we realize there's a better error code
for this.)
// Martin
More information about the ffmpeg-devel
mailing list