]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/voutqt.m
macosx: Simplify the title update code.
[vlc] / modules / gui / macosx / voutqt.m
index 6f80948a9f782a5edd6028c6b6f222fe2e9f6f40..61b1d76cef74e22e960556030e2d63099c2922e7 100644 (file)
@@ -29,9 +29,9 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <errno.h>                                                 /* ENOMEM */
 #include <stdlib.h>                                                /* free() */
 #include <string.h>
+#include <assert.h>
 
 #include <QuickTime/QuickTime.h>
 
@@ -61,8 +61,8 @@ struct vout_sys_t
     VLCQTView * o_qtview;
     VLCVoutView       * o_vout_view;
 
-    vlc_bool_t  b_saved_frame;
-    vlc_bool_t  b_cpu_has_simd; /* does CPU supports Altivec, MMX, etc... */
+    bool  b_saved_frame;
+    bool  b_cpu_has_simd; /* does CPU supports Altivec, MMX, etc... */
     NSRect      s_frame;
 
     CodecType i_codec;
@@ -76,7 +76,7 @@ struct vout_sys_t
     int i_origx, i_origy;
     int i_width, i_height;
     /* Mozilla plugin-related variables */
-    vlc_bool_t b_embedded;
+    bool b_embedded;
     RgnHandle clip_mask;
 };
 
@@ -114,7 +114,7 @@ static void QTFreePicture       ( vout_thread_t *, picture_t * );
  *****************************************************************************
  * This function allocates and initializes a MacOS X vout method.
  *****************************************************************************/
-int E_(OpenVideoQT) ( vlc_object_t *p_this )
+int OpenVideoQT ( vlc_object_t *p_this )
 {
     vout_thread_t * p_vout = (vout_thread_t *)p_this;
     OSErr err;
@@ -142,9 +142,9 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
      * CGrafPtr that we're expected to use */
     var_Get( p_vout->p_libvlc, "drawable", &value_drawable );
     if( value_drawable.i_int != 0 )
-        p_vout->p_sys->b_embedded = VLC_TRUE;
+        p_vout->p_sys->b_embedded = true;
     else
-        p_vout->p_sys->b_embedded = VLC_FALSE;
+        p_vout->p_sys->b_embedded = false;
 
     p_vout->p_sys->b_cpu_has_simd =
         vlc_CPU() & (CPU_CAPABILITY_ALTIVEC|CPU_CAPABILITY_MMXEXT);
@@ -165,8 +165,8 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    /* Damn QT isn't thread safe. so keep a lock in the p_libvlc object */
-    vlc_mutex_lock( &p_vout->p_libvlc->quicktime_lock );
+    /* Damn QT isn't thread safe, so keep a process-wide lock */
+    vlc_mutex_t *p_qtlock = var_AcquireMutex( "quicktime_mutex" );
 
     /* Can we find the right chroma ? */
     if( p_vout->p_sys->b_cpu_has_simd )
@@ -179,7 +179,7 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
         err = FindCodec( kYUV420CodecType, bestSpeedCodec,
                         nil, &p_vout->p_sys->img_dc );
     }
-    vlc_mutex_unlock( &p_vout->p_libvlc->quicktime_lock );
+    vlc_mutex_unlock( p_qtlock );
  
     if( err == noErr && p_vout->p_sys->img_dc != 0 )
     {
@@ -232,7 +232,7 @@ int E_(OpenVideoQT) ( vlc_object_t *p_this )
 /*****************************************************************************
  * CloseVideo: destroy video thread output method
  *****************************************************************************/
-void E_(CloseVideoQT) ( vlc_object_t *p_this )
+void CloseVideoQT ( vlc_object_t *p_this )
 {
     NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
     vout_thread_t * p_vout = (vout_thread_t *)p_this;
@@ -454,12 +454,12 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
  *****************************************************************************/
 static int ControlVideo( vout_thread_t *p_vout, int i_query, va_list args )
 {
-    vlc_bool_t b_arg;
+    bool b_arg;
 
     switch( i_query )
     {
         case VOUT_SET_STAY_ON_TOP:
-            b_arg = va_arg( args, vlc_bool_t );
+            b_arg = (bool) va_arg( args, int );
             [p_vout->p_sys->o_vout_view setOnTop: b_arg];
             return VLC_SUCCESS;
 
@@ -704,8 +704,10 @@ static int QTNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
             p_pic->p_sys->i_size = p_vout->output.i_width * p_vout->output.i_height * 2;
 
             /* Allocate the memory buffer */
-            p_pic->p_data = vlc_memalign( &p_pic->p_data_orig,
-                                          16, p_pic->p_sys->i_size );
+            p_pic->p_data_orig = p_pic->p_data = malloc( p_pic->p_sys->i_size );
+            /* Memory is always 16-bytes aligned on OSX, so it does not
+             * posix_memalign() */
+            assert( (((uintptr_t)p_pic->p_data) % 16) == 0 );
 
             p_pic->p[0].p_pixels = p_pic->p_data;
             p_pic->p[0].i_lines = p_vout->output.i_height;
@@ -724,8 +726,11 @@ static int QTNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
             p_pic->p_sys->i_size = sizeof(PlanarPixmapInfoYUV420);
  
             /* Allocate the memory buffer */
-            p_pic->p_data = vlc_memalign( &p_pic->p_data_orig,
-                                          16, p_vout->output.i_width * p_vout->output.i_height * 3 / 2 );
+            p_pic->p_data_orig = p_pic->p_data = malloc( p_vout->output.i_width
+                                     * p_vout->output.i_height * 3 / 2 );
+            /* Memory is always 16-bytes aligned on OSX, so it does not
+             * posix_memalign() */
+            assert( (((uintptr_t)p_pic->p_data) % 16) == 0 );
 
             /* Y buffer */
             p_pic->Y_PIXELS = p_pic->p_data;
@@ -814,7 +819,7 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
         [p_vout->p_sys->o_vout_view frame].size;
         p_vout->p_sys->s_frame.origin =
         [[p_vout->p_sys->o_vout_view getWindow] frame].origin;
-        p_vout->p_sys->b_saved_frame = VLC_TRUE;
+        p_vout->p_sys->b_saved_frame = true;
     }
         else
         {