[vlc-devel] [PATCH 1/3] modules: add add_submodule_name()
Thomas Guillem
thomas at gllm.fr
Tue Nov 7 18:40:34 CET 2017
Allow to create a sub module with its own name.
---
include/vlc_plugin.h | 7 +++++++
src/modules/entry.c | 12 ++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/include/vlc_plugin.h b/include/vlc_plugin.h
index 7e9e447d04..496c08374e 100644
--- a/include/vlc_plugin.h
+++ b/include/vlc_plugin.h
@@ -105,6 +105,9 @@ enum vlc_module_properties
/* callback for suggested values
* (args=const char *, size_t (*)(vlc_object_t *, <type> **, char ***)) */
+ VLC_MODULE_CREATE_SUBMODULE,
+ /* create a new submodule with a specified name (args=const char *) */
+
/* Insert new VLC_CONFIG_* here */
};
@@ -273,6 +276,10 @@ VLC_METADATA_EXPORTS
if (vlc_plugin_set (VLC_MODULE_CREATE, &module)) \
goto error;
+#define add_submodule_name( name ) \
+ if (vlc_plugin_set (VLC_MODULE_CREATE_SUBMODULE, &module, (const char *) name)) \
+ goto error;
+
#define add_shortcut( ... ) \
{ \
const char *shortcuts[] = { __VA_ARGS__ }; \
diff --git a/src/modules/entry.c b/src/modules/entry.c
index 29044fa5d4..a751a643c2 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -198,6 +198,7 @@ static int vlc_plugin_desc_cb(void *ctx, void *tgt, int propid, ...)
va_start (ap, propid);
switch (propid)
{
+ case VLC_MODULE_CREATE_SUBMODULE:
case VLC_MODULE_CREATE:
{
module_t *super = plugin->module;
@@ -209,12 +210,19 @@ static int vlc_plugin_desc_cb(void *ctx, void *tgt, int propid, ...)
}
*(va_arg (ap, module_t **)) = submodule;
+ assert(propid == VLC_MODULE_CREATE_SUBMODULE ? super != NULL : true);
if (super == NULL)
break;
- /* Inheritance. Ugly!! */
submodule->pp_shortcuts = xmalloc (sizeof ( *submodule->pp_shortcuts ));
- submodule->pp_shortcuts[0] = super->pp_shortcuts[0];
+ if (propid == VLC_MODULE_CREATE_SUBMODULE)
+ {
+ const char *name = va_arg (ap, const char *);
+ assert(name != NULL);
+ submodule->pp_shortcuts[0] = name;
+ }
+ else
+ submodule->pp_shortcuts[0] = super->pp_shortcuts[0];
submodule->i_shortcuts = 1; /* object name */
submodule->psz_shortname = super->psz_shortname;
--
2.11.0
More information about the vlc-devel
mailing list