static int AddIntfCallback( vlc_object_t *, char const *,
vlc_value_t , vlc_value_t , void * );
+/**
+ * \brief Destroy the interface after the main loop endeed.
+ *
+ * \param p_intf the interface thread
+ * \return nothing
+ */
+static void intf_Destroy( vlc_object_t *obj )
+{
+ intf_thread_t *p_intf = (intf_thread_t *)obj;
+
+ /* Unlock module if present (a switch may have failed) */
+ if( p_intf->p_module )
+ module_Unneed( p_intf, p_intf->p_module );
+
+ free( p_intf->psz_intf );
+ vlc_mutex_destroy( &p_intf->change_lock );
+}
+
/*****************************************************************************
* intf_Create: prepare interface before main loop
*****************************************************************************
p_intf->b_menu_change = false;
/* Initialize mutexes */
- vlc_mutex_init( p_intf, &p_intf->change_lock );
+ vlc_mutex_init( &p_intf->change_lock );
/* Attach interface to its parent object */
vlc_object_attach( p_intf, p_this );
+ vlc_object_set_destructor( p_intf, intf_Destroy );
return p_intf;
}
*/
int intf_RunThread( intf_thread_t *p_intf )
{
- /* This interface doesn't need to be run */
- if( p_intf->pf_run == NULL )
- return VLC_SUCCESS;
-
/* Hack to get Mac OS X Cocoa runtime running
* (it needs access to the main thread) */
if( p_intf->b_should_run_on_first_thread )
{
RunInterface( p_intf );
+ vlc_object_detach( p_intf );
+ vlc_object_release( p_intf );
return VLC_SUCCESS;
}
{
/* Tell the interface to die */
vlc_object_kill( p_intf );
- if( p_intf->pf_run != NULL )
- {
- vlc_cond_signal( &p_intf->object_wait );
- vlc_thread_join( p_intf );
- }
+ vlc_cond_signal( &p_intf->object_wait );
+ vlc_thread_join( p_intf );
}
-/**
- * \brief Destroy the interface after the main loop endeed.
- *
- * Destroys interfaces and closes output devices
- * \param p_intf the interface thread
- * \return nothing
- */
-void intf_Destroy( intf_thread_t *p_intf )
-{
- /* Unlock module if present (a switch may have failed) */
- if( p_intf->p_module )
- {
- module_Unneed( p_intf, p_intf->p_module );
- }
- free( p_intf->psz_intf );
-
- vlc_mutex_destroy( &p_intf->change_lock );
-
- /* Free structure */
- vlc_object_release( p_intf );
-}
-
-
/* Following functions are local */
/*****************************************************************************
do
{
/* Give control to the interface */
- p_intf->pf_run( p_intf );
+ if( p_intf->pf_run )
+ p_intf->pf_run( p_intf );
+ else
+ while( vlc_object_lock_and_wait( p_intf ) == 0 );
/* Reset play on start status */
p_intf->b_play = false;
if( intf_RunThread( p_intf ) != VLC_SUCCESS )
{
vlc_object_detach( p_intf );
- intf_Destroy( p_intf );
+ vlc_object_release( p_intf );
return VLC_EGENERIC;
}