]> git.sesse.net Git - vlc/commitdiff
input: inline vlc_object_kill() and simplify
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 26 Mar 2013 15:46:38 +0000 (17:46 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 26 Mar 2013 15:47:31 +0000 (17:47 +0200)
src/input/input.c
src/libvlc.h
src/misc/objects.c

index 073de23a172dc13c8893227b098dde64d19e2a69..d1462e8dd811cfa7ed58c247b513788fcd4958dc 100644 (file)
@@ -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:
index c116d035b4efd91e67bfe818dbc2c380d83594cb..f6185c9efc9bdd944ead969c1e96b2bcf483bc4f 100644 (file)
@@ -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 );
 
index 3e365bda3c66cc936d5f74eb4bdd9b4bed557ef1..ad65a97260a4f8055b56511804c9994896b8851e 100644 (file)
@@ -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.