Commit 5d1203f0 authored by Stefano Sabatini's avatar Stefano Sabatini Committed by Anton Khirnov

avio: flush the internal buffer in avio_close()

This is consistent with stdio, and thus what people would naturally
expect.
parent 04438790
...@@ -349,6 +349,9 @@ int avio_open2(AVIOContext **s, const char *url, int flags, ...@@ -349,6 +349,9 @@ int avio_open2(AVIOContext **s, const char *url, int flags,
* Close the resource accessed by the AVIOContext s and free it. * Close the resource accessed by the AVIOContext s and free it.
* This function can only be used if s was opened by avio_open(). * This function can only be used if s was opened by avio_open().
* *
* The internal buffer is automatically flushed before closing the
* resource.
*
* @return 0 on success, an AVERROR < 0 on error. * @return 0 on success, an AVERROR < 0 on error.
*/ */
int avio_close(AVIOContext *s); int avio_close(AVIOContext *s);
......
...@@ -761,6 +761,7 @@ int avio_close(AVIOContext *s) ...@@ -761,6 +761,7 @@ int avio_close(AVIOContext *s)
if (!s) if (!s)
return 0; return 0;
avio_flush(s);
h = s->opaque; h = s->opaque;
av_freep(&s->buffer); av_freep(&s->buffer);
av_free(s); av_free(s);
......
...@@ -86,8 +86,6 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -86,8 +86,6 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
avio_write(pb[0], pkt->data , ysize); avio_write(pb[0], pkt->data , ysize);
avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2); avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
avio_write(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2); avio_write(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
avio_flush(pb[1]);
avio_flush(pb[2]);
avio_close(pb[1]); avio_close(pb[1]);
avio_close(pb[2]); avio_close(pb[2]);
}else{ }else{
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 54 #define LIBAVFORMAT_VERSION_MAJOR 54
#define LIBAVFORMAT_VERSION_MINOR 16 #define LIBAVFORMAT_VERSION_MINOR 16
#define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_MICRO 1
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \ LIBAVFORMAT_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment