]> git.sesse.net Git - vlc/commitdiff
* include/main.h
authorDerk-Jan Hartman <hartman@videolan.org>
Wed, 21 May 2003 15:40:03 +0000 (15:40 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Wed, 21 May 2003 15:40:03 +0000 (15:40 +0000)
  src/libvlc.c: Added a quicktime_lock on SYS_DARWIN
* ALL: QT on OSX is not threadsafe in certain areas. i have found the proces
  of identifying the right Codec to use for decoding to be one of these areas.
  So when we do this, only one thread at a time can use QT.
  Watching QT trailers is doable now, as soon as ffmpeg fix their altivec optimizations again ;)

include/main.h
modules/codec/quicktime.c
modules/gui/macosx/vout.m
src/libvlc.c

index 0521a6776ccaf067f565c1123fb532a78a28b66b..22702f0c5b1e9f4122f07d54db50cf964a5bd031 100644 (file)
@@ -3,7 +3,7 @@
  * Declaration and extern access to global program object.
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
- * $Id: main.h,v 1.53 2003/02/17 05:50:31 sam Exp $
+ * $Id: main.h,v 1.54 2003/05/21 15:40:03 hartman Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
@@ -101,5 +101,8 @@ struct vlc_t
 
     /* Locks */
     vlc_mutex_t            config_lock;          /* lock for the config file */
+#ifdef SYS_DARWIN
+    vlc_mutex_t            quicktime_lock;          /* QT is not thread safe on OSX */
+#endif
 };
 
index 28cb4cccb619d41fd61b41846d3be99751f1c3cb..b5e3278acc62dcf6d569d3a2cfe5cecd492266a2 100644 (file)
@@ -2,7 +2,7 @@
  * quicktime.c: a quicktime decoder that uses the QT library/dll
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: quicktime.c,v 1.1 2003/05/20 21:35:52 hartman Exp $
+ * $Id: quicktime.c,v 1.2 2003/05/21 15:40:03 hartman Exp $
  *
  * Authors: Laurent Aimar <fenrir at via.ecp.fr>
  *          Derk-Jan Hartman <thedj at users.sf.net>
@@ -352,9 +352,18 @@ static int  InitThreadAudio     ( adec_thread_t *p_dec )
     p_dec->OutputFormatInfo.sampleRate  = p_wf->nSamplesPerSec;
     p_dec->OutputFormatInfo.format      = FCC( 'N', 'O', 'N', 'E' );
 
+#ifdef SYS_DARWIN
+/* on OS X QT is not threadsafe */
+    vlc_mutex_lock( &p_dec->p_fifo->p_vlc->quicktime_lock );
+#endif
+
     i_error = p_dec->SoundConverterOpen( &p_dec->InputFormatInfo,
                                          &p_dec->OutputFormatInfo,
                                          &p_dec->myConverter );
+#ifdef SYS_DARWIN
+    vlc_mutex_unlock( &p_dec->p_fifo->p_vlc->quicktime_lock );
+#endif
+
     if( i_error )
     {
         msg_Dbg( p_dec->p_fifo, "error while SoundConverterOpen = %d", i_error );
index 535a468663d8711963b9526e25df1cf9249f6619..39adae7e3226b837b0a20fa2eb584569cf141ea1 100644 (file)
@@ -2,7 +2,7 @@
  * vout.m: MacOS X video output plugin
  *****************************************************************************
  * Copyright (C) 2001-2003 VideoLAN
- * $Id: vout.m,v 1.47 2003/05/05 22:04:11 hartman Exp $
+ * $Id: vout.m,v 1.48 2003/05/21 15:40:03 hartman Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Florian G. Pflug <fgp@phlo.org>
@@ -150,8 +150,13 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
 
     if( vout_ChromaCmp( p_vout->render.i_chroma, VLC_FOURCC('I','4','2','0') ) )
     {
+        /* Damn QT isn't thread safe. so keep a lock in the p_vlc object */
+        vlc_mutex_lock( &p_vout->p_vlc->quicktime_lock );
+
         err = FindCodec( kYUV420CodecType, bestSpeedCodec,
                          nil, &p_vout->p_sys->img_dc );
+        
+        vlc_mutex_unlock( &p_vout->p_vlc->quicktime_lock );
         if( err == noErr && p_vout->p_sys->img_dc != 0 )
         {
             p_vout->output.i_chroma = VLC_FOURCC('I','4','2','0');
index 35292ac96b1160638ef465568078d35f96fc2a1f..6179907e9ed42287ac4eb2b419c735162ed2dca1 100644 (file)
@@ -2,7 +2,7 @@
  * libvlc.c: main libvlc source
  *****************************************************************************
  * Copyright (C) 1998-2002 VideoLAN
- * $Id: libvlc.c,v 1.86 2003/05/11 13:14:04 sigmunau Exp $
+ * $Id: libvlc.c,v 1.87 2003/05/21 15:40:03 hartman Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -187,6 +187,9 @@ int VLC_Create( void )
 
     /* Initialize mutexes */
     vlc_mutex_init( p_vlc, &p_vlc->config_lock );
+#ifdef SYS_DARWIN
+    vlc_mutex_init( p_vlc, &p_vlc->quicktime_lock );
+#endif
 
     /* Store our newly allocated structure in the global list */
     vlc_object_attach( p_vlc, &libvlc );
@@ -650,6 +653,9 @@ int VLC_Destroy( int i_object )
 
     /* Destroy mutexes */
     vlc_mutex_destroy( &p_vlc->config_lock );
+#ifdef SYS_DARWIN
+    vlc_mutex_destroy( &p_vlc->quicktime_lock );
+#endif
 
     vlc_object_detach( p_vlc );