static void Error ( input_thread_t *p_input );
static void End ( input_thread_t *p_input );
static void MainLoop( input_thread_t *p_input );
-static void Destroy( input_thread_t *p_input, sout_instance_t **pp_sout );
static inline int ControlPopNoLock( input_thread_t *, int *, vlc_value_t * );
static void ControlReduce( input_thread_t * );
TAB_INIT( p_input->p->i_attachment, p_input->p->attachment );
p_input->p->p_es_out = NULL;
p_input->p->p_sout = NULL;
+ p_input->p->b_owns_its_sout = VLC_TRUE;
p_input->p->b_sout_keep = VLC_FALSE;
p_input->p->b_out_pace_control = VLC_FALSE;
p_input->i_pts_delay = 0;
/* */
if( p_sout )
+ {
p_input->p->p_sout = p_sout;
+ p_input->p->b_owns_its_sout = VLC_FALSE;
+ }
/* Attach only once we are ready */
vlc_object_attach( p_input, p_parent );
return p_input;
}
-/* FIXME: This function should go away and only vlc_object_release()
- * should be needed */
-static void Destroy( input_thread_t *p_input, sout_instance_t **pp_sout )
+/**
+ * Input destructor (called when the object's refcount reaches 0).
+ */
+static void Destructor( input_thread_t * p_input )
{
- vlc_object_detach( p_input );
input_thread_private_t *priv = p_input->p;
- if( pp_sout )
- *pp_sout = NULL;
- if( priv->p_sout )
+ if( priv->b_owns_its_sout && priv->p_sout )
{
- if( pp_sout )
- *pp_sout = priv->p_sout;
- else if( priv->b_sout_keep )
+ if( priv->b_sout_keep )
SoutKeep( priv->p_sout );
else
- {
sout_DeleteInstance( priv->p_sout );
- priv->p_sout = NULL;
- }
}
- vlc_object_release( p_input );
-}
-
-/**
- * Input destructor (called when the object's refcount reaches 0).
- */
-static void Destructor( input_thread_t * p_input )
-{
- input_thread_private_t *priv = p_input->p;
vlc_mutex_destroy( &priv->lock_control );
free( priv );
}
{
input_ChangeState( p_input, ERROR_S );
msg_Err( p_input, "cannot create input thread" );
- Destroy( p_input, &p_sout );
+ vlc_object_detach( p_input );
+ vlc_object_release( p_input );
return NULL;
}
{
input_ChangeState( p_input, ERROR_S );
msg_Err( p_input, "cannot create input thread" );
- Destroy( p_input, NULL );
+ vlc_object_detach( p_input );
+ vlc_object_release( p_input );
return VLC_EGENERIC;
}
}
if( !Init( p_input ) )
End( p_input );
- Destroy( p_input, NULL );
+ vlc_object_detach( p_input );
+ vlc_object_release( p_input );
return VLC_SUCCESS;
}
input_ControlPush( p_input, INPUT_CONTROL_SET_DIE, NULL );
}
+sout_instance_t * input_DetachSout( input_thread_t *p_input )
+{
+ p_input->p->b_owns_its_sout = VLC_FALSE;
+ return p_input->p->p_sout;
+}
+
/**
* Clean up a dead input thread
* This function does not return until the thread is effectively cancelled.
* \param the input thread to kill
*/
void input_DestroyThread( input_thread_t *p_input )
-{
- input_DestroyThreadExtended( p_input, NULL );
-}
-
-void input_DestroyThreadExtended( input_thread_t *p_input, sout_instance_t **pp_sout )
{
/* Join the thread */
vlc_thread_join( p_input );
/* */
- Destroy( p_input, pp_sout );
+ vlc_object_detach( p_input );
+ vlc_object_release( p_input );
}
/*****************************************************************************
exit:
/* Release memory */
- Destroy( p_input, NULL );
+ vlc_object_detach( p_input );
+ vlc_object_release( p_input );
return 0;
}
msleep( 100000 );
input_StopThread( p_input );
- input_DestroyThreadExtended( p_input, NULL );
+ input_DestroyThread( p_input );
}
free( psz_output );
free( psz_header );
if( p_instance->p_input )
{
input_StopThread( p_instance->p_input );
- input_DestroyThreadExtended( p_instance->p_input, &p_instance->p_sout );
+ p_instance->p_sout = input_DetachSout( p_instance->p_input );
+ input_DestroyThread( p_instance->p_input );
}
if( p_instance->p_sout )
sout_DeleteInstance( p_instance->p_sout );
}
input_StopThread( p_instance->p_input );
- input_DestroyThreadExtended( p_instance->p_input, &p_instance->p_sout );
+ p_instance->p_sout = input_DetachSout( p_instance->p_input );
+ input_DestroyThread( p_instance->p_input );
if( !p_instance->b_sout_keep && p_instance->p_sout )
{
sout_DeleteInstance( p_instance->p_sout );