diff options
author | Max Kellermann <max@duempel.org> | 2015-10-27 11:05:47 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-10-27 11:05:47 +0100 |
commit | 94f850a5885c89e5255948f9274aaaa4197bc52b (patch) | |
tree | 5348c92cb0ed9a3dc409be922abac07eee4438de /src/decoder/plugins/FfmpegIo.cxx | |
parent | 3882c114505ea39e3707f27d91eb8ef363a8895b (diff) | |
parent | db9997a1068e00c5f78d4bb9834ce5a13e7b7a3b (diff) | |
download | mpd-94f850a5885c89e5255948f9274aaaa4197bc52b.tar.gz mpd-94f850a5885c89e5255948f9274aaaa4197bc52b.tar.xz mpd-94f850a5885c89e5255948f9274aaaa4197bc52b.zip |
Merge tag 'v0.19.11'
Diffstat (limited to 'src/decoder/plugins/FfmpegIo.cxx')
-rw-r--r-- | src/decoder/plugins/FfmpegIo.cxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/decoder/plugins/FfmpegIo.cxx b/src/decoder/plugins/FfmpegIo.cxx index 9603a131d..08fddffa5 100644 --- a/src/decoder/plugins/FfmpegIo.cxx +++ b/src/decoder/plugins/FfmpegIo.cxx @@ -28,7 +28,10 @@ AvioStream::~AvioStream() { - av_free(io); + if (io != nullptr) { + av_free(io->buffer); + av_free(io); + } } inline int @@ -90,9 +93,18 @@ AvioStream::_Seek(void *opaque, int64_t pos, int whence) bool AvioStream::Open() { - io = avio_alloc_context(buffer, sizeof(buffer), + constexpr size_t BUFFER_SIZE = 8192; + auto buffer = (unsigned char *)av_malloc(BUFFER_SIZE); + if (buffer == nullptr) + return false; + + io = avio_alloc_context(buffer, BUFFER_SIZE, false, this, _Read, nullptr, input.IsSeekable() ? _Seek : nullptr); + /* If avio_alloc_context() fails, who frees the buffer? The + libavformat API documentation does not specify this, it + only says that AVIOContext.buffer must be freed in the end, + however no AVIOContext exists in that failure code path. */ return io != nullptr; } |