]> git.sesse.net Git - mlt/commitdiff
Fix race on stream index (kdenlive-2296)
authorDan Dennedy <dan@dennedy.org>
Thu, 29 Sep 2011 20:58:47 +0000 (13:58 -0700)
committerDan Dennedy <dan@dennedy.org>
Thu, 29 Sep 2011 20:58:47 +0000 (13:58 -0700)
src/modules/avformat/producer_avformat.c

index f80c7d7e1f6839ddb4f0385054c7c60266aa0cac..3829d2028d967c8ba797beca62651c24b3a092b3 100644 (file)
@@ -1886,13 +1886,11 @@ static void producer_set_up_video( producer_avformat self, mlt_frame frame )
        {
                // Reset the video properties if the index changed
                self->video_index = index;
+               avformat_lock();
                if ( self->video_codec )
-               {
-                       avformat_lock();
                        avcodec_close( self->video_codec );
-                       avformat_unlock();
-               }
                self->video_codec = NULL;
+               avformat_unlock();
        }
 
        // Get the frame properties
@@ -2447,13 +2445,11 @@ static void producer_set_up_audio( producer_avformat self, mlt_frame frame )
        // Update the audio properties if the index changed
        if ( context && index > -1 && index != self->audio_index )
        {
+               avformat_lock();
                if ( self->audio_codec[ self->audio_index ] )
-               {
-                       avformat_lock();
                        avcodec_close( self->audio_codec[ self->audio_index ] );
-                       avformat_unlock();
-               }
                self->audio_codec[ self->audio_index ] = NULL;
+               avformat_unlock();
        }
        if ( self->audio_index != -1 )
                self->audio_index = index;