[v2] avio: Do not flush the buffer if a constant packet size is requested

Message ID 20190131120920.84351-1-lu_zero@gentoo.org
State New
Headers show
Series
  • [v2] avio: Do not flush the buffer if a constant packet size is requested
Related show

Commit Message

Luca Barbato Jan. 31, 2019, 12:09 p.m.
---
Now w/out messing up the must_flush logic.

 libavformat/aviobuf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--
2.12.2

Patch

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 98e35f776c..4d9e246e07 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -244,8 +244,10 @@  void avio_write(AVIOContext *s, const unsigned char *buf, int size)

 void avio_flush(AVIOContext *s)
 {
-    flush_buffer(s);
-    s->must_flush = 0;
+    if (!s->max_packet_size || s->buf_ptr - s->buffer >= s->max_packet_size) {
+        flush_buffer(s);
+        s->must_flush = 0;
+    }
 }

 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)