[FFmpeg-cvslog] avformat/aviobuf: fix avio_flush() for read streams

wm4 git at videolan.org
Tue Sep 30 21:56:44 CEST 2014


ffmpeg | branch: master | wm4 <nfxjfg at googlemail.com> | Tue Sep 30 18:46:48 2014 +0200| [c8422f04a3256a9abc01588f1b4aa95f5aadc891] | committer: Michael Niedermayer

avformat/aviobuf: fix avio_flush() for read streams

avio_flush() did nothing useful for read streams. Fix it to behave as
expected, and discard the currently read buffer properly.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c8422f04a3256a9abc01588f1b4aa95f5aadc891
---

 libavformat/avio.h    |    8 ++++++--
 libavformat/aviobuf.c |    4 +++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 2210c01..86f754e 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -289,10 +289,14 @@ int url_feof(AVIOContext *s);
 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
 
 /**
- * Force flushing of buffered data to the output s.
+ * Force flushing of buffered data.
  *
- * Force the buffered data to be immediately written to the output,
+ * For write streams, force the buffered data to be immediately written to the output,
  * without to wait to fill the internal buffer.
+ *
+ * For read streams, discard all currently buffered data, and advance the
+ * reported file position to that of the underlying stream. This does not
+ * read new data, and does not perform any seeks.
  */
 void avio_flush(AVIOContext *s);
 
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 9795ba4..f01ed88 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -139,7 +139,7 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len)
 
 static void flush_buffer(AVIOContext *s)
 {
-    if (s->buf_ptr > s->buffer) {
+    if (s->write_flag && s->buf_ptr > s->buffer) {
         writeout(s, s->buffer, s->buf_ptr - s->buffer);
         if (s->update_checksum) {
             s->checksum     = s->update_checksum(s->checksum, s->checksum_ptr,
@@ -148,6 +148,8 @@ static void flush_buffer(AVIOContext *s)
         }
     }
     s->buf_ptr = s->buffer;
+    if (!s->write_flag)
+        s->buf_end = s->buffer;
 }
 
 void avio_w8(AVIOContext *s, int b)



More information about the ffmpeg-cvslog mailing list