[vlc-commits] misc: move object variables debug dump to variables.c

Rémi Denis-Courmont git at videolan.org
Thu May 21 19:32:58 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 21 19:50:15 2015 +0300| [af4bb51ccf854b904ccbfdbe1c670134d6fe0fcf] | committer: Rémi Denis-Courmont

misc: move object variables debug dump to variables.c

No functional changes

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

 src/misc/objects.c   |   74 +------------------------------------------------
 src/misc/variables.c |   75 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/misc/variables.h |    1 +
 3 files changed, 77 insertions(+), 73 deletions(-)

diff --git a/src/misc/objects.c b/src/misc/objects.c
index 7604e56..56ebcc4 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -568,73 +568,6 @@ vlc_list_t *vlc_list_children( vlc_object_t *obj )
     return l;
 }
 
-static void DumpVariable (const void *data, const VISIT which, const int depth)
-{
-    if (which != postorder && which != leaf)
-        return;
-    (void) depth;
-
-    const variable_t *p_var = *(const variable_t **)data;
-    const char *psz_type = "unknown";
-
-    switch( p_var->i_type & VLC_VAR_TYPE )
-    {
-#define MYCASE( type, nice )    \
-        case VLC_VAR_ ## type:  \
-            psz_type = nice;    \
-            break;
-        MYCASE( VOID, "void" );
-        MYCASE( BOOL, "bool" );
-        MYCASE( INTEGER, "integer" );
-        MYCASE( HOTKEY, "hotkey" );
-        MYCASE( STRING, "string" );
-        MYCASE( VARIABLE, "variable" );
-        MYCASE( FLOAT, "float" );
-        MYCASE( TIME, "time" );
-        MYCASE( COORDS, "coords" );
-        MYCASE( ADDRESS, "address" );
-#undef MYCASE
-    }
-    printf( " *-o \"%s\" (%s", p_var->psz_name, psz_type );
-    if( p_var->psz_text )
-        printf( ", %s", p_var->psz_text );
-    fputc( ')', stdout );
-    if( p_var->i_type & VLC_VAR_HASCHOICE )
-        fputs( ", has choices", stdout );
-    if( p_var->i_type & VLC_VAR_ISCOMMAND )
-        fputs( ", command", stdout );
-    if( p_var->value_callbacks.i_entries )
-        printf( ", %d callbacks", p_var->value_callbacks.i_entries );
-    switch( p_var->i_type & VLC_VAR_CLASS )
-    {
-        case VLC_VAR_VOID:
-            break;
-        case VLC_VAR_BOOL:
-            printf( ": %s", p_var->val.b_bool ? "true" : "false" );
-            break;
-        case VLC_VAR_INTEGER:
-            printf( ": %"PRId64, p_var->val.i_int );
-            break;
-        case VLC_VAR_STRING:
-            printf( ": \"%s\"", p_var->val.psz_string );
-            break;
-        case VLC_VAR_FLOAT:
-            printf( ": %f", p_var->val.f_float );
-            break;
-        case VLC_VAR_TIME:
-            printf( ": %"PRIi64, (int64_t)p_var->val.i_time );
-            break;
-        case VLC_VAR_COORDS:
-            printf( ": %"PRId32"x%"PRId32,
-                    p_var->val.coords.x, p_var->val.coords.y );
-            break;
-        case VLC_VAR_ADDRESS:
-            printf( ": %p", p_var->val.p_address );
-            break;
-    }
-    fputc( '\n', stdout );
-}
-
 /*****************************************************************************
  * DumpCommand: print the current vlc structure
  *****************************************************************************
@@ -673,12 +606,7 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
             p_object = p_this->p_libvlc ? VLC_OBJECT(p_this->p_libvlc) : p_this;
 
         PrintObject( vlc_internals(p_object), "" );
-        vlc_mutex_lock( &vlc_internals( p_object )->var_lock );
-        if( vlc_internals( p_object )->var_root == NULL )
-            puts( " `-o No variables" );
-        else
-            twalk( vlc_internals( p_object )->var_root, DumpVariable );
-        vlc_mutex_unlock( &vlc_internals( p_object )->var_lock );
+        DumpVariables(p_object);
     }
     libvlc_unlock (p_this->p_libvlc);
 
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 36e6dce..4ac7ddd 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -1421,3 +1421,78 @@ void var_FreeList( vlc_value_t *p_val, vlc_value_t *p_val2 )
         free( p_val2->p_list );
     }
 }
+
+static void DumpVariable(const void *data, const VISIT which, const int depth)
+{
+    if (which != postorder && which != leaf)
+        return;
+    (void) depth;
+
+    const variable_t *var = *(const variable_t **)data;
+    const char *typename = "unknown";
+
+    switch (var->i_type & VLC_VAR_TYPE)
+    {
+        case VLC_VAR_VOID:     typename = "void";        break;
+        case VLC_VAR_BOOL:     typename = "bool";        break;
+        case VLC_VAR_INTEGER:  typename = "integer";     break;
+        case VLC_VAR_HOTKEY:   typename = "hotkey";      break;
+        case VLC_VAR_STRING:   typename = "string";      break;
+        case VLC_VAR_VARIABLE: typename = "variable";    break;
+        case VLC_VAR_FLOAT:    typename = "float";       break;
+        case VLC_VAR_TIME:     typename = "time";        break;
+        case VLC_VAR_COORDS:   typename = "coordinates"; break;
+        case VLC_VAR_ADDRESS:  typename = "address";     break;
+        default:               typename = "unknown";     break;
+    }
+
+    printf(" *-o \"%s\" (%s", var->psz_name, typename);
+    if (var->psz_text != NULL)
+        printf(", %s", var->psz_text);
+    putchar(')');
+    if (var->i_type & VLC_VAR_HASCHOICE)
+        fputs(", has choices", stdout);
+    if (var->i_type & VLC_VAR_ISCOMMAND)
+        fputs(", command", stdout);
+    if (var->value_callbacks.i_entries)
+        printf(", %d callbacks", var->value_callbacks.i_entries);
+
+    switch (var->i_type & VLC_VAR_CLASS)
+    {
+        case VLC_VAR_VOID:
+            break;
+        case VLC_VAR_BOOL:
+            printf(": %s", var->val.b_bool ? "true" : "false");
+            break;
+        case VLC_VAR_INTEGER:
+            printf(": %"PRId64, var->val.i_int );
+            break;
+        case VLC_VAR_STRING:
+            printf(": \"%s\"", var->val.psz_string );
+            break;
+        case VLC_VAR_FLOAT:
+            printf(": %f", var->val.f_float );
+            break;
+        case VLC_VAR_TIME:
+            printf(": %"PRId64, var->val.i_time);
+            break;
+        case VLC_VAR_COORDS:
+            printf(": %"PRId32"x%"PRId32,
+                   var->val.coords.x, var->val.coords.y);
+            break;
+        case VLC_VAR_ADDRESS:
+            printf(": %p", var->val.p_address);
+            break;
+    }
+    putchar('\n');
+}
+
+void DumpVariables(vlc_object_t *obj)
+{
+    vlc_mutex_lock(&vlc_internals(obj)->var_lock);
+    if (vlc_internals(obj)->var_root == NULL)
+        puts(" `-o No variables");
+    else
+        twalk(vlc_internals(obj)->var_root, DumpVariable);
+    vlc_mutex_unlock(&vlc_internals(obj)->var_lock);
+}
diff --git a/src/misc/variables.h b/src/misc/variables.h
index 35b8203..6cdce0c 100644
--- a/src/misc/variables.h
+++ b/src/misc/variables.h
@@ -56,6 +56,7 @@ struct vlc_object_internals
 # define vlc_internals( obj ) (((vlc_object_internals_t*)(VLC_OBJECT(obj)))-1)
 # define vlc_externals( priv ) ((vlc_object_t *)((priv) + 1))
 
+void DumpVariables(vlc_object_t *obj);
 
 typedef struct callback_entry_t callback_entry_t;
 



More information about the vlc-commits mailing list