[vlc-devel] [PATCH] modules: add module_shortcut_exists
Thomas Guillem
thomas at gllm.fr
Fri Feb 12 12:27:29 CET 2016
And remove module_find_by_shortcut that was unused.
This new function will be used by service discoveries in order to know if a
protocol is handled by the current vlc instance.
---
include/vlc_modules.h | 1 +
src/libvlc.h | 5 -----
src/libvlccore.sym | 1 +
src/modules/modules.c | 15 ++++++---------
4 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/include/vlc_modules.h b/include/vlc_modules.h
index 7f45217..ede6907 100644
--- a/include/vlc_modules.h
+++ b/include/vlc_modules.h
@@ -43,6 +43,7 @@ VLC_API module_t * module_need( vlc_object_t *, const char *, const char *, bool
VLC_API void module_unneed( vlc_object_t *, module_t * );
#define module_unneed(a,b) module_unneed(VLC_OBJECT(a),b)
VLC_API bool module_exists(const char *) VLC_USED;
+VLC_API bool module_shortcut_exists(const char *) VLC_USED;
VLC_API module_t * module_find(const char *) VLC_USED;
int module_start(vlc_object_t *, const module_t *);
diff --git a/src/libvlc.h b/src/libvlc.h
index d198581..fc57c2a 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -124,11 +124,6 @@ void vlc_object_set_destructor (vlc_object_t *, vlc_destructor_t);
#define vlc_object_set_destructor(a,b) \
vlc_object_set_destructor (VLC_OBJECT(a), b)
-/*
- * To be cleaned-up module stuff:
- */
-module_t *module_find_by_shortcut (const char *psz_shortcut);
-
#define ZOOM_SECTION N_("Zoom")
#define ZOOM_QUARTER_KEY_TEXT N_("1:4 Quarter")
#define ZOOM_HALF_KEY_TEXT N_("1:2 Half")
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 9491a18..0d35998 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -253,6 +253,7 @@ module_list_free
module_list_get
module_need
module_provides
+module_shortcut_exists
module_unneed
vlc_module_load
vlc_module_unload
diff --git a/src/modules/modules.c b/src/modules/modules.c
index 2fa9928..5b97e47 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -414,32 +414,29 @@ bool module_exists (const char * psz_name)
}
/**
- * Get a pointer to a module_t that matches a shortcut.
- * This is a temporary hack for SD. Do not re-use (generally multiple modules
- * can have the same shortcut, so this is *broken* - use module_need()!).
+ * Tell if a module can handle a shortcut
*
* \param psz_shortcut shortcut of the module
- * \param psz_cap capability of the module
- * \return a pointer to the module or NULL in case of a failure
+ * \return TRUE if a module can handle the shortcut
*/
-module_t *module_find_by_shortcut (const char *psz_shortcut)
+bool module_shortcut_exists (const char *psz_shortcut)
{
size_t count;
module_t **list = module_list_get (&count);
for (size_t i = 0; i < count; i++)
{
- module_t *module = list[count];
+ module_t *module = list[i];
for (size_t j = 0; j < module->i_shortcuts; j++)
if (!strcmp (module->pp_shortcuts[j], psz_shortcut))
{
module_list_free (list);
- return module;
+ return true;
}
}
module_list_free (list);
- return NULL;
+ return false;
}
/**
--
2.7.0
More information about the vlc-devel
mailing list