Commit b7cce616 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Hildon: partially fix vout window provider thread safety

parent ae57a467
......@@ -74,6 +74,14 @@ vlc_module_begin();
set_callbacks( OpenWindow, CloseWindow );
vlc_module_end();
static struct
{
vlc_mutex_t lock;
vlc_cond_t wait;
intf_thread_t *intf;
bool enabled;
} wnd_req = { VLC_STATIC_MUTEX, PTHREAD_COND_INITIALIZER, NULL, false };
/*****************************************************************************
* Module callbacks
*****************************************************************************/
......@@ -95,9 +103,9 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->p_main_window = NULL;
p_intf->p_sys->p_video_window = NULL;
wnd_req.enabled = true;
/* ^no need to lock, interfacesare started before video outputs */
vlc_spin_init( &p_intf->p_sys->event_lock );
vlc_mutex_init( &p_intf->p_sys->p_video_mutex );
vlc_cond_init( &p_intf->p_sys->p_video_cond );
return VLC_SUCCESS;
}
......@@ -246,6 +254,7 @@ static void Run( intf_thread_t *p_intf )
var_DelCallback( p_intf->p_sys->p_playlist, "activity",
activity_cb, p_intf );
/* FIXME: we need to wait for vout to clean up... */
assert( !p_intf->p_sys->p_vout ); /* too late */
gtk_object_destroy( GTK_OBJECT( window ) );
}
......@@ -264,27 +273,27 @@ static gboolean should_die( gpointer data )
static int OpenWindow (vlc_object_t *obj)
{
vout_window_t *wnd = (vout_window_t *)obj;
intf_thread_t *intf;
if (wnd->cfg->is_standalone)
if (wnd->cfg->is_standalone || !wnd_req.enabled)
return VLC_EGENERIC;
intf_thread_t *intf = (intf_thread_t*)vlc_object_find_name (obj, "maemo", FIND_ANYWHERE);
if (intf == NULL)
{
msg_Err( obj, "Maemo interface not found" );
return VLC_EGENERIC; /* Maemo not in use */
}
/* FIXME it should NOT be needed */
vout_thread_t *vout = vlc_object_find (obj, VLC_OBJECT_VOUT, FIND_PARENT);
if (!vout)
return VLC_EGENERIC;
vlc_mutex_lock (&wnd_req.lock);
while ((intf = wnd_req.intf) == NULL)
vlc_cond_wait (&wnd_req.wait, &wnd_req.lock);
wnd->handle.xid = request_video( intf, vout );
vlc_mutex_unlock (&wnd_req.lock);
vlc_object_release( vout );
if (!wnd->handle.xid)
{
vlc_object_release( vout );
return VLC_EGENERIC;
}
vlc_object_release( vout );
msg_Dbg( intf, "Using handle %"PRIu32, wnd->handle.xid );
......@@ -322,8 +331,9 @@ static void CloseWindow (vlc_object_t *obj)
vout_window_t *wnd = (vout_window_t *)obj;
intf_thread_t *intf = (intf_thread_t *)wnd->sys;
vlc_mutex_lock( &wnd_req.lock );
release_video( intf );
vlc_object_release (intf);
vlc_mutex_unlock( &wnd_req.lock );
}
static uint32_t request_video( intf_thread_t *p_intf, vout_thread_t *p_nvout )
......@@ -334,16 +344,6 @@ static uint32_t request_video( intf_thread_t *p_intf, vout_thread_t *p_nvout )
return 0;
}
vlc_mutex_lock( &p_intf->p_sys->p_video_mutex );
mutex_cleanup_push( &p_intf->p_sys->p_video_mutex );
// We wait until the p_video_window is set
while( p_intf->p_sys->p_video_window == NULL )
vlc_cond_wait( &p_intf->p_sys->p_video_cond,
&p_intf->p_sys->p_video_mutex );
vlc_cleanup_run();
p_intf->p_sys->p_vout = vlc_object_hold( p_nvout );
return GDK_WINDOW_XID( p_intf->p_sys->p_video_window->window );
}
......@@ -368,7 +368,10 @@ static gboolean video_widget_ready( gpointer data )
p_intf->p_sys->p_video_window = video;
gtk_widget_grab_focus( video );
vlc_cond_signal( &p_intf->p_sys->p_video_cond );
vlc_mutex_lock( &wnd_req.lock );
wnd_req.intf = p_intf;
vlc_cond_signal( &wnd_req.wait );
vlc_mutex_unlock( &wnd_req.lock );
// We rewind the input
if( p_intf->p_sys->p_input )
......
......@@ -47,6 +47,4 @@ struct intf_sys_t
GtkWidget *p_video_window;
vout_thread_t *p_vout;
vlc_cond_t p_video_cond;
vlc_mutex_t p_video_mutex;
};
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