[vlc-devel] [PATCH 2/5] modules: add vlc_module_load_next/module_need_next
Thomas Guillem
thomas at gllm.fr
Wed Jun 3 17:35:42 CEST 2015
This extends vlc_module_load and module_need. You can now load a module
that come right after the current one in the priority list.
---
include/vlc_modules.h | 11 +++++++----
src/libvlccore.sym | 4 ++--
src/modules/modules.c | 25 +++++++++++++++++--------
3 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/include/vlc_modules.h b/include/vlc_modules.h
index 7f45217..51bd856 100644
--- a/include/vlc_modules.h
+++ b/include/vlc_modules.h
@@ -33,13 +33,16 @@ typedef void (*vlc_deactivate_t)(void *func, va_list args);
* Exported functions.
*****************************************************************************/
-VLC_API module_t * vlc_module_load( vlc_object_t *obj, const char *cap, const char *name, bool strict, vlc_activate_t probe, ... ) VLC_USED;
+VLC_API module_t * vlc_module_load_next( vlc_object_t *obj, const char *cap, const char *name, bool strict, module_t *current, vlc_activate_t probe, ... ) VLC_USED;
+#define vlc_module_load_next(o,c,n,s,cu,...) \
+ vlc_module_load_next(VLC_OBJECT(o),c,n,s,cu,__VA_ARGS__)
#define vlc_module_load(o,c,n,s,...) \
- vlc_module_load(VLC_OBJECT(o),c,n,s,__VA_ARGS__)
+ vlc_module_load_next(o,c,n,s,NULL,__VA_ARGS__)
VLC_API void vlc_module_unload( module_t *, vlc_deactivate_t deinit, ... );
-VLC_API module_t * module_need( vlc_object_t *, const char *, const char *, bool ) VLC_USED;
-#define module_need(a,b,c,d) module_need(VLC_OBJECT(a),b,c,d)
+VLC_API module_t * module_need_next( vlc_object_t *, const char *, const char *, bool, module_t * ) VLC_USED;
+#define module_need_next(a,b,c,d,e) module_need_next(VLC_OBJECT(a),b,c,d,e)
+#define module_need(a,b,c,d) module_need_next(a,b,c,d,NULL)
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;
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 86a3a82..ebbc0c3 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -258,10 +258,10 @@ module_get_score
module_gettext
module_list_free
module_list_get
-module_need
+module_need_next
module_provides
module_unneed
-vlc_module_load
+vlc_module_load_next
vlc_module_unload
vlc_Log
vlc_LogSet
diff --git a/src/modules/modules.c b/src/modules/modules.c
index 0f966f7..e0453c1 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -176,7 +176,7 @@ static int module_load (vlc_object_t *obj, module_t *m,
return ret;
}
-#undef vlc_module_load
+#undef vlc_module_load_next
/**
* Finds and instantiates the best module of a certain type.
* All candidates modules having the specified capability and name will be
@@ -194,12 +194,13 @@ static int module_load (vlc_object_t *obj, module_t *m,
* \param name name name of the module asked, if any
* \param strict if true, do not fallback to plugin with a different name
* but the same capability
+ * \param current if not NULL, only load a module that is after this current one.
* \param probe module probe callback
* \return the module or NULL in case of a failure
*/
-module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
- const char *name, bool strict,
- vlc_activate_t probe, ...)
+module_t *vlc_module_load_next(vlc_object_t *obj, const char *capability,
+ const char *name, bool strict, module_t *current,
+ vlc_activate_t probe, ...)
{
char *var = NULL;
@@ -236,6 +237,14 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
{
module_cap *modcap = &modcaps[i];
+ /* ignore all modules before current */
+ if (current != NULL)
+ {
+ if (modcap->p_module == current)
+ current = NULL;
+ continue;
+ }
+
if (modcap->i_cap_score == -1)
goto done;
if (modcap->i_cap_score == 0 && (strict || module_get_score (modcap->p_module) <= 0))
@@ -304,11 +313,11 @@ static void generic_stop(void *func, va_list ap)
deactivate(obj);
}
-#undef module_need
-module_t *module_need(vlc_object_t *obj, const char *cap, const char *name,
- bool strict)
+#undef module_need_next
+module_t *module_need_next(vlc_object_t *obj, const char *cap, const char *name,
+ bool strict, module_t *current)
{
- return vlc_module_load(obj, cap, name, strict, generic_start, obj);
+ return vlc_module_load_next(obj, cap, name, strict, current, generic_start, obj);
}
#undef module_unneed
--
2.1.4
More information about the vlc-devel
mailing list