From 66982b2e20ae8b0690e4dfcbf1a236540ff1c707 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 2 Oct 2009 06:36:39 +0000 Subject: [PATCH] Make get_buffer and get_partial_buffer return url_ferror or AVERROR_EOF as appropriate if it couldn't read any data at all. This should make handling of EOF and error simpler or make it work right without extra code in a few place (e.g. raw demuxer). git-svn-id: file:///var/local/repositories/ffmpeg/trunk@20135 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b --- libavformat/aviobuf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index f270139a9b..c670d48c98 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -415,6 +415,10 @@ int get_buffer(ByteIOContext *s, unsigned char *buf, int size) 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 @@ int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size) 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; } -- 2.11.4.GIT