[vlc-devel] [PATCH 2/3] objects: allow using DumpStructure in other parts of the core

Steve Lhomme robux4 at ycbcr.xyz
Tue Mar 12 09:24:55 CET 2019


---
 src/misc/objects.c   | 9 +++++----
 src/misc/variables.h | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/misc/objects.c b/src/misc/objects.c
index 481536d258..61318c951a 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -117,7 +117,7 @@ static void PrintObject(vlc_object_t *obj, FILE *output)
     vlc_restorecancel (canc);
 }
 
-static void DumpStructure(vlc_object_t *obj, FILE *output, unsigned level)
+void DumpStructure(vlc_object_t *obj, FILE *output, unsigned level, bool locked)
 {
     PrintObject(obj, output);
 
@@ -129,9 +129,10 @@ static void DumpStructure(vlc_object_t *obj, FILE *output, unsigned level)
 
     vlc_object_internals_t *priv;
 
-    vlc_mutex_assert(&tree_lock);
+    if (locked)
+        vlc_mutex_assert(&tree_lock);
     vlc_children_foreach(priv, vlc_internals(obj))
-        DumpStructure(vlc_externals(priv), output, level + 1);
+        DumpStructure(vlc_externals(priv), output, level + 1, locked);
 }
 
 /**
@@ -148,7 +149,7 @@ static int TreeCommand (vlc_object_t *obj, char const *cmd,
 
     flockfile(stdout);
     vlc_mutex_lock(&tree_lock);
-    DumpStructure(obj, stdout, 0);
+    DumpStructure(obj, stdout, 0, true);
     vlc_mutex_unlock(&tree_lock);
     funlockfile(stdout);
     return VLC_SUCCESS;
diff --git a/src/misc/variables.h b/src/misc/variables.h
index b850553687..10bf2db369 100644
--- a/src/misc/variables.h
+++ b/src/misc/variables.h
@@ -60,6 +60,7 @@ struct vlc_object_internals
 # define vlc_externals( priv ) ((vlc_object_t *)((priv) + 1))
 
 void DumpVariables(vlc_object_t *obj);
+void DumpStructure(vlc_object_t *obj, FILE *output, unsigned level, bool locked);
 
 extern void var_DestroyAll( vlc_object_t * );
 
-- 
2.17.1



More information about the vlc-devel mailing list