[vlc-commits] Handle NULL value in "input-current" callback

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:28:25 2014 +0300| [3c2c9364a1f0c9c34db661a22be6cb8b490dc0cb] | committer: Rémi Denis-Courmont

Handle NULL value in "input-current" callback

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

 modules/control/gestures.c         |    8 ++++++--
 modules/control/netsync.c          |   20 ++++++++++++--------
 modules/gui/skins2/src/vlcproc.cpp |   12 +++++++-----
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/modules/control/gestures.c b/modules/control/gestures.c
index d526971..a820b55 100644
--- a/modules/control/gestures.c
+++ b/modules/control/gestures.c
@@ -508,8 +508,12 @@ static int PlaylistEvent( vlc_object_t *p_this, char const *psz_var,
 
     (void) p_this; (void) psz_var; (void) oldval;
 
-    var_AddCallback( p_input, "intf-event", InputEvent, p_intf );
     assert( p_sys->p_input == NULL );
-    p_sys->p_input = vlc_object_hold( p_input );
+
+    if( p_input != NULL )
+    {
+        var_AddCallback( p_input, "intf-event", InputEvent, p_intf );
+        p_sys->p_input = vlc_object_hold( p_input );
+    }
     return VLC_SUCCESS;
 }
diff --git a/modules/control/netsync.c b/modules/control/netsync.c
index 88bc429..2ced26b 100644
--- a/modules/control/netsync.c
+++ b/modules/control/netsync.c
@@ -289,17 +289,21 @@ static int PlaylistEvent(vlc_object_t *object, char const *cmd,
     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;
+
     assert(sys->input == NULL);
-    sys->input = vlc_object_hold(input);
-    if (vlc_clone(&sys->thread, sys->is_master ? Master : Slave, intf,
-                  VLC_THREAD_PRIORITY_INPUT)) {
-        vlc_object_release(input);
-        sys->input = NULL;
-        return VLC_SUCCESS;
+
+    if (input != NULL)
+    {
+        sys->input = vlc_object_hold(input);
+        if (vlc_clone(&sys->thread, sys->is_master ? Master : Slave, intf,
+                      VLC_THREAD_PRIORITY_INPUT)) {
+            vlc_object_release(input);
+            sys->input = NULL;
+            return VLC_SUCCESS;
+        }
+        var_AddCallback(input, "intf-event", InputEvent, intf);
     }
-    var_AddCallback(input, "intf-event", InputEvent, intf);
     return VLC_SUCCESS;
 }
 
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index dcf3b30..7cf4882 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -227,11 +227,13 @@ int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
     VlcProc *pThis = (VlcProc*)pParam;
     input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
 
-    var_AddCallback( pInput, "intf-event", onGenericCallback2, pThis );
-    var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
-    var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
-    var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
-
+    if( pInput != NULL )
+    {
+        var_AddCallback( pInput, "intf-event", onGenericCallback2, pThis );
+        var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
+        var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
+        var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
+    }
     return VLC_SUCCESS;
 }
 



More information about the vlc-commits mailing list