[vlc-devel] [PATCH 4/6] modules: add module_Symbol() internal helper

RĂ©mi Denis-Courmont remi at remlab.net
Thu Jul 18 21:29:21 CEST 2019


---
 src/modules/bank.c    | 18 ++++++++++++++++++
 src/modules/modules.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/src/modules/bank.c b/src/modules/bank.c
index 8bc85b06ba..06a251d877 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -592,6 +592,17 @@ static void module_Unmap(vlc_plugin_t *plugin)
     if (handle != NULL)
         vlc_dlclose(handle);
 }
+
+void *module_Symbol(struct vlc_logger *log,
+                    vlc_plugin_t *plugin, const char *name)
+{
+    if (module_Map(log, plugin))
+        return NULL;
+
+    void *handle = (void *)atomic_load_explicit(&plugin->handle,
+                                                memory_order_relaxed);
+    return vlc_dlsym(handle, name);
+}
 #else
 int module_Map(struct vlc_logger *log, vlc_plugin_t *plugin)
 {
@@ -603,6 +614,13 @@ static void module_Unmap(vlc_plugin_t *plugin)
 {
     (void) plugin;
 }
+
+void *module_Symbol(struct vlc_logger *log,
+                    vlc_plugin_t *plugin, const char *name)
+{
+    (void) log; (void) plugin; (void) name;
+    return NULL;
+}
 #endif /* HAVE_DYNAMIC_PLUGINS */
 
 /**
diff --git a/src/modules/modules.h b/src/modules/modules.h
index 1c7d32e8e5..118a3aa7c4 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -111,6 +111,7 @@ void module_LoadPlugins(vlc_object_t *);
 #define module_LoadPlugins(a) module_LoadPlugins(VLC_OBJECT(a))
 void module_EndBank (bool);
 int module_Map(struct vlc_logger *, vlc_plugin_t *);
+void *module_Symbol(struct vlc_logger *, vlc_plugin_t *, const char *name);
 
 ssize_t module_list_cap (module_t ***, const char *);
 
-- 
2.22.0



More information about the vlc-devel mailing list