[vlc-commits] modules: pass force flag as parameter to activation callback

Rémi Denis-Courmont git at videolan.org
Mon Mar 4 21:05:38 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar  4 19:50:11 2019 +0200| [fc13953d90d99ada09c8557b3e32b0abe3b3f558] | committer: Rémi Denis-Courmont

modules: pass force flag as parameter to activation callback

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fc13953d90d99ada09c8557b3e32b0abe3b3f558
---

 include/vlc_modules.h           |  2 +-
 modules/audio_output/mmdevice.c |  3 ++-
 modules/audio_output/winstore.c |  1 +
 modules/codec/avcodec/va.c      |  3 ++-
 src/input/decoder_helpers.c     |  3 ++-
 src/input/demux.c               |  3 ++-
 src/misc/messages.c             |  3 ++-
 src/modules/modules.c           | 19 ++++++++++---------
 src/network/tls.c               |  6 ++++--
 src/video_output/display.c      |  3 ++-
 src/video_output/opengl.c       |  3 ++-
 src/video_output/window.c       |  3 ++-
 12 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/include/vlc_modules.h b/include/vlc_modules.h
index e63a0d48aa..b4d1b3200f 100644
--- a/include/vlc_modules.h
+++ b/include/vlc_modules.h
@@ -28,7 +28,7 @@
  * 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);
 
 /*****************************************************************************
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 3aded2b9d3..656a4a243d 100644
--- a/modules/audio_output/mmdevice.c
+++ b/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);
 }
 
-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_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 *);
     LPCGUID sid = var_InheritBool(s, "volume-save") ? &GUID_VLC_AUD_OUT : NULL;
 
+    (void) forced;
     *hr = start(s, fmt, sid);
     if (*hr == AUDCLNT_E_DEVICE_INVALIDATED)
         return VLC_ETIMEOUT;
diff --git a/modules/audio_output/winstore.c b/modules/audio_output/winstore.c
index d2afa78844..ea1688e90e 100644
--- a/modules/audio_output/winstore.c
+++ b/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 *);
     HRESULT *hr = va_arg(ap, HRESULT *);
 
+    (void) forced;
     *hr = start(s, fmt, &GUID_VLC_AUD_OUT);
     return SUCCEEDED(*hr) ? VLC_SUCCESS : VLC_EGENERIC;
 }
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index 040ba2293d..daad7c2dd6 100644
--- a/modules/codec/avcodec/va.c
+++ b/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 *);
     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,
                 const es_format_t *, void *) = func;
 
+    (void) forced;
     return open(va, ctx, pix_fmt, fmt, p_sys);
 }
 
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index 2dcdc1c82a..0153d33585 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -97,7 +97,7 @@ struct vlc_decoder_device_priv
     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 *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);
     }
+    (void) forced;
     return ret;
 }
 
diff --git a/src/input/demux.c b/src/input/demux.c
index 0d0777ba16..a5fd8e0890 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -162,7 +162,7 @@ static void demux_DestroyDemux(demux_t *demux)
     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;
     demux_t *demux = va_arg(ap, demux_t *);
@@ -175,6 +175,7 @@ static int demux_Probe(void *func, va_list ap)
         return VLC_EGENERIC;
     }
 
+    (void) forced;
     return probe(VLC_OBJECT(demux));
 }
 
diff --git a/src/misc/messages.c b/src/misc/messages.c
index acdb94af84..3de4002be2 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -392,12 +392,13 @@ struct vlc_logger_module {
     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 *,
                                                     void **) = func;
     struct vlc_logger_module *module = va_arg(ap, struct vlc_logger_module *);
 
+    (void) forced;
     module->ops = activate(VLC_OBJECT(module), &module->opaque);
     return (module->ops != NULL) ? VLC_SUCCESS : VLC_EGENERIC;
 }
diff --git a/src/modules/modules.c b/src/modules/modules.c
index 6d493e5e31..bb9922d0dd 100644
--- a/src/modules/modules.c
+++ b/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,
-                        vlc_activate_t init, va_list args)
+                        vlc_activate_t init, bool forced, va_list args)
 {
     int ret = VLC_SUCCESS;
 
@@ -164,7 +164,7 @@ static int module_load (vlc_object_t *obj, module_t *m,
         va_list ap;
 
         va_copy (ap, args);
-        ret = init (m->pf_activate, ap);
+        ret = init(m->pf_activate, forced, ap);
         va_end (ap);
     }
 
@@ -216,7 +216,6 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
     }
 
     module_t *module = NULL;
-    const bool b_force_backup = obj->obj.force; /* FIXME: remove this */
     va_list args;
 
     va_start(args, probe);
