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

input: inline vlc_object_kill() and simplify

parent 7066acb7
......@@ -70,8 +70,6 @@ static int Init ( input_thread_t *p_input );
static void End ( input_thread_t *p_input );
static void MainLoop( input_thread_t *p_input, bool b_interactive );
static void ObjectKillChildrens( input_thread_t *, vlc_object_t * );
static inline int ControlPop( input_thread_t *, int *, vlc_value_t *, mtime_t i_deadline, bool b_postpone_seek );
static void ControlRelease( int i_type, vlc_value_t val );
static bool ControlIsSeekRequest( int i_type );
......@@ -242,7 +240,7 @@ void input_Stop( input_thread_t *p_input, bool b_abort )
/* Set die for input and ALL of this childrens (even (grand-)grand-childrens)
* It is needed here even if it is done in INPUT_CONTROL_SET_DIE handler to
* unlock the control loop */
ObjectKillChildrens( p_input, VLC_OBJECT(p_input) );
ObjectKillChildrens( VLC_OBJECT(p_input) );
vlc_mutex_lock( &p_input->p->lock_control );
p_input->p->b_abort |= b_abort;
......@@ -285,25 +283,6 @@ input_item_t *input_GetItem( input_thread_t *p_input )
return p_input->p->p_item;
}
/*****************************************************************************
* ObjectKillChildrens
*****************************************************************************/
static void ObjectKillChildrens( input_thread_t *p_input, vlc_object_t *p_obj )
{
vlc_list_t *p_list;
/* FIXME ObjectKillChildrens seems a very bad idea in fact */
if( p_obj == VLC_OBJECT(p_input->p->p_sout) )
return;
vlc_object_kill( p_obj );
p_list = vlc_list_children( p_obj );
for( int i = 0; i < p_list->i_count; i++ )
ObjectKillChildrens( p_input, p_list->p_values[i].p_object );
vlc_list_release( p_list );
}
/*****************************************************************************
* This function creates a new input, and returns a pointer
* to its description. On error, it returns NULL.
......@@ -1686,7 +1665,7 @@ static bool Control( input_thread_t *p_input,
msg_Dbg( p_input, "control: stopping input" );
/* Mark all submodules to die */
ObjectKillChildrens( p_input, VLC_OBJECT(p_input) );
ObjectKillChildrens( VLC_OBJECT(p_input) );
break;
case INPUT_CONTROL_SET_POSITION:
......
......@@ -58,8 +58,7 @@ void vlc_CPU_dump(vlc_object_t *);
int vlc_clone_detach (vlc_thread_t *, void *(*)(void *), void *, int);
int vlc_object_waitpipe (vlc_object_t *obj);
void vlc_object_kill (vlc_object_t *) VLC_DEPRECATED;
#define vlc_object_kill(o) vlc_object_kill(VLC_OBJECT(o))
void ObjectKillChildrens (vlc_object_t *);
int vlc_set_priority( vlc_thread_t, int );
......
......@@ -378,34 +378,36 @@ int vlc_object_waitpipe( vlc_object_t *obj )
return internals->pipes[0];
}
#undef vlc_object_kill
/**
* Requests termination of an object, cancels the object thread, and make the
* object wait pipe (if it exists) readable. Not a cancellation point.
* Hack for input objects. Should be removed eventually.
*/
void vlc_object_kill( vlc_object_t *p_this )
void ObjectKillChildrens( vlc_object_t *p_obj )
{
vlc_object_internals_t *priv = vlc_internals( p_this );
int fd = -1;
/* FIXME ObjectKillChildrens seems a very bad idea in fact */
/*if( p_obj == VLC_OBJECT(p_input->p->p_sout) ) return;*/
vlc_object_internals_t *priv = vlc_internals (p_obj);
if (atomic_exchange (&priv->alive, false))
{
int fd;
vlc_mutex_lock (&pipe_lock);
fd = priv->pipes[1];
vlc_mutex_unlock (&pipe_lock);
if (fd != -1)
{
write (fd, &(uint64_t){ 1 }, sizeof (uint64_t));
msg_Dbg (p_obj, "object waitpipe triggered");
}
}
if (fd != -1)
{
int canc = vlc_savecancel ();
/* write _after_ setting b_die, so vlc_object_alive() returns false */
write (fd, &(uint64_t){ 1 }, sizeof (uint64_t));
msg_Dbg (p_this, "waitpipe: object killed");
vlc_restorecancel (canc);
}
vlc_list_t *p_list = vlc_list_children( p_obj );
for( int i = 0; i < p_list->i_count; i++ )
ObjectKillChildrens( p_list->p_values[i].p_object );
vlc_list_release( p_list );
}
#undef vlc_object_find_name
/**
* Finds a named object and increment its reference count.
......
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