]> git.sesse.net Git - vlc/commitdiff
* src/video_output/vout_intf.c, include/video_output.h:
authorGildas Bazin <gbazin@videolan.org>
Sun, 16 May 2004 22:06:34 +0000 (22:06 +0000)
committerGildas Bazin <gbazin@videolan.org>
Sun, 16 May 2004 22:06:34 +0000 (22:06 +0000)
  + vout_RequestWindow() will now cycle through all the available interfaces until
it finds one with embedded vout support.
    This fixes the issue where embedded vout would stop working when additional
interfaces are spawned after the main interface is started.
  + vout_RequestWindow() now stores the parent interface pointer into the vout
object for later use by vout_ControlWindow() and vout_ReleaseWindow().
  + added a vout_vaControlDefault() called by the vouts pf_control() when they
don't handle something.
* modules/video_output/directx/events.c, modules/video_output/x11/xcommon.c:
  + call vout_vaControlDefault().
* modules/gui/wxwindows/wxwindows.cpp: sets p_intf->b_dead when the interface is
about to be destroyed.

include/video_output.h
modules/gui/wxwindows/wxwindows.cpp
modules/video_output/directx/events.c
modules/video_output/x11/xcommon.c
src/video_output/video_output.c
src/video_output/vout_intf.c

index add6be1077f7120496e93360c5b0461f334ca8a7..924465660968a40014793f4d04b6b9982bdfca80 100644 (file)
@@ -89,6 +89,9 @@ struct vout_thread_t
     unsigned int        i_window_width;              /**< video window width */
     unsigned int        i_window_height;            /**< video window height */
     unsigned int        i_alignment;          /**< video alignment in window */
+
+    intf_thread_t       *p_parent_intf;   /**< parent interface for embedded
+                                                               vout (if any) */
     /**@}*/
 
     /** \name Plugin used and shortcuts to access its capabilities */
@@ -216,6 +219,8 @@ VLC_EXPORT( void,            vout_UnlinkPicture,  ( vout_thread_t *, picture_t *
 VLC_EXPORT( void,            vout_PlacePicture,   ( vout_thread_t *, unsigned int, unsigned int, unsigned int *, unsigned int *, unsigned int *, unsigned int * ) );
 picture_t *     vout_RenderPicture  ( vout_thread_t *, picture_t *,
                                                        subpicture_t * );
+
+VLC_EXPORT( int, vout_vaControlDefault, ( vout_thread_t *, int, va_list ) );
 VLC_EXPORT( void *, vout_RequestWindow, ( vout_thread_t *, int *, int *, unsigned int *, unsigned int * ) );
 VLC_EXPORT( void,   vout_ReleaseWindow, ( vout_thread_t *, void * ) );
 VLC_EXPORT( int, vout_ControlWindow, ( vout_thread_t *, void *, int, va_list ) );
index 85e9cd32247a7391525b1d4919b123bb990febfe..aa6fdd001ba21efff54616ea19574ff296ced4bc 100644 (file)
@@ -177,6 +177,10 @@ static void Close( vlc_object_t *p_this )
         vlc_object_release( p_intf->p_sys->p_input );
     }
 
+    vlc_mutex_lock( &p_intf->object_lock );
+    p_intf->b_dead = VLC_TRUE;
+    vlc_mutex_unlock( &p_intf->object_lock );
+
     if( p_intf->pf_show_dialog )
     {
         /* We must destroy the dialogs thread */
index 1eed8d71ca03e8d75890d7334ca0ad3beaba302b..e366b25cf2a866e7497123b8d2b496cca6a9ac1c 100644 (file)
@@ -933,7 +933,7 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
         SetWindowPos( p_vout->p_sys->hwnd, 0, point.x, point.y, 0, 0,
                       SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );
 
-      return VLC_SUCCESS;
+        return vout_vaControlDefault( p_vout, i_query, args );
 
     case VOUT_CLOSE:
         return VLC_SUCCESS;
@@ -947,7 +947,6 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
         return VLC_SUCCESS;
 
     default:
-        msg_Dbg( p_vout, "control query not supported" );
-        return VLC_EGENERIC;
+        return vout_vaControlDefault( p_vout, i_query, args );
     }
 }
index bf4979eac135387447abe7b16fb5438b88d8169b..863f69bc26c9ac75fa0f17150f1c436ed820d187 100644 (file)
@@ -2132,7 +2132,7 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
             XSync( p_vout->p_sys->p_display, False );
             p_vout->p_sys->p_win->owner_window = 0;
             vlc_mutex_unlock( &p_vout->p_sys->lock );
-            return VLC_SUCCESS;
+            return vout_vaControlDefault( p_vout, i_query, args );
 
         case VOUT_SET_STAY_ON_TOP:
             if( p_vout->p_sys->p_win->owner_window )
@@ -2146,8 +2146,7 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
             return VLC_SUCCESS;
 
        default:
-            msg_Dbg( p_vout, "control query not supported" );
-            return VLC_EGENERIC;
+            return vout_vaControlDefault( p_vout, i_query, args );
     }
 }
 
index 45fcb92f14f684f7fe4e978d4ecca0e87954e699..0ac229b0831552d7f01fa3813e9458c0ea7a04bf 100644 (file)
@@ -291,6 +291,7 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
     p_vout->c_fps_samples = 0;
     p_vout->b_filter_change = 0;
     p_vout->pf_control = 0;
+    p_vout->p_parent_intf = 0;
 
     /* Mouse coordinates */
     var_Create( p_vout, "mouse-x", VLC_VAR_INTEGER );
index 05e6500d4a646872bffe3f869bcb027f9125ba91..18e4f9395091b3c8bb1ca238b2613b6ab3328be3 100644 (file)
@@ -56,9 +56,11 @@ void *vout_RequestWindow( vout_thread_t *p_vout,
                           unsigned int *pi_width_hint,
                           unsigned int *pi_height_hint )
 {
-    intf_thread_t *p_intf;
+    intf_thread_t *p_intf = NULL;
+    vlc_list_t *p_list;
     void *p_window;
     vlc_value_t val;
+    int i;
 
     /* Get requested coordinates */
     var_Get( p_vout, "video-x", &val );
@@ -73,61 +75,88 @@ void *vout_RequestWindow( vout_thread_t *p_vout,
     var_Get( p_vout->p_vlc, "drawable", &val );
     if( val.i_int ) return (void *)val.i_int;
 
-    /* Find the main interface */
-    p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE );
-    if( !p_intf ) return NULL;
+    /* Find the first interface which supports embedding */
+    p_list = vlc_list_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE );
+    if( !p_list ) return NULL;
 
-    if( !p_intf->pf_request_window )
+    for( i = 0; i < p_list->i_count; i++ )
     {
-        vlc_object_release( p_intf );
+        p_intf = (intf_thread_t *)p_list->p_values[i].p_object;
+        if( p_intf->pf_request_window ) break;
+        p_intf = NULL;
+    }
+
+    if( !p_intf )
+    {
+        vlc_list_release( p_list );
         return NULL;
     }
 
+    vlc_object_yield( p_intf );
+    vlc_list_release( p_list );
+
     p_window = p_intf->pf_request_window( p_intf, p_vout, pi_x_hint, pi_y_hint,
                                           pi_width_hint, pi_height_hint );
-    vlc_object_release( p_intf );
+
+    if( !p_window ) vlc_object_release( p_intf );
+    else p_vout->p_parent_intf = p_intf;
 
     return p_window;
 }
 
 void vout_ReleaseWindow( vout_thread_t *p_vout, void *p_window )
 {
-    intf_thread_t *p_intf;
+    intf_thread_t *p_intf = p_vout->p_parent_intf;
 
-    /* Find the main interface */
-    p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE );
     if( !p_intf ) return;
 
+    vlc_mutex_lock( &p_intf->object_lock );
+    if( p_intf->b_dead )
+    {
+        vlc_mutex_unlock( &p_intf->object_lock );
+        return;
+    }
+
     if( !p_intf->pf_release_window )
     {
         msg_Err( p_vout, "no pf_release_window");
+        vlc_mutex_unlock( &p_intf->object_lock );
         vlc_object_release( p_intf );
         return;
     }
 
     p_intf->pf_release_window( p_intf, p_window );
+
+    p_vout->p_parent_intf = NULL;
+    vlc_mutex_unlock( &p_intf->object_lock );
     vlc_object_release( p_intf );
 }
 
 int vout_ControlWindow( vout_thread_t *p_vout, void *p_window,
                         int i_query, va_list args )
 {
-    intf_thread_t *p_intf;
+    intf_thread_t *p_intf = p_vout->p_parent_intf;
     int i_ret;
 
-    /* Find the main interface */
-    p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE );
     if( !p_intf ) return VLC_EGENERIC;
 
+    vlc_mutex_lock( &p_intf->object_lock );
+    if( p_intf->b_dead )
+    {
+        vlc_mutex_unlock( &p_intf->object_lock );
+        return VLC_EGENERIC;
+    }
+
     if( !p_intf->pf_control_window )
     {
         msg_Err( p_vout, "no pf_control_window");
+        vlc_mutex_unlock( &p_intf->object_lock );
         vlc_object_release( p_intf );
         return VLC_EGENERIC;
     }
 
     i_ret = p_intf->pf_control_window( p_intf, p_window, i_query, args );
-    vlc_object_release( p_intf );
+    vlc_mutex_unlock( &p_intf->object_lock );
     return i_ret;
 }
 
@@ -193,6 +222,29 @@ void vout_IntfInit( vout_thread_t *p_vout )
     var_AddCallback( p_vout, "fullscreen", FullscreenCallback, NULL );
 }
 
+/*****************************************************************************
+ * vout_ControlDefault: default methods for video output control.
+ *****************************************************************************/
+int vout_vaControlDefault( vout_thread_t *p_vout, int i_query, va_list args )
+{
+    switch( i_query )
+    {
+    case VOUT_REPARENT:
+    case VOUT_CLOSE:
+        if( p_vout->p_parent_intf )
+        {
+            vlc_object_release( p_vout->p_parent_intf );
+            p_vout->p_parent_intf = NULL;
+        }
+        return VLC_SUCCESS;
+        break;
+
+    default:
+        msg_Dbg( p_vout, "control query not supported" );
+        return VLC_EGENERIC;
+    }
+}
+
 /*****************************************************************************
  * Object variables callbacks
  *****************************************************************************/