[FFmpeg-devel] [PATCH] tty: return av_get_packet() error codes instead of converting them to EIO

Peter Ross pross at xvid.org
Tue Sep 4 16:05:48 CEST 2012


On Tue, Sep 04, 2012 at 07:25:15AM +0200, Reimar Döffinger wrote:
> On 4 Sep 2012, at 01:44, Peter Ross <pross at xvid.org> wrote:
> > ---
> > Updated.
> > 
> > libavformat/tty.c |    4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/tty.c b/libavformat/tty.c
> > index a71c6b1..39380e2 100644
> > --- a/libavformat/tty.c
> > +++ b/libavformat/tty.c
> > @@ -135,8 +135,8 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
> >     }
> > 
> >     pkt->size = av_get_packet(avctx->pb, pkt, n);
> > -    if (pkt->size <= 0)
> > -        return AVERROR(EIO);
> > +    if (pkt->size < 0)
> > +        return pkt->size;
> 
> Is that change in behaviour (0 sized packets no longer considered an error) intended/correct?
> Particularly since I guess that case can happen both due to n being 0 or due the the file being cut at exactly the start of a packet.
> (not that it is likely to matter much in practice, but making code less correct to save a single ?: seems like a bad trade-off to me).

The number of requested bytes ('n') is always > 0, and av_get_packet() is a blocking call, 
so the '== 0' case should never happen. Correct me if iam wrong here!

Grepping all the uses of av_get_packet shows several different ways its being used. e.g.
Return error code <0, return error code <=0, return EIO always, etc. I am not sure which
is most appropriate.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120905/8960af4f/attachment.asc>


More information about the ffmpeg-devel mailing list