Allow using an object's psz_object_name as id for the libvlc_global commands "tree...
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 24 Mar 2007 17:13:40 +0000 (17:13 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 24 Mar 2007 17:13:40 +0000 (17:13 +0000)
./vlc -I rc --sub-filter marq@test --no-audio ~/media/redefined-nintendo.mpg
vars test
(instead of "vars 376" ... or whatever the integer id is)

src/misc/objects.c

index 35bc2b6..4a9dd7e 100644 (file)
@@ -805,7 +805,30 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
 
         if( *newval.psz_string )
         {
-            p_object = vlc_object_get( p_this, atoi(newval.psz_string) );
+            char *end;
+            int i_id = strtol( newval.psz_string, &end, 0 );
+            if( end != newval.psz_string )
+                p_object = vlc_object_get( p_this, i_id );
+            else
+            {
+                /* try using the object's name to find it */
+                vlc_object_t *p_libvlc = vlc_object_get( p_this, 1 );
+                if( p_libvlc )
+                {
+                    /* Look in p_libvlc's children tree */
+                    p_object = vlc_object_find_name( p_libvlc,
+                                                     newval.psz_string,
+                                                     FIND_CHILD );
+                    vlc_object_release( p_libvlc );
+                }
+                if( !p_object )
+                {
+                    /* If it's not in libvlc, look in libvlc_global (== p_this) */
+                    p_object = vlc_object_find_name( p_this,
+                                                     newval.psz_string,
+                                                     FIND_CHILD );
+                }
+            }
 
             if( !p_object )
             {