]> git.sesse.net Git - vlc/commitdiff
macosx: vout drawable rework.
authorJean-Paul Saman <jpsaman@videolan.org>
Mon, 2 Mar 2009 20:32:13 +0000 (21:32 +0100)
committerJean-Paul Saman <jpsaman@videolan.org>
Tue, 17 Mar 2009 13:03:09 +0000 (14:03 +0100)
The macosx drawable variable that used to hold the drawable window reference is splitted up in two variables "drawable-agl" (used by macosx safari/mozilla plugin) and "drawable-gl" (used by macosx interface).

modules/gui/macosx/vout.m
modules/gui/macosx/voutgl.m
modules/video_output/opengllayer.m
src/control/libvlc_internal.h
src/control/media_player.c
src/control/video.c
src/libvlc.c

index 4654777cd679b45847ba2bfc807ed5ce785b64a0..6db6e48fa7d6d42419fafde58759ded6a359033c 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * vout.m: MacOS X video output module
  *****************************************************************************
- * Copyright (C) 2001-2008 the VideoLAN team
+ * Copyright (C) 2001-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Colin Delacroix <colin@zoy.org>
@@ -338,7 +338,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     vlc_object_release( p_input );
 }
 
-
 - (void)setOnTop:(BOOL)b_on_top
 {
     if( b_on_top )
@@ -711,11 +710,11 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 + (id)voutView: (vout_thread_t *)p_vout subView: (NSView *)view
          frame: (NSRect *)s_frame
 {
-    vlc_value_t value_drawable;
+    int i_drawable_gl;
     int i_timeout;
     id o_return = nil;
 
-    var_Get( p_vout->p_libvlc, "drawable", &value_drawable );
+    i_drawable_gl = var_GetInteger( p_vout->p_libvlc, "drawable-gl" );
 
     var_Create( p_vout, "macosx-vdev", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "macosx-stretch", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
@@ -726,9 +725,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
     /* We only wait for NSApp to initialise if we're not embedded (as in the
      * case of the Mozilla plugin).  We can tell whether we're embedded or not
-     * by examining the "drawable" value: if it's zero, we're running in the
+     * by examining the "drawable-gl" value: if it's zero, we're running in the
      * main Mac intf; if it's non-zero, we're embedded. */
-    if( value_drawable.i_int == 0 )
+    if( i_drawable_gl == 0 )
     {
         /* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */
         for( i_timeout = 20 ; i_timeout-- ; )
index 0704953281073fb07461192b4e5db53618b0bc5c..1347503748824e61985df5555a6209f5b15f98d1 100644 (file)
@@ -114,7 +114,7 @@ int OpenVideoGL  ( vlc_object_t * p_this )
 
     memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
 
-    var_Get( p_vout->p_libvlc, "drawable", &value_drawable );
+    var_Get( p_vout->p_libvlc, "drawable-agl", &value_drawable );
     if( value_drawable.i_int != 0 )
     {
         static const GLint ATTRIBUTES[] = {
@@ -148,7 +148,8 @@ int OpenVideoGL  ( vlc_object_t * p_this )
             msg_Err( p_vout, "cannot create AGL context." );
             return VLC_EGENERIC;
         }
-        else {
+        else
+        {
             // tell opengl not to sync buffer swap with vertical retrace (too inefficient)
             GLint param = 0;
             aglSetInteger(p_vout->p_sys->agl_ctx, AGL_SWAP_INTERVAL, &param);
@@ -496,7 +497,7 @@ static int aglInit( vout_thread_t * p_vout )
     Rect viewBounds;
     Rect clipBounds;
  
-    var_Get( p_vout->p_libvlc, "drawable", &val );
+    var_Get( p_vout->p_libvlc, "drawable-agl", &val );
     p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int;
     aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable);
 
@@ -616,7 +617,7 @@ static int aglManage( vout_thread_t * p_vout )
             Rect viewBounds;
             Rect clipBounds;
 
-            var_Get( p_vout->p_libvlc, "drawable", &val );
+            var_Get( p_vout->p_libvlc, "drawable-agl", &val );
             p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int;
             aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable);
 
index 4e9c185bdda47e397db51ca8b4b6dabde651f747..fe7518f052d7d132e1cf74caac9145d42720d036 100644 (file)
@@ -3,7 +3,7 @@
  * a layer. The layer will register itself to the drawable object stored in 
  * the "drawable" variable. 
  *****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
+ * Copyright (C) 2004-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet <asmax@videolan.org>
@@ -185,8 +185,8 @@ static int Init( vout_thread_t *p_vout )
 
     /* We do need a drawable to work properly */
     vlc_value_t value_drawable;
-    var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT );
-    var_Get( p_vout, "drawable", &value_drawable );
+    var_Create( p_vout, "drawable-gl", VLC_VAR_DOINHERIT );
+    var_Get( p_vout, "drawable-gl", &value_drawable );
 
     p_vout->p_sys->o_cocoa_container = (id) value_drawable.i_int;
     
index d24d8a9fceb9388ea5d7669b3d7dcedd76dcb162..f27447810253ffb1a8ef80e7a8136965d11adb9a 100644 (file)
@@ -2,7 +2,7 @@
  * libvlc_internal.h : Definition of opaque structures for libvlc exported API
  * Also contains some internal utility functions
  *****************************************************************************
- * Copyright (C) 2005 the VideoLAN team
+ * Copyright (C) 2005-2009 the VideoLAN team
  * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
@@ -158,6 +158,7 @@ struct libvlc_media_player_t
     {
         void *hwnd;
         uint32_t xid;
+        uint32_t agl;
     } drawable;
 
     bool        b_own_its_input_thread;
index 8ab3b7f8decdcb08928a46860f674fa31595a23c..61ed914d500e9298ef544f2510c2ce9fa0a21120 100644 (file)
@@ -94,6 +94,7 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor
 
         var_Destroy( p_input_thread, "drawable-hwnd" );
         var_Destroy( p_input_thread, "drawable-xid" );
+        var_Destroy( p_input_thread, "drawable-agl" );
     }
 
     vlc_object_release( p_input_thread );
@@ -274,6 +275,7 @@ libvlc_media_player_new( libvlc_instance_t * p_libvlc_instance,
         return NULL;
     }
     p_mi->p_md = NULL;
+    p_mi->drawable.agl = 0;
     p_mi->drawable.xid = 0;
     p_mi->drawable.hwnd = NULL;
     p_mi->p_libvlc_instance = p_libvlc_instance;
@@ -615,6 +617,10 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi,
 
     p_input_thread = p_mi->p_input_thread;
 
+    var_Create( p_input_thread, "drawable-agl", VLC_VAR_INTEGER );
+    if( p_mi->drawable.agl )
+        var_SetInteger( p_input_thread, "drawable-agl", p_mi->drawable.agl );
+
     var_Create( p_input_thread, "drawable-xid", VLC_VAR_INTEGER );
     if( p_mi->drawable.xid )
         var_SetInteger( p_input_thread, "drawable-xid", p_mi->drawable.xid );
@@ -728,6 +734,25 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi,
     }
 }
 
+/**************************************************************************
+ * set_agl
+ **************************************************************************/
+void libvlc_media_player_set_agl( libvlc_media_player_t *p_mi,
+                                      uint32_t drawable,
+                                      libvlc_exception_t *p_e )
+{
+    (void) p_e;
+    p_mi->drawable.agl = drawable;
+}
+
+/**************************************************************************
+ * get_agl
+ **************************************************************************/
+uint32_t libvlc_media_player_get_agl( libvlc_media_player_t *p_mi )
+{
+    return p_mi->drawable.agl;
+}
+
 /**************************************************************************
  * set_xwindow
  **************************************************************************/
@@ -778,6 +803,8 @@ void libvlc_media_player_set_drawable( libvlc_media_player_t *p_mi,
         p_mi->drawable.hwnd = (HWND)drawable;
     else
         libvlc_exception_raise(p_e, "Operation not supported");
+#elif defined(__APPLE__)
+    p_mi->drawable.agl = drawable;
 #else
     p_mi->drawable.xid = drawable;
 #endif
@@ -797,6 +824,8 @@ libvlc_media_player_get_drawable ( libvlc_media_player_t *p_mi,
         return (libvlc_drawable_t)p_mi->drawable.hwnd;
     else
         return 0;
+#elif defined(__APPLE__)
+    return p_mi->drawable.agl;
 #else
     return p_mi->drawable.xid;
 #endif
index 6efaa6fe3b2159ef853a224b67f7c545c2ecff6e..0e3a2a65574ec8793f22e7e6597bd5c496f3aaae 100644 (file)
@@ -242,6 +242,8 @@ void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d
         return; /* BOOM! we told you not to use this function! */
     val.p_address = (void *)(uintptr_t)d;
     var_Set( p_instance->p_libvlc_int, "drawable-hwnd", val );
+#elif defined(__APPLE__)
+    var_SetInteger( p_instance->p_libvlc_int, "drawable-agl", d );
 #else
     var_SetInteger( p_instance->p_libvlc_int, "drawable-xid", d );
 #endif
@@ -266,12 +268,13 @@ libvlc_drawable_t libvlc_video_get_parent( libvlc_instance_t *p_instance, libvlc
         return 0;
     var_Get( p_instance->p_libvlc_int, "drawable-hwnd", &val );
     return (uintptr_t)val.p_address;
+#elif defined(__APPLE__)
+    return var_GetInteger( p_instance->p_libvlc_int, "drawable-agl" );
 #else
     return var_GetInteger( p_instance->p_libvlc_int, "drawable-xid" );
 #endif
 }
 
-
 void libvlc_video_set_size( libvlc_instance_t *p_instance, int width, int height,
                            libvlc_exception_t *p_e )
 {
index e4a1a8e780adf98d0062ef7d19f19cc179defed2..49f4ff50829c8fd0fbf2691db905a130ddebe5ad 100644 (file)
@@ -970,9 +970,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
      */
     var_Create( p_libvlc, "drawable-xid", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_ADDRESS );
-#ifdef __APPLE__
-    var_Create( p_libvlc, "drawable", VLC_VAR_INTEGER );
-#endif
+    var_Create( p_libvlc, "drawable-agl", VLC_VAR_INTEGER );
+    var_Create( p_libvlc, "drawable-gl", VLC_VAR_INTEGER );
+
     var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-view-left", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-view-bottom", VLC_VAR_INTEGER );