forked from mirror/openmw-tes3mp
Updated ffmpeg decoder fix
Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
This commit is contained in:
parent
5c5f87445b
commit
6107d5bad2
1 changed files with 20 additions and 10 deletions
|
@ -160,7 +160,12 @@ void FFmpeg_Decoder::open(const std::string &fname)
|
||||||
{
|
{
|
||||||
if (mFormatCtx->pb != NULL)
|
if (mFormatCtx->pb != NULL)
|
||||||
{
|
{
|
||||||
avio_close(mFormatCtx->pb);
|
if (mFormatCtx->pb->buffer != NULL)
|
||||||
|
{
|
||||||
|
av_free(mFormatCtx->pb->buffer);
|
||||||
|
mFormatCtx->pb->buffer = NULL;
|
||||||
|
}
|
||||||
|
av_free(mFormatCtx->pb);
|
||||||
mFormatCtx->pb = NULL;
|
mFormatCtx->pb = NULL;
|
||||||
}
|
}
|
||||||
avformat_free_context(mFormatCtx);
|
avformat_free_context(mFormatCtx);
|
||||||
|
@ -200,7 +205,12 @@ void FFmpeg_Decoder::open(const std::string &fname)
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
avio_close(mFormatCtx->pb);
|
if (mFormatCtx->pb->buffer != NULL)
|
||||||
|
{
|
||||||
|
av_free(mFormatCtx->pb->buffer);
|
||||||
|
mFormatCtx->pb->buffer = NULL;
|
||||||
|
}
|
||||||
|
av_free(mFormatCtx->pb);
|
||||||
mFormatCtx->pb = NULL;
|
mFormatCtx->pb = NULL;
|
||||||
|
|
||||||
avformat_close_input(&mFormatCtx);
|
avformat_close_input(&mFormatCtx);
|
||||||
|
@ -221,16 +231,16 @@ void FFmpeg_Decoder::close()
|
||||||
{
|
{
|
||||||
if (mFormatCtx->pb != NULL)
|
if (mFormatCtx->pb != NULL)
|
||||||
{
|
{
|
||||||
avio_flush(mFormatCtx->pb);
|
// valgrind shows memleak near mFormatCtx->pb
|
||||||
|
|
||||||
//
|
//
|
||||||
// avio-close() gives segfault, but with av_free valgrind shows memleak
|
// As scrawl pointed, memleak could be related to this ffmpeg ticket:
|
||||||
// near mFormatCtx->pb
|
// https://trac.ffmpeg.org/ticket/1357
|
||||||
//
|
|
||||||
// to be checked!
|
|
||||||
//
|
|
||||||
// avio_close(mFormatCtx->pb);
|
|
||||||
//
|
//
|
||||||
|
if (mFormatCtx->pb->buffer != NULL)
|
||||||
|
{
|
||||||
|
av_free(mFormatCtx->pb->buffer);
|
||||||
|
mFormatCtx->pb->buffer = NULL;
|
||||||
|
}
|
||||||
av_free(mFormatCtx->pb);
|
av_free(mFormatCtx->pb);
|
||||||
mFormatCtx->pb = NULL;
|
mFormatCtx->pb = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue