Browse Source

modules: pull logger usage

pull/85/head
Rémi Denis-Courmont 8 years ago
parent
commit
19f90e804c
  1. 19
      include/vlc_modules.h
  2. 33
      src/modules/modules.c

19
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;

33
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);

Loading…
Cancel
Save