Commit a748c625 authored by Gildas Bazin's avatar Gildas Bazin

* src/video_output/vout_intf.c, include/video_output.h:

  + 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.
parent d6d2450d
......@@ -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 ) );
......
......@@ -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 */
......
......@@ -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 );
}
}
......@@ -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 );
}
}
......
......@@ -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 );
......
......@@ -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
*****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment