[vlc-commits] modules: add/use module_need_var()

Rémi Denis-Courmont git at videolan.org
Tue Jan 30 20:45:14 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jan 30 21:15:52 2018 +0200| [008d355b97afdd4cee02bea837b67c3a0da43daa] | committer: Rémi Denis-Courmont

modules: add/use module_need_var()

...to get the module name or module name list from an object variable.

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

 include/vlc_modules.h                     | 13 +++++++++++++
 modules/stream_out/mosaic_bridge.c        |  2 +-
 modules/stream_out/transcode/audio.c      |  2 +-
 modules/stream_out/transcode/spu.c        |  2 +-
 modules/stream_out/transcode/video.c      |  2 +-
 modules/video_output/opengl/vout_helper.c |  2 +-
 src/audio_output/output.c                 |  2 +-
 src/input/decoder.c                       |  6 +++---
 src/input/vlm.c                           |  2 +-
 src/misc/image.c                          |  2 +-
 src/video_output/vout_subpictures.c       |  2 +-
 11 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/include/vlc_modules.h b/include/vlc_modules.h
index c2d3c26d20..c3cbf1c87d 100644
--- a/include/vlc_modules.h
+++ b/include/vlc_modules.h
@@ -46,6 +46,19 @@ VLC_API void vlc_module_unload( vlc_object_t *obj, module_t *,
 
 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_USED
+static inline module_t *module_need_var(vlc_object_t *obj, const char *cap,
+                                        const char *varname)
+{
+    char *list = var_InheritString(obj, varname);
+    module_t *m = module_need(obj, cap, list, false);
+
+    free(list);
+    return m;
+}
+#define module_need_var(a,b,c) module_need_var(VLC_OBJECT(a),b,c)
+
 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/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c
index e0f9ff4c8f..e2b98ead91 100644
--- a/modules/stream_out/mosaic_bridge.c
+++ b/modules/stream_out/mosaic_bridge.c
@@ -307,7 +307,7 @@ static sout_stream_id_sys_t * Add( sout_stream_t *p_stream, const es_format_t *p
     //p_sys->p_decoder->p_cfg = p_sys->p_video_cfg;
 
     p_sys->p_decoder->p_module =
-        module_need( p_sys->p_decoder, "video decoder", "$codec", false );
+        module_need_var( p_sys->p_decoder, "video decoder", "codec" );
 
     if( !p_sys->p_decoder->p_module )
     {
diff --git a/modules/stream_out/transcode/audio.c b/modules/stream_out/transcode/audio.c
index d2c9f5f40a..d3f5bf7cf3 100644
--- a/modules/stream_out/transcode/audio.c
+++ b/modules/stream_out/transcode/audio.c
@@ -194,7 +194,7 @@ static int transcode_audio_new( sout_stream_t *p_stream,
     id->p_decoder->pf_aout_format_update = audio_update_format;
     /* id->p_decoder->p_cfg = p_sys->p_audio_cfg; */
     id->p_decoder->p_module =
-        module_need( id->p_decoder, "audio decoder", "$codec", false );
+        module_need_var( id->p_decoder, "audio decoder", "codec" );
     if( !id->p_decoder->p_module )
     {
         msg_Err( p_stream, "cannot find audio decoder" );
diff --git a/modules/stream_out/transcode/spu.c b/modules/stream_out/transcode/spu.c
index 51f86b4fa0..7ee05e8e3e 100644
--- a/modules/stream_out/transcode/spu.c
+++ b/modules/stream_out/transcode/spu.c
@@ -83,7 +83,7 @@ static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_sys_t *id
     /* id->p_decoder->p_cfg = p_sys->p_spu_cfg; */
 
     id->p_decoder->p_module =
-        module_need( id->p_decoder, "spu decoder", "$codec", false );
+        module_need_var( id->p_decoder, "spu decoder", "codec" );
 
     if( !id->p_decoder->p_module )
     {
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 323893f217..1a641bb929 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -190,7 +190,7 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_sys_t *i
     id->p_decoder->p_owner = (decoder_owner_sys_t*) p_stream;
 
     id->p_decoder->p_module =
-        module_need( id->p_decoder, "video decoder", "$codec", false );
+        module_need_var( id->p_decoder, "video decoder", "codec" );
 
     if( !id->p_decoder->p_module )
     {
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index fe98279f5d..04294af30e 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -654,7 +654,7 @@ opengl_init_program(vout_display_opengl_t *vgl, struct prgm *prgm,
         if (desc->plane_count == 0)
         {
             /* Opaque chroma: load a module to handle it */
-            tc->p_module = module_need(tc, "glconv", "$glconv", true);
+            tc->p_module = module_need_var(tc, "glconv", "glconv");
         }
 
         if (tc->p_module != NULL)
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 0549de044d..caf398ea18 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -241,7 +241,7 @@ audio_output_t *aout_New (vlc_object_t *parent)
     aout->volume_set = NULL;
     aout->mute_set = NULL;
     aout->device_select = NULL;
-    owner->module = module_need (aout, "audio output", "$aout", false);
+    owner->module = module_need_var(aout, "audio output", "aout");
     if (owner->module == NULL)
     {
         msg_Err (aout, "no suitable audio output module");
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 0d3df97934..170d355f2e 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -175,11 +175,11 @@ static int LoadDecoder( decoder_t *p_dec, bool b_packetizer,
             [AUDIO_ES] = "audio decoder",
             [SPU_ES] = "spu decoder",
         };
-        p_dec->p_module = module_need( p_dec, caps[p_dec->fmt_in.i_cat],
-                                       "$codec", false );
+        p_dec->p_module = module_need_var( p_dec, caps[p_dec->fmt_in.i_cat],
+                                           "codec" );
     }
     else
-        p_dec->p_module = module_need( p_dec, "packetizer", "$packetizer", false );
+        p_dec->p_module = module_need_var( p_dec, "packetizer", "packetizer" );
 
     if( !p_dec->p_module )
     {
diff --git a/src/input/vlm.c b/src/input/vlm.c
index 99e0e5862b..d8cfa46b52 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -736,7 +736,7 @@ static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id
     {
         p_vlm->p_vod = vlc_custom_create( VLC_OBJECT(p_vlm), sizeof( vod_t ),
                                           "vod server" );
-        p_vlm->p_vod->p_module = module_need( p_vlm->p_vod, "vod server", "$vod-server", false );
+        p_vlm->p_vod->p_module = module_need_var( p_vlm->p_vod, "vod server", "vod-server" );
         if( !p_vlm->p_vod->p_module )
         {
             msg_Err( p_vlm, "cannot find vod server" );
diff --git a/src/misc/image.c b/src/misc/image.c
index 6ea0e11bbd..395b9d39cb 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -679,7 +679,7 @@ static decoder_t *CreateDecoder( vlc_object_t *p_this, const video_format_t *fmt
     p_dec->pf_vout_buffer_new = video_new_buffer;
 
     /* Find a suitable decoder module */
-    p_dec->p_module = module_need( p_dec, "video decoder", "$codec", false );
+    p_dec->p_module = module_need_var( p_dec, "video decoder", "codec" );
     if( !p_dec->p_module )
     {
         msg_Err( p_dec, "no suitable decoder module for fourcc `%4.4s'. "
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 0a1b9e6808..1d654e4d4f 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -205,7 +205,7 @@ static filter_t *SpuRenderCreateAndLoadText(spu_t *spu)
 
     text->pf_get_attachments = spu_get_attachments;
 
-    text->p_module = module_need(text, "text renderer", "$text-renderer", false);
+    text->p_module = module_need_var(text, "text renderer", "text-renderer");
 
     /* Create a few variables used for enhanced text rendering */
     var_Create(text, "spu-elapsed",   VLC_VAR_INTEGER);



More information about the vlc-commits mailing list