Browse Source

modules: pass force flag as parameter to activation callback

pull/85/head
Rémi Denis-Courmont 8 years ago
parent
commit
fc13953d90
  1. 2
      include/vlc_modules.h
  2. 3
      modules/audio_output/mmdevice.c
  3. 1
      modules/audio_output/winstore.c
  4. 3
      modules/codec/avcodec/va.c
  5. 3
      src/input/decoder_helpers.c
  6. 3
      src/input/demux.c
  7. 3
      src/misc/messages.c
  8. 19
      src/modules/modules.c
  9. 6
      src/network/tls.c
  10. 3
      src/video_output/display.c
  11. 3
      src/video_output/opengl.c
  12. 3
      src/video_output/window.c

2
include/vlc_modules.h

@ -28,7 +28,7 @@
* This file defines functions for modules in vlc * This file defines functions for modules in vlc
*/ */
typedef int (*vlc_activate_t)(void *func, va_list args); typedef int (*vlc_activate_t)(void *func, bool forced, va_list args);
typedef void (*vlc_deactivate_t)(void *func, va_list args); typedef void (*vlc_deactivate_t)(void *func, va_list args);
/***************************************************************************** /*****************************************************************************

3
modules/audio_output/mmdevice.c

@ -1095,7 +1095,7 @@ static HRESULT ActivateDevice(void *opaque, REFIID iid, PROPVARIANT *actparms,
return IMMDevice_Activate(dev, iid, CLSCTX_ALL, actparms, pv); return IMMDevice_Activate(dev, iid, CLSCTX_ALL, actparms, pv);
} }
static int aout_stream_Start(void *func, va_list ap) static int aout_stream_Start(void *func, bool forced, va_list ap)
{ {
aout_stream_start_t start = func; aout_stream_start_t start = func;
aout_stream_t *s = va_arg(ap, aout_stream_t *); aout_stream_t *s = va_arg(ap, aout_stream_t *);
@ -1103,6 +1103,7 @@ static int aout_stream_Start(void *func, va_list ap)
HRESULT *hr = va_arg(ap, HRESULT *); HRESULT *hr = va_arg(ap, HRESULT *);
LPCGUID sid = var_InheritBool(s, "volume-save") ? &GUID_VLC_AUD_OUT : NULL; LPCGUID sid = var_InheritBool(s, "volume-save") ? &GUID_VLC_AUD_OUT : NULL;
(void) forced;
*hr = start(s, fmt, sid); *hr = start(s, fmt, sid);
if (*hr == AUDCLNT_E_DEVICE_INVALIDATED) if (*hr == AUDCLNT_E_DEVICE_INVALIDATED)
return VLC_ETIMEOUT; return VLC_ETIMEOUT;

1
modules/audio_output/winstore.c

@ -214,6 +214,7 @@ static int aout_stream_Start(void *func, va_list ap)
audio_sample_format_t *fmt = va_arg(ap, audio_sample_format_t *); audio_sample_format_t *fmt = va_arg(ap, audio_sample_format_t *);
HRESULT *hr = va_arg(ap, HRESULT *); HRESULT *hr = va_arg(ap, HRESULT *);
(void) forced;
*hr = start(s, fmt, &GUID_VLC_AUD_OUT); *hr = start(s, fmt, &GUID_VLC_AUD_OUT);
return SUCCEEDED(*hr) ? VLC_SUCCESS : VLC_EGENERIC; return SUCCEEDED(*hr) ? VLC_SUCCESS : VLC_EGENERIC;
} }

3
modules/codec/avcodec/va.c

@ -88,7 +88,7 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt)
} }
} }
static int vlc_va_Start(void *func, va_list ap) static int vlc_va_Start(void *func, bool forced, va_list ap)
{ {
vlc_va_t *va = va_arg(ap, vlc_va_t *); vlc_va_t *va = va_arg(ap, vlc_va_t *);
AVCodecContext *ctx = va_arg(ap, AVCodecContext *); AVCodecContext *ctx = va_arg(ap, AVCodecContext *);
@ -98,6 +98,7 @@ static int vlc_va_Start(void *func, va_list ap)
int (*open)(vlc_va_t *, AVCodecContext *, enum PixelFormat, int (*open)(vlc_va_t *, AVCodecContext *, enum PixelFormat,
const es_format_t *, void *) = func; const es_format_t *, void *) = func;
(void) forced;
return open(va, ctx, pix_fmt, fmt, p_sys); return open(va, ctx, pix_fmt, fmt, p_sys);
} }

3
src/input/decoder_helpers.c

@ -97,7 +97,7 @@ struct vlc_decoder_device_priv
module_t *module; module_t *module;
}; };
static int decoder_device_Open(void *func, va_list ap) static int decoder_device_Open(void *func, bool forced, va_list ap)
{ {
vlc_decoder_device_Open open = func; vlc_decoder_device_Open open = func;
vlc_decoder_device *device = va_arg(ap, vlc_decoder_device *); vlc_decoder_device *device = va_arg(ap, vlc_decoder_device *);
@ -113,6 +113,7 @@ static int decoder_device_Open(void *func, va_list ap)
{ {
assert(device->type != VLC_DECODER_DEVICE_NONE); assert(device->type != VLC_DECODER_DEVICE_NONE);
} }
(void) forced;
return ret; return ret;
} }

3
src/input/demux.c

@ -162,7 +162,7 @@ static void demux_DestroyDemux(demux_t *demux)
vlc_stream_Delete(demux->s); vlc_stream_Delete(demux->s);
} }
static int demux_Probe(void *func, va_list ap) static int demux_Probe(void *func, bool forced, va_list ap)
{ {
int (*probe)(vlc_object_t *) = func; int (*probe)(vlc_object_t *) = func;
demux_t *demux = va_arg(ap, demux_t *); demux_t *demux = va_arg(ap, demux_t *);
@ -175,6 +175,7 @@ static int demux_Probe(void *func, va_list ap)
return VLC_EGENERIC; return VLC_EGENERIC;
} }
(void) forced;
return probe(VLC_OBJECT(demux)); return probe(VLC_OBJECT(demux));
} }

3
src/misc/messages.c

@ -392,12 +392,13 @@ struct vlc_logger_module {
void *opaque; void *opaque;
}; };
static int vlc_logger_load(void *func, va_list ap) static int vlc_logger_load(void *func, bool forced, va_list ap)
{ {
const struct vlc_logger_operations *(*activate)(vlc_object_t *, const struct vlc_logger_operations *(*activate)(vlc_object_t *,
void **) = func; void **) = func;
struct vlc_logger_module *module = va_arg(ap, struct vlc_logger_module *); struct vlc_logger_module *module = va_arg(ap, struct vlc_logger_module *);
(void) forced;
module->ops = activate(VLC_OBJECT(module), &module->opaque); module->ops = activate(VLC_OBJECT(module), &module->opaque);
return (module->ops != NULL) ? VLC_SUCCESS : VLC_EGENERIC; return (module->ops != NULL) ? VLC_SUCCESS : VLC_EGENERIC;
} }

19
src/modules/modules.c

@ -152,7 +152,7 @@ static bool module_match_name(const module_t *m, const char *name, size_t len)
} }
static int module_load (vlc_object_t *obj, module_t *m, static int module_load (vlc_object_t *obj, module_t *m,
vlc_activate_t init, va_list args) vlc_activate_t init, bool forced, va_list args)
{ {
int ret = VLC_SUCCESS; int ret = VLC_SUCCESS;
@ -164,7 +164,7 @@ static int module_load (vlc_object_t *obj, module_t *m,
va_list ap; va_list ap;
va_copy (ap, args); va_copy (ap, args);
ret = init (m->pf_activate, ap); ret = init(m->pf_activate, forced, ap);
va_end (ap); va_end (ap);
} }
@ -216,7 +216,6 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
} }
module_t *module = NULL; module_t *module = NULL;
const bool b_force_backup = obj->obj.force; /* FIXME: remove this */
va_list args; va_list args;
va_start(args, probe); va_start(args, probe);
@ -231,7 +230,7 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
if (!strcasecmp ("none", shortcut)) if (!strcasecmp ("none", shortcut))
goto done; goto done;
obj->obj.force = strict && strcasecmp ("any", shortcut); bool force = strict && strcasecmp ("any", shortcut);
for (ssize_t i = 0; i < total; i++) for (ssize_t i = 0; i < total; i++)
{ {
module_t *cand = mods[i]; module_t *cand = mods[i];
@ -241,7 +240,7 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
continue; continue;
mods[i] = NULL; // only try each module once at most... mods[i] = NULL; // only try each module once at most...
int ret = module_load (obj, cand, probe, args); int ret = module_load(obj, cand, probe, force, args);
switch (ret) switch (ret)
{ {
case VLC_SUCCESS: case VLC_SUCCESS:
@ -256,14 +255,13 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
/* None of the shortcuts matched, fall back to any module */ /* None of the shortcuts matched, fall back to any module */
if (!strict) if (!strict)
{ {
obj->obj.force = false;
for (ssize_t i = 0; i < total; i++) for (ssize_t i = 0; i < total; i++)
{ {
module_t *cand = mods[i]; module_t *cand = mods[i];
if (cand == NULL || module_get_score (cand) <= 0) if (cand == NULL || module_get_score (cand) <= 0)
continue; continue;
int ret = module_load (obj, cand, probe, args); int ret = module_load(obj, cand, probe, false, args);
switch (ret) switch (ret)
{ {
case VLC_SUCCESS: case VLC_SUCCESS:
@ -276,7 +274,6 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
} }
done: done:
va_end (args); va_end (args);
obj->obj.force = b_force_backup;
module_list_free (mods); module_list_free (mods);
if (module != NULL) if (module != NULL)
@ -312,11 +309,12 @@ void vlc_module_unload(vlc_object_t *obj, module_t *module,
} }
static int generic_start(void *func, va_list ap) static int generic_start(void *func, bool forced, va_list ap)
{ {
vlc_object_t *obj = va_arg(ap, vlc_object_t *); vlc_object_t *obj = va_arg(ap, vlc_object_t *);
int (*activate)(vlc_object_t *) = func; int (*activate)(vlc_object_t *) = func;
obj->obj.force = forced;
return activate(obj); return activate(obj);
} }
@ -332,12 +330,15 @@ static void generic_stop(void *func, va_list ap)
module_t *module_need(vlc_object_t *obj, const char *cap, const char *name, module_t *module_need(vlc_object_t *obj, const char *cap, const char *name,
bool strict) 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, cap, name, strict,
generic_start, obj); generic_start, obj);
if (module != NULL) { if (module != NULL) {
var_Create(obj, "module-name", VLC_VAR_STRING); var_Create(obj, "module-name", VLC_VAR_STRING);
var_SetString(obj, "module-name", module_get_object(module)); var_SetString(obj, "module-name", module_get_object(module));
} }
obj->obj.force = b_force_backup;
return module; return module;
} }

6
src/network/tls.c

@ -46,21 +46,23 @@
/*** TLS credentials ***/ /*** TLS credentials ***/
static int tls_server_load(void *func, va_list ap) static int tls_server_load(void *func, bool forced, va_list ap)
{ {
int (*activate)(vlc_tls_server_t *, const char *, const char *) = func; int (*activate)(vlc_tls_server_t *, const char *, const char *) = func;
vlc_tls_server_t *crd = va_arg(ap, vlc_tls_server_t *); vlc_tls_server_t *crd = va_arg(ap, vlc_tls_server_t *);
const char *cert = va_arg (ap, const char *); const char *cert = va_arg (ap, const char *);
const char *key = va_arg (ap, const char *); const char *key = va_arg (ap, const char *);
(void) forced;
return activate (crd, cert, key); return activate (crd, cert, key);
} }
static int tls_client_load(void *func, va_list ap) static int tls_client_load(void *func, bool forced, va_list ap)
{ {
int (*activate)(vlc_tls_client_t *) = func; int (*activate)(vlc_tls_client_t *) = func;
vlc_tls_client_t *crd = va_arg(ap, vlc_tls_client_t *); vlc_tls_client_t *crd = va_arg(ap, vlc_tls_client_t *);
(void) forced;
return activate (crd); return activate (crd);
} }

3
src/video_output/display.c

@ -65,7 +65,7 @@ static picture_t *VideoBufferNew(filter_t *filter)
* *
*****************************************************************************/ *****************************************************************************/
static int vout_display_start(void *func, va_list ap) static int vout_display_start(void *func, bool forced, va_list ap)
{ {
vout_display_open_cb activate = func; vout_display_open_cb activate = func;
vout_display_t *vd = va_arg(ap, vout_display_t *); vout_display_t *vd = va_arg(ap, vout_display_t *);
@ -77,6 +77,7 @@ static int vout_display_start(void *func, va_list ap)
video_format_Copy(fmtp, &vd->source); video_format_Copy(fmtp, &vd->source);
fmtp->i_sar_num = 0; fmtp->i_sar_num = 0;
fmtp->i_sar_den = 0; fmtp->i_sar_den = 0;
vd->obj.force = forced; /* TODO: pass to activate() instead? */
int ret = activate(vd, cfg, fmtp, context); int ret = activate(vd, cfg, fmtp, context);
if (ret != VLC_SUCCESS) if (ret != VLC_SUCCESS)

3
src/video_output/opengl.c

@ -38,13 +38,14 @@ struct vlc_gl_priv_t
vlc_atomic_rc_t rc; vlc_atomic_rc_t rc;
}; };
static int vlc_gl_start(void *func, va_list ap) static int vlc_gl_start(void *func, bool forced, va_list ap)
{ {
int (*activate)(vlc_gl_t *, unsigned, unsigned) = func; int (*activate)(vlc_gl_t *, unsigned, unsigned) = func;
vlc_gl_t *gl = va_arg(ap, vlc_gl_t *); vlc_gl_t *gl = va_arg(ap, vlc_gl_t *);
unsigned width = va_arg(ap, unsigned); unsigned width = va_arg(ap, unsigned);
unsigned height = va_arg(ap, unsigned); unsigned height = va_arg(ap, unsigned);
(void) forced;
return activate(gl, width, height); return activate(gl, width, height);
} }

3
src/video_output/window.c

@ -43,11 +43,12 @@ typedef struct
vlc_inhibit_t *inhibit; vlc_inhibit_t *inhibit;
} window_t; } window_t;
static int vout_window_start(void *func, va_list ap) static int vout_window_start(void *func, bool forced, va_list ap)
{ {
int (*activate)(vout_window_t *) = func; int (*activate)(vout_window_t *) = func;
vout_window_t *wnd = va_arg(ap, vout_window_t *); vout_window_t *wnd = va_arg(ap, vout_window_t *);
(void) forced;
return activate(wnd); return activate(wnd);
} }

Loading…
Cancel
Save