@@ -231,7 +230,7 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
         if (!strcasecmp ("none", shortcut))
             goto done;
 
-        obj->obj.force = strict && strcasecmp ("any", shortcut);
+        bool force = strict && strcasecmp ("any", shortcut);
         for (ssize_t i = 0; i < total; i++)
         {
             module_t *cand = mods[i];
@@ -241,7 +240,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, args);
+            int ret = module_load(obj, cand, probe, force, args);
             switch (ret)
             {
                 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 */
     if (!strict)
     {
-        obj->obj.force = false;
         for (ssize_t i = 0; i < total; i++)
         {
             module_t *cand = mods[i];
             if (cand == NULL || module_get_score (cand) <= 0)
                 continue;
 
-            int ret = module_load (obj, cand, probe, args);
+            int ret = module_load(obj, cand, probe, false, args);
             switch (ret)
             {
                 case VLC_SUCCESS:
@@ -276,7 +274,6 @@ module_t *vlc_module_load(vlc_object_t *obj, const char *capability,
     }
 done:
     va_end (args);
-    obj->obj.force = b_force_backup;
     module_list_free (mods);
 
     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 *);
     int (*activate)(vlc_object_t *) = func;
 
+    obj->obj.force = forced;
     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,
                       bool strict)
 {
+    const bool b_force_backup = obj->obj.force; /* FIXME: remove this */
     module_t *module = vlc_module_load(obj, cap, name, strict,
                                        generic_start, obj);
     if (module != NULL) {
         var_Create(obj, "module-name", VLC_VAR_STRING);
         var_SetString(obj, "module-name", module_get_object(module));
     }
+
+    obj->obj.force = b_force_backup;
     return module;
 }
 
diff --git a/src/network/tls.c b/src/network/tls.c
index 18ca6d8762..55b40f1423 100644
--- a/src/network/tls.c
+++ b/src/network/tls.c
@@ -46,21 +46,23 @@
 
 /*** 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;
     vlc_tls_server_t *crd = va_arg(ap, vlc_tls_server_t *);
     const char *cert = va_arg (ap, const char *);
     const char *key = va_arg (ap, const char *);
 
+    (void) forced;
     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;
     vlc_tls_client_t *crd = va_arg(ap, vlc_tls_client_t *);
 
+    (void) forced;
     return activate (crd);
 }
 
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 429d7285eb..ac5a81092d 100644
--- a/src/video_output/display.c
+++ b/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_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);
     fmtp->i_sar_num = 0;
     fmtp->i_sar_den = 0;
+    vd->obj.force = forced; /* TODO: pass to activate() instead? */
 
     int ret = activate(vd, cfg, fmtp, context);
     if (ret != VLC_SUCCESS)
diff --git a/src/video_output/opengl.c b/src/video_output/opengl.c
index fc521cb438..e4bf375b8f 100644
--- a/src/video_output/opengl.c
+++ b/src/video_output/opengl.c
@@ -38,13 +38,14 @@ struct vlc_gl_priv_t
     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;
     vlc_gl_t *gl = va_arg(ap, vlc_gl_t *);
     unsigned width = va_arg(ap, unsigned);
     unsigned height = va_arg(ap, unsigned);
 
+    (void) forced;
     return activate(gl, width, height);
 }
 
diff --git a/src/video_output/window.c b/src/video_output/window.c
index a111d7f4e7..20ddece927 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -43,11 +43,12 @@ typedef struct
     vlc_inhibit_t *inhibit;
 } 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;
     vout_window_t *wnd = va_arg(ap, vout_window_t *);
 
+    (void) forced;
     return activate(wnd);
 }
 



More information about the vlc-commits mailing list