[vlc-devel] [PATCH] plugins: do not capture set of null-capability modules
Lyndon Brown
jnqnfe at gmail.com
Sat Sep 26 20:58:29 CEST 2020
attached. preview below.
i can move the discussion of the reasoning for skipping null-cap
modules from the comment block to the commit log if preferred.
similarly i'll move the minor documentation enhancements i slipped in
here to a separate commit if preferred.
From: Lyndon Brown <jnqnfe at gmail.com>
Date: Fri, 5 Apr 2019 12:07:27 +0100
Subject: plugins: do not capture set of null-capability modules
as explained in the comment, there are plugins where the first module has
a null capability.
for such modules, the module_get_capability() call would return "none",
and the pre-organised/sorted tree would thus store such modules under a
supposed capability of "none". this is pointless and unwanted.
diff --git a/src/modules/bank.c b/src/modules/bank.c
index 12330d695d..5d5b997925 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -102,16 +102,25 @@ static struct
vlc_plugin_t *vlc_plugins = NULL;
/**
- * Adds a module to the bank
+ * Add a module to the pre-organised sets
*/
static int vlc_module_store(module_t *mod)
{
- const char *name = module_get_capability(mod);
+ /* Some plugins authors choose to call add_submodule() without having
+ actually setup the initial module with a capability and callbacks; where
+ a plugin has multiple modules, this is sometimes done deliberately in
+ order that the initial module is utilised for holding name and help text
+ properties that apply to that group of modules as a whole, being used
+ for instance in help output against the plugin's option set. We have no
+ interest in recording such entries in the capability tree, so we skip it. */
+ if (unlikely(mod->psz_capability == NULL))
+ return 0;
+
vlc_modcap_t *cap = malloc(sizeof (*cap));
if (unlikely(cap == NULL))
return -1;
- cap->name = strdup(name);
+ cap->name = strdup(mod->psz_capability);
cap->modv = NULL;
cap->modc = 0;
@@ -148,9 +157,11 @@ static void vlc_plugin_store(vlc_plugin_t *lib)
{
vlc_mutex_assert(&modules.lock);
+ /* Add the plugin to the linked list */
lib->next = vlc_plugins;
vlc_plugins = lib;
+ /* Add modules to the pre-organised sets */
for (module_t *m = lib->module; m != NULL; m = m->next)
vlc_module_store(m);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: null_cap.patch
Type: text/x-patch
Size: 2114 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200926/a49295a2/attachment.bin>
More information about the vlc-devel
mailing list