[vlc-commits] modules: pull logger usage
Rémi Denis-Courmont
git at videolan.org
Mon Mar 4 21:05:56 CET 2019
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 4 21:21:38 2019 +0200| [19f90e804c199bad3aa5a299e47d09bb7ad7f8ee] | committer: Rémi Denis-Courmont
modules: pull logger usage
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=19f90e804c199bad3aa5a299e47d09bb7ad7f8ee
---
include/vlc_modules.h | 19 ++++++++++++++++---
src/modules/modules.c | 33 ++++++++++++++++-----------------
2 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/include/vlc_modules.h b/include/vlc_modules.h
index b047b1ac57..a39f0485db 100644
--- a/include/vlc_modules.h
+++ b/include/vlc_modules.h
@@ -30,14 +30,27 @@
typedef int (*vlc_activate_t)(void *func, bool forced, va_list args);
typedef void (*vlc_deactivate_t)(void *func, va_list args);
+struct vlc_logger;
/*****************************************************************************
* 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, ...) \
- vlc_module_load(VLC_OBJECT(o), c, n, __VA_ARGS__)
+VLC_API module_t *vlc_module_load(struct vlc_logger *log, const char *cap,
+ const char *name, bool strict,
+ vlc_activate_t probe, ... ) VLC_USED;
+#ifndef __cplusplus
+#define vlc_module_load(ctx, cap, name, strict, ...) \
+ _Generic ((ctx), \
+ struct vlc_logger *: \
+ vlc_module_load((void *)(ctx), cap, name, strict, __VA_ARGS__), \
+ void *: \
+ vlc_module_load((void *)(ctx), cap, name, strict, __VA_ARGS__), \
+ default: \
+ vlc_module_load(vlc_object_logger((vlc_object_t *)(ctx)), cap, \
+ name, strict, __VA_ARGS__))
+#endif
+
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;
diff --git a/src/modules/modules.c b/src/modules/modules.c
index a7b59ad4c0..1d8c9f15ae 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -151,12 +151,12 @@ static bool module_match_name(const module_t *m, const char *name, size_t len)
return false;
}
-static int module_load (vlc_object_t *obj, module_t *m,
- vlc_activate_t init, bool forced, va_list args)
+static int module_load(vlc_logger_t *log, module_t *m,
+ vlc_activate_t init, bool forced, va_list args)
{
int ret = VLC_SUCCESS;
- if (module_Map(obj->obj.logger, m->plugin))
+ if (module_Map(log, m->plugin))
return VLC_EGENERIC;
if (m->pf_activate != NULL)
@@ -171,7 +171,6 @@ static int module_load (vlc_object_t *obj, module_t *m,
return ret;
}
-#undef vlc_module_load
/**
* Finds and instantiates the best module of a certain type.
* All candidates modules having the specified capability and name will be
@@ -184,7 +183,7 @@ static int module_load (vlc_object_t *obj, module_t *m,
* variable arguments passed to this function. This scheme is meant to
* support arbitrary prototypes for the module entry point.
*
- * \param obj VLC object
+ * \param log logger (or NULL to ignore)
* \param capability capability, i.e. class of module
* \param name name of the module asked, if any
* \param strict if true, do not fallback to plugin with a different name
@@ -192,9 +191,9 @@ static int module_load (vlc_object_t *obj, module_t *m,
* \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)(struct vlc_logger *log, const char *capability,
+ const char *name, bool strict,
+ vlc_activate_t probe, ...)
{
if (name == NULL || name[0] == '\0')
name = "any";
@@ -203,12 +202,12 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
module_t **mods;
ssize_t total = module_list_cap (&mods, capability);
- msg_Dbg (obj, "looking for %s module matching \"%s\": %zd candidates",
- capability, name, total);
+ vlc_debug(log, "looking for %s module matching \"%s\": %zd candidates",
+ capability, name, total);
if (total <= 0)
{
module_list_free (mods);
- msg_Dbg (obj, "no %s modules", capability);
+ vlc_debug(log, "no %s modules", capability);
return NULL;
}
@@ -237,7 +236,7 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
continue;
mods[i] = NULL; // only try each module once at most...
- int ret = module_load(obj, cand, probe, force, args);
+ int ret = module_load(log, cand, probe, force, args);
switch (ret)
{
case VLC_SUCCESS:
@@ -258,7 +257,7 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
if (cand == NULL || module_get_score (cand) <= 0)
continue;
- int ret = module_load(obj, cand, probe, false, args);
+ int ret = module_load(log, cand, probe, false, args);
switch (ret)
{
case VLC_SUCCESS:
@@ -274,10 +273,10 @@ done:
module_list_free (mods);
if (module != NULL)
- msg_Dbg (obj, "using %s module \"%s\"", capability,
- module_get_object (module));
+ vlc_debug(log, "using %s module \"%s\"", capability,
+ module_get_object (module));
else
- msg_Dbg (obj, "no %s modules matched", capability);
+ vlc_debug(log, "no %s modules matched", capability);
return module;
}
@@ -325,7 +324,7 @@ module_t *module_need(vlc_object_t *obj, const char *cap, const char *name,
bool strict)
{
const bool b_force_backup = obj->obj.force; /* FIXME: remove this */
- module_t *module = vlc_module_load(obj, cap, name, strict,
+ module_t *module = vlc_module_load(obj->obj.logger, cap, name, strict,
generic_start, obj);
if (module != NULL) {
var_Create(obj, "module-name", VLC_VAR_STRING);
More information about the vlc-commits
mailing list