summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2014-09-30 18:46:48 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-09-30 21:31:08 +0200
commitc8422f04a3256a9abc01588f1b4aa95f5aadc891 (patch)
tree06e19d02fbbb00bf9adc2e13168504604327c926 /libavformat/aviobuf.c
parent07de0db74b56a5cb45039b58b6ff43ea5ffb90bc (diff)
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@gmx.at>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 9795ba46df..f01ed8843b 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)