[vlc-devel] commit: avformat: lock avcodec ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Mar 12 16:41:55 CET 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Mar 12 17:41:02 2009 +0200| [0e05b6e2b1509d58bb2f32db25da26feb0396b87] | committer: Rémi Denis-Courmont 

avformat: lock avcodec

This is ugly but we can do jack about this (short of forking ffmpeg).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0e05b6e2b1509d58bb2f32db25da26feb0396b87
---

 modules/demux/avformat/demux.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index e413c00..fae4a27 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -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++ )




More information about the vlc-devel mailing list