[vlc-commits] netsync: fix and simplify dead input handling (fixes #5426)

Rémi Denis-Courmont git at videolan.org
Sat Aug 16 14:48:57 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug 16 15:42:21 2014 +0300| [cc69b31845705795702f18d1dcc7f51da9244ab9] | committer: Rémi Denis-Courmont

netsync: fix and simplify dead input handling (fixes #5426)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cc69b31845705795702f18d1dcc7f51da9244ab9
---

 modules/control/netsync.c |   42 ++++++++++++++++--------------------------
 1 file changed, 16 insertions(+), 26 deletions(-)

diff --git a/modules/control/netsync.c b/modules/control/netsync.c
index 2ced26b..b833141 100644
--- a/modules/control/netsync.c
+++ b/modules/control/netsync.c
@@ -151,8 +151,13 @@ void Close(vlc_object_t *object)
     intf_thread_t *intf = (intf_thread_t*)object;
     intf_sys_t *sys = intf->p_sys;
 
-    assert(sys->input == NULL);
     var_DelCallback(sys->playlist, "input-current", PlaylistEvent, intf);
+
+    if (sys->input != NULL) {
+        vlc_cancel(sys->thread);
+        vlc_join(sys->thread, NULL);
+    }
+
     net_Close(sys->fd);
     free(sys);
 }
@@ -266,43 +271,28 @@ static void *Slave(void *handle)
     return NULL;
 }
 
-static int InputEvent(vlc_object_t *object, char const *cmd,
-                      vlc_value_t oldval, vlc_value_t newval, void *data)
+static int PlaylistEvent(vlc_object_t *object, char const *cmd,
+                         vlc_value_t oldval, vlc_value_t newval, void *data)
 {
-    VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(object);
+    VLC_UNUSED(cmd); VLC_UNUSED(object);
     intf_thread_t  *intf = data;
     intf_sys_t     *sys = intf->p_sys;
+    input_thread_t *input = newval.p_address;
 
-    if (newval.i_int == INPUT_EVENT_DEAD && sys->input) {
+    if (sys->input != NULL) {
         msg_Err(intf, "InputEvent DEAD");
+        assert(oldval.p_address == sys->input);
+
         vlc_cancel(sys->thread);
         vlc_join(sys->thread, NULL);
-        vlc_object_release(sys->input);
-        sys->input = NULL;
     }
-    return VLC_SUCCESS;
-}
 
-static int PlaylistEvent(vlc_object_t *object, char const *cmd,
-                         vlc_value_t oldval, vlc_value_t newval, void *data)
-{
-    VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(object);
-    intf_thread_t  *intf = data;
-    intf_sys_t     *sys = intf->p_sys;
-    input_thread_t *input = newval.p_address;
+    sys->input = input;
 
-    assert(sys->input == NULL);
-
-    if (input != NULL)
-    {
-        sys->input = vlc_object_hold(input);
+    if (input != NULL) {
         if (vlc_clone(&sys->thread, sys->is_master ? Master : Slave, intf,
-                      VLC_THREAD_PRIORITY_INPUT)) {
-            vlc_object_release(input);
+                      VLC_THREAD_PRIORITY_INPUT))
             sys->input = NULL;
-            return VLC_SUCCESS;
-        }
-        var_AddCallback(input, "intf-event", InputEvent, intf);
     }
     return VLC_SUCCESS;
 }



More information about the vlc-commits mailing list