]> git.sesse.net Git - vlc/commitdiff
avformat: lock avcodec
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 12 Mar 2009 15:41:02 +0000 (17:41 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 12 Mar 2009 15:41:49 +0000 (17:41 +0200)
This is ugly but we can do jack about this (short of forking ffmpeg).

modules/demux/avformat/demux.c

index e413c00821076c684e49dd81f05bd2b8c15530c6..fae4a274e07ac185f9c0166fe62942a36bc4c3ea 100644 (file)
@@ -36,6 +36,7 @@
 #include <vlc_meta.h>
 #include <vlc_input.h>
 #include <vlc_charset.h>
+#include <vlc_avcodec.h>
 
 /* ffmpeg header */
 #if defined(HAVE_LIBAVFORMAT_AVFORMAT_H)
@@ -205,13 +206,16 @@ int OpenDemux( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
+    vlc_avcodec_lock(); /* avformat calls avcodec behind our back!!! */
     if( av_find_stream_info( p_sys->ic ) < 0 )
     {
+        vlc_avcodec_unlock();
         msg_Err( p_demux, "av_find_stream_info failed" );
         if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
         CloseDemux( p_this );
         return VLC_EGENERIC;
     }
+    vlc_avcodec_unlock();
     if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
 
     for( i = 0; i < p_sys->ic->nb_streams; i++ )