While reading this, you will find a bunch of:
while (find (VLC_OBJECT_INTERFACE))
release; release;
These are of course plain BUGS (which are neither introduced nor fixed
by this commit). Imagine, for instance, what happens if two threads run
the code above at the same time... they end up releasing the interface
once too many.
VLC_EXPORT( intf_thread_t *, __intf_Create, ( vlc_object_t *, const char *, int, const char *const * ) );
VLC_EXPORT( int, intf_RunThread, ( intf_thread_t * ) );
VLC_EXPORT( void, intf_StopThread, ( intf_thread_t * ) );
VLC_EXPORT( intf_thread_t *, __intf_Create, ( vlc_object_t *, const char *, int, const char *const * ) );
VLC_EXPORT( int, intf_RunThread, ( intf_thread_t * ) );
VLC_EXPORT( void, intf_StopThread, ( intf_thread_t * ) );
-VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) );
/* If the interface is in the main thread, it should listen both to
* p_intf->b_die and p_libvlc->b_die */
/* If the interface is in the main thread, it should listen both to
* p_intf->b_die and p_libvlc->b_die */
intf_StopThread( p_intf );
vlc_object_detach( p_intf );
vlc_object_release( p_intf );
intf_StopThread( p_intf );
vlc_object_detach( p_intf );
vlc_object_release( p_intf );
- intf_Destroy( p_intf );
+ vlc_object_release( p_intf );
intf_StopThread( p_intf );
vlc_object_detach( p_intf );
vlc_object_release( p_intf );
intf_StopThread( p_intf );
vlc_object_detach( p_intf );
vlc_object_release( p_intf );
- intf_Destroy( p_intf );
+ vlc_object_release( p_intf );
intf_StopThread( p_extraintf );
vlc_object_detach( p_extraintf );
vlc_object_release( p_extraintf );
intf_StopThread( p_extraintf );
vlc_object_detach( p_extraintf );
vlc_object_release( p_extraintf );
- intf_Destroy( p_extraintf );
+ vlc_object_release( p_extraintf );
}
/* Make sure we exit (In case other interfaces have been spawned) */
}
/* Make sure we exit (In case other interfaces have been spawned) */
if( intf_RunThread( p_new_intf ) )
{
vlc_object_detach( p_new_intf );
if( intf_RunThread( p_new_intf ) )
{
vlc_object_detach( p_new_intf );
- intf_Destroy( p_new_intf );
+ vlc_object_release( p_new_intf );
msg_Err( p_intf, "interface \"%s\" cannot run", psz_temp );
}
msg_Err( p_intf, "interface \"%s\" cannot run", psz_temp );
}
if( intf_RunThread( p_newintf ) )
{
vlc_object_detach( p_newintf );
if( intf_RunThread( p_newintf ) )
{
vlc_object_detach( p_newintf );
- intf_Destroy( p_newintf );
+ vlc_object_release( p_newintf );
static int AddIntfCallback( vlc_object_t *, char const *,
vlc_value_t , vlc_value_t , void * );
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
*****************************************************************************
/*****************************************************************************
* intf_Create: prepare interface before main loop
*****************************************************************************
/* Attach interface to its parent object */
vlc_object_attach( p_intf, p_this );
/* Attach interface to its parent object */
vlc_object_attach( p_intf, p_this );
+ vlc_object_set_destructor( p_intf, intf_Destroy );
if( p_intf->b_should_run_on_first_thread )
{
RunInterface( p_intf );
if( p_intf->b_should_run_on_first_thread )
{
RunInterface( p_intf );
+ vlc_object_detach( p_intf );
+ vlc_object_release( 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 */
/*****************************************************************************
/* Following functions are local */
/*****************************************************************************
if( intf_RunThread( p_intf ) != VLC_SUCCESS )
{
vlc_object_detach( p_intf );
if( intf_RunThread( p_intf ) != VLC_SUCCESS )
{
vlc_object_detach( p_intf );
- intf_Destroy( p_intf );
+ vlc_object_release( p_intf );
{
intf_StopThread( p_intf );
vlc_object_detach( p_intf );
{
intf_StopThread( p_intf );
vlc_object_detach( p_intf );
- vlc_object_release( p_intf );
- intf_Destroy( p_intf );
- p_intf = NULL;
+ vlc_object_release( p_intf ); /* for intf_Create() */
+ vlc_object_release( p_intf ); /* for vlc_object_find() */
}
/* Free video outputs */
}
/* Free video outputs */
/* Try to run the interface */
p_intf->b_play = b_play;
i_err = intf_RunThread( p_intf );
/* Try to run the interface */
p_intf->b_play = b_play;
i_err = intf_RunThread( p_intf );
- if( i_err || p_intf->b_should_run_on_first_thread )
{
vlc_object_detach( p_intf );
{
vlc_object_detach( p_intf );
- intf_Destroy( p_intf );
- p_intf = NULL;
+ vlc_object_release( p_intf );
while( vlc_object_lock_and_wait( p_intf ) == 0 );
vlc_object_detach( p_intf );
while( vlc_object_lock_and_wait( p_intf ) == 0 );
vlc_object_detach( p_intf );
- intf_Destroy( p_intf );
+ vlc_object_release( p_intf );
input_StopThread
input_vaControl
__intf_Create
input_StopThread
input_vaControl
__intf_Create
__intf_Eject
__intf_Progress
__intf_ProgressUpdate
__intf_Eject
__intf_Progress
__intf_ProgressUpdate