From fd8326e9585259609122b8d289848328749c13a2 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 21 Mar 2012 12:20:36 -0700 Subject: [PATCH] Better handle some ffmpeg errors --- apps/openmw/mwsound/ffmpeg_decoder.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index fb530de913..3ba1af525d 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -243,12 +243,16 @@ void FFmpeg_Decoder::open(const std::string &fname) if((mFormatCtx=avformat_alloc_context()) == NULL) fail("Failed to allocate context"); + mFormatCtx->pb = avio_alloc_context(NULL, 0, 0, this, readPacket, writePacket, seek); + if(!mFormatCtx->pb || avformat_open_input(&mFormatCtx, fname.c_str(), NULL, NULL) != 0) + { + avformat_free_context(mFormatCtx); + mFormatCtx = NULL; + fail("Failed to allocate input stream"); + } + try { - mFormatCtx->pb = avio_alloc_context(NULL, 0, 0, this, readPacket, writePacket, seek); - if(!mFormatCtx->pb || avformat_open_input(&mFormatCtx, fname.c_str(), NULL, NULL) != 0) - fail("Failed to open input stream for "+fname); - if(avformat_find_stream_info(mFormatCtx, NULL) < 0) fail("Failed to find stream info in "+fname);