Author: jackburton Date: 2009-10-30 15:29:09 +0100 (Fri, 30 Oct 2009) New Revision: 33845 Changeset: http://dev.haiku-os.org/changeset/33845/haiku Modified: haiku/trunk/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp Log: Don't call avcodec_close() on an unopened codec, as that causes a crash. Happens for example when you create a BMediaFile and close it without committing the header Modified: haiku/trunk/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp 2009-10-30 12:08:15 UTC (rev 33844) +++ haiku/trunk/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp 2009-10-30 14:29:09 UTC (rev 33845) @@ -327,8 +327,9 @@ for(unsigned i = 0; i < fContext->nb_streams; i++) { #if OPEN_CODEC_CONTEXT // We only need to close the AVCodecContext when we opened it. - // This is experimental, see WriteHeader(). - avcodec_close(fContext->streams[i]->codec); + // This is experimental, see CommitHeader(). + if (fHeaderWritten) + avcodec_close(fContext->streams[i]->codec); #endif av_freep(&fContext->streams[i]->codec); av_freep(&fContext->streams[i]);