[FFmpeg-devel] [PATCH] make av_get_packet return AVERROR_EOF if appropriate
Reimar Döffinger
Reimar.Doeffinger
Thu Oct 1 22:21:04 CEST 2009
On Thu, Oct 01, 2009 at 09:20:54PM +0200, Michael Niedermayer wrote:
> On Thu, Oct 01, 2009 at 07:15:06PM +0200, Reimar D?ffinger wrote:
> > I propose this change to get_buffer:
> > Index: libavformat/aviobuf.c
> > ===================================================================
> > --- libavformat/aviobuf.c (revision 20105)
> > +++ libavformat/aviobuf.c (working copy)
> > @@ -415,6 +415,8 @@
> > size -= len;
> > }
> > }
> > + if (size1 == size && url_feof(s))
> > + return AVERROR_EOF;
> > return size1 - size;
> > }
> >
>
> this would return EOF even if EIO happened
> url_ferror() should maybe be considered or eof not set in case of other
> errors
I wasn't even aware of url_ferror. Seems preferable to me to make those
errors available as return value when possible.
I admit it isn't great but I have the impression that currently almost
nothing takes care of url_ferror, so that should at least be a slight
improvement.
Index: aviobuf.c
===================================================================
--- aviobuf.c (revision 20130)
+++ aviobuf.c (working copy)
@@ -415,6 +415,10 @@
size -= len;
}
}
+ if (size1 == size) {
+ if (url_ferror(s)) return url_ferror(s);
+ if (url_feof(s)) return AVERROR_EOF;
+ }
return size1 - size;
}
@@ -434,6 +438,10 @@
len = size;
memcpy(buf, s->buf_ptr, len);
s->buf_ptr += len;
+ if (!len) {
+ if (url_ferror(s)) return url_ferror(s);
+ if (url_feof(s)) return AVERROR_EOF;
+ }
return len;
}
More information about the ffmpeg-devel
mailing list