[vlc-devel] [RFC PATCH 1/2] modules: add module_need_ignored
Thomas Guillem
thomas at gllm.fr
Fri Apr 8 16:44:42 CEST 2016
Load a module that is not in the module ignore list.
---
include/vlc_modules.h | 8 +++++---
modules/audio_output/mmdevice.c | 2 +-
modules/audio_output/winstore.c | 2 +-
modules/codec/avcodec/va.c | 2 +-
src/config/core.c | 2 +-
src/misc/messages.c | 2 +-
src/modules/bank.c | 27 ++++++++++++++++++++++-----
src/modules/modules.c | 13 +++++++++++--
src/modules/modules.h | 2 +-
src/network/tls.c | 4 ++--
src/video_output/window.c | 2 +-
11 files changed, 47 insertions(+), 19 deletions(-)
diff --git a/include/vlc_modules.h b/include/vlc_modules.h
index 7f45217..c016576 100644
--- a/include/vlc_modules.h
+++ b/include/vlc_modules.h
@@ -33,13 +33,15 @@ 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;
-#define vlc_module_load(o,c,n,s,...) \
- vlc_module_load(VLC_OBJECT(o),c,n,s,__VA_ARGS__)
+VLC_API module_t * vlc_module_load( vlc_object_t *obj, const char *cap, const char *name, bool strict, module_t **ignore_list, size_t ignore_count, vlc_activate_t probe, ... ) VLC_USED;
+#define vlc_module_load(o,c,n,s,t,u,...) \
+ vlc_module_load(VLC_OBJECT(o),c,n,s,t,u,__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_ignored( vlc_object_t *, const char *, const char *, bool, module_t **, size_t ) VLC_USED;
+#define module_need_ignored(a,b,c,d,e,f) module_need_ignored(VLC_OBJECT(a),b,c,d,e,f)
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/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 286bc9d..0cea94b 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1059,7 +1059,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
HRESULT hr;
/* TODO: Do not overload the "aout" configuration item. */
- sys->module = vlc_module_load(s, "aout stream", "$aout", false,
+ sys->module = vlc_module_load(s, "aout stream", "$aout", false, NULL, 0,
aout_stream_Start, s, fmt, &hr);
if (hr != AUDCLNT_E_DEVICE_INVALIDATED || DeviceSelect(aout, NULL))
break;
diff --git a/modules/audio_output/winstore.c b/modules/audio_output/winstore.c
index 4734f39..5f7de09 100644
--- a/modules/audio_output/winstore.c
+++ b/modules/audio_output/winstore.c
@@ -146,7 +146,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
s->owner.activate = ActivateDevice;
EnterMTA();
- sys->module = vlc_module_load(s, "aout stream", NULL, false,
+ sys->module = vlc_module_load(s, "aout stream", NULL, false, NULL, 0,
aout_stream_Start, s, fmt, &hr);
LeaveMTA();
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index f534f89..6ca75a1 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -104,7 +104,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
if (unlikely(va == NULL))
return NULL;
- va->module = vlc_module_load(va, "hw decoder", "$avcodec-hw", true,
+ va->module = vlc_module_load(va, "hw decoder", "$avcodec-hw", true, NULL, 0,
vlc_va_Start, va, avctx, pix_fmt, fmt, p_sys);
if (va->module == NULL)
{
diff --git a/src/config/core.c b/src/config/core.c
index 322b5f0..813abcd 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -383,7 +383,7 @@ static ssize_t config_ListModules (const char *cap, char ***restrict values,
char ***restrict texts)
{
module_t **list;
- ssize_t n = module_list_cap (&list, cap);
+ ssize_t n = module_list_cap (&list, cap, NULL, 0);
if (n <= 0)
{
*values = *texts = NULL;
diff --git a/src/misc/messages.c b/src/misc/messages.c
index b838bdd..0c347ad 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -360,7 +360,7 @@ int vlc_LogInit(libvlc_int_t *vlc)
void *sys, *early_sys = NULL;
/* TODO: module configuration item */
- module_t *module = vlc_module_load(logger, "logger", NULL, false,
+ module_t *module = vlc_module_load(logger, "logger", NULL, false, NULL, 0,
vlc_logger_load, logger, &cb, &sys);
if (module == NULL)
cb = vlc_vaLogDiscard;
diff --git a/src/modules/bank.c b/src/modules/bank.c
index 19292e6..13e02bc 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -247,6 +247,18 @@ static int modulecmp (const void *a, const void *b)
return (*mb)->i_score - (*ma)->i_score;
}
+
+static bool module_ignored (module_t *module, module_t **ignore_list,
+ size_t ignore_count)
+{
+ for (size_t i = 0; i < ignore_count; ++i)
+ {
+ if (ignore_list[i] == module)
+ return true;
+ }
+ return false;
+}
+
/**
* Builds a sorted list of all VLC modules with a given capability.
* The list is sorted from the highest module score to the lowest.
@@ -255,7 +267,8 @@ static int modulecmp (const void *a, const void *b)
* @return the number of matching found, or -1 on error (*list is then NULL).
* @note *list must be freed with module_list_free().
*/
-ssize_t module_list_cap (module_t ***restrict list, const char *cap)
+ssize_t module_list_cap (module_t ***restrict list, const char *cap,
+ module_t **ignore_list, size_t ignore_count)
{
/* TODO: This is quite inefficient. List should be sorted by capability. */
ssize_t n = 0;
@@ -264,10 +277,12 @@ ssize_t module_list_cap (module_t ***restrict list, const char *cap)
for (module_t *mod = modules.head; mod != NULL; mod = mod->next)
{
- if (module_provides (mod, cap))
+ if (module_provides (mod, cap)
+ && !module_ignored (mod, ignore_list, ignore_count))
n++;
for (module_t *subm = mod->submodule; subm != NULL; subm = subm->next)
- if (module_provides (subm, cap))
+ if (module_provides (subm, cap)
+ && !module_ignored (mod, ignore_list, ignore_count))
n++;
}
@@ -278,10 +293,12 @@ ssize_t module_list_cap (module_t ***restrict list, const char *cap)
for (module_t *mod = modules.head; mod != NULL; mod = mod->next)
{
- if (module_provides (mod, cap))
+ if (module_provides (mod, cap)
+ && !module_ignored (mod, ignore_list, ignore_count))
*(tab++)= mod;
for (module_t *subm = mod->submodule; subm != NULL; subm = subm->next)
- if (module_provides (subm, cap))
+ if (module_provides (subm, cap)
+ && !module_ignored (mod, ignore_list, ignore_count))
*(tab++) = subm;
}
diff --git a/src/modules/modules.c b/src/modules/modules.c
index 6dd2678..0f22e42 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -211,6 +211,7 @@ static int module_load (vlc_object_t *obj, module_t *m,
*/
module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
const char *name, bool strict,
+ module_t **ignore_list, size_t ignore_count,
vlc_activate_t probe, ...)
{
char *var = NULL;
@@ -227,7 +228,7 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
/* Find matching modules */
module_t **mods;
- ssize_t total = module_list_cap (&mods, capability);
+ ssize_t total = module_list_cap (&mods, capability, ignore_list, ignore_count);
msg_Dbg (obj, "looking for %s module matching \"%s\": %zd candidates",
capability, name, total);
@@ -363,7 +364,15 @@ static void generic_stop(void *func, va_list ap)
module_t *module_need(vlc_object_t *obj, const char *cap, const char *name,
bool strict)
{
- return vlc_module_load(obj, cap, name, strict, generic_start, obj);
+ return vlc_module_load(obj, cap, name, strict, NULL, 0, generic_start, obj);
+}
+
+#undef module_need_ignored
+module_t *module_need_ignored(vlc_object_t *obj, const char *cap, const char *name,
+ bool strict, module_t **ignore_list, size_t ignore_count)
+{
+ return vlc_module_load(obj, cap, name, strict, ignore_list, ignore_count,
+ generic_start, obj);
}
#undef module_unneed
diff --git a/src/modules/modules.h b/src/modules/modules.h
index e38e952..e2b38f2 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -110,7 +110,7 @@ size_t module_LoadPlugins( vlc_object_t * );
void module_EndBank (bool);
int module_Map (vlc_object_t *, module_t *);
-ssize_t module_list_cap (module_t ***, const char *);
+ssize_t module_list_cap (module_t ***, const char *, module_t **, size_t);
int vlc_bindtextdomain (const char *);
diff --git a/src/network/tls.c b/src/network/tls.c
index 5787051..2026f64 100644
--- a/src/network/tls.c
+++ b/src/network/tls.c
@@ -83,7 +83,7 @@ vlc_tls_ServerCreate (vlc_object_t *obj, const char *cert_path,
if (key_path == NULL)
key_path = cert_path;
- srv->module = vlc_module_load (srv, "tls server", NULL, false,
+ srv->module = vlc_module_load (srv, "tls server", NULL, false, NULL, 0,
tls_server_load, srv, cert_path, key_path);
if (srv->module == NULL)
{
@@ -102,7 +102,7 @@ vlc_tls_creds_t *vlc_tls_ClientCreate (vlc_object_t *obj)
if (unlikely(crd == NULL))
return NULL;
- crd->module = vlc_module_load (crd, "tls client", NULL, false,
+ crd->module = vlc_module_load (crd, "tls client", NULL, false, NULL, 0,
tls_client_load, crd);
if (crd->module == NULL)
{
diff --git a/src/video_output/window.c b/src/video_output/window.c
index 8b3826a..9c11128 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -68,7 +68,7 @@ vout_window_t *vout_window_New(vlc_object_t *obj, const char *module,
window->owner.resized = NULL;
w->module = vlc_module_load(window, "vout window", module,
- module && *module,
+ module && *module, NULL, 0,
vout_window_start, window, cfg);
if (!w->module) {
vlc_object_release(window);
--
2.8.0.rc3
More information about the vlc-devel
mailing list