[vlc-commits] input: inline vlc_object_kill() and simplify
Rémi Denis-Courmont
git at videolan.org
Tue Mar 26 16:47:36 CET 2013
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Mar 26 17:46:38 2013 +0200| [72210bb453862f0b0986306af9df18572e3ee09b] | committer: Rémi Denis-Courmont
input: inline vlc_object_kill() and simplify
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=72210bb453862f0b0986306af9df18572e3ee09b
---
src/input/input.c | 25 ++-----------------------
src/libvlc.h | 3 +--
src/misc/objects.c | 32 +++++++++++++++++---------------
3 files changed, 20 insertions(+), 40 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index 073de23..d1462e8 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -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;
@@ -286,25 +284,6 @@ input_item_t *input_GetItem( input_thread_t *p_input )
}
/*****************************************************************************
- * 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:
diff --git a/src/libvlc.h b/src/libvlc.h
index c116d03..f6185c9 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -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 );
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 3e365bd..ad65a97 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -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.
More information about the vlc-commits
mailing list