From 66fe08f31c11e6b5fdc8b20096c3859a02750faa Mon Sep 17 00:00:00 2001
From: Nicolas LeQuec <nicolas.lequec@gmail.com>
Date: Tue, 13 Jul 2021 18:06:08 +0200
Subject: [PATCH] libvlc-module: add the tracer module

---
 src/libvlc-module.c | 6 ++++++
 src/misc/tracer.c   | 7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 9caaaaa2259c..b35ce06cf178 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1085,6 +1085,10 @@ static const char* const ppsz_restore_playback_desc[] = {
     "You can select which VoD server module you want to use. Set this " \
     "to 'vod_rtsp' to switch back to the old, legacy module." )
 
+#define TRACER_TEXT N_("Tracer module")
+#define TRACER_LONGTEXT N_( \
+    "This allow to select which tracer module you want to use." )
+
 #define VLM_CONF_TEXT N_("VLM configuration file")
 #define VLM_CONF_LONGTEXT N_( \
     "Read a VLM configuration file as soon as VLM is started." )
@@ -2058,6 +2062,8 @@ vlc_module_begin ()
     set_section( N_("Special modules"), NULL )
     add_module("vod-server", "vod server", NULL,
                VOD_SERVER_TEXT, VOD_SERVER_LONGTEXT)
+    add_module("tracer", "tracer", NULL,
+               TRACER_TEXT, TRACER_LONGTEXT)
 
     set_section( N_("Plugins" ), NULL )
 #ifdef HAVE_DYNAMIC_PLUGINS
diff --git a/src/misc/tracer.c b/src/misc/tracer.c
index 727767815928..d0d2f088b7d0 100644
--- a/src/misc/tracer.c
+++ b/src/misc/tracer.c
@@ -78,11 +78,16 @@ static struct vlc_tracer *vlc_TraceModuleCreate(vlc_object_t *parent)
     if (unlikely(module == NULL))
         return NULL;
 
-    if (vlc_module_load(VLC_OBJECT(module), "tracer", NULL, false,
+    char *module_name = var_InheritString(parent, "tracer");
+    if (vlc_module_load(VLC_OBJECT(module), "tracer", module_name, false,
                         vlc_tracer_load, module) == NULL) {
         vlc_object_delete(VLC_OBJECT(module));
+        if (module_name)
+            free(module_name);
         return NULL;
     }
+    if (module_name)
+        free(module_name);
 
     return &module->tracer;
 }
-- 
GitLab