[vlc-devel] [PATCH 11/11] modules:stream_out: use the new decoder_LoadModule()

Steve Lhomme robux4 at videolabs.io
Thu Jul 13 15:44:44 CEST 2017


---
 modules/stream_out/mosaic_bridge.c   | 18 +++++++++++++-----
 modules/stream_out/transcode/audio.c | 18 +++++++++++++-----
 modules/stream_out/transcode/spu.c   |  3 +--
 modules/stream_out/transcode/video.c | 20 ++++++++++++++------
 4 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c
index 5d61f7f497..a91ca0645b 100644
--- a/modules/stream_out/mosaic_bridge.c
+++ b/modules/stream_out/mosaic_bridge.c
@@ -270,6 +270,18 @@ static void Close( vlc_object_t * p_this )
     free( p_sys );
 }
 
+static int DecoderStart(void *func, va_list ap)
+{
+    decoder_t *p_dec = va_arg(ap, decoder_t *);
+    int (*activate)(vlc_object_t *) = func;
+
+    p_dec->fmt_out = p_dec->fmt_in;
+    p_dec->fmt_out.i_extra = 0;
+    p_dec->fmt_out.p_extra = 0;
+
+    return activate( VLC_OBJECT(p_dec) );
+}
+
 static sout_stream_id_sys_t * Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
@@ -288,9 +300,6 @@ static sout_stream_id_sys_t * Add( sout_stream_t *p_stream, const es_format_t *p
     p_sys->p_decoder->p_module = NULL;
     p_sys->p_decoder->fmt_in = *p_fmt;
     p_sys->p_decoder->b_frame_drop_allowed = true;
-    p_sys->p_decoder->fmt_out = p_sys->p_decoder->fmt_in;
-    p_sys->p_decoder->fmt_out.i_extra = 0;
-    p_sys->p_decoder->fmt_out.p_extra = 0;
     p_sys->p_decoder->pf_decode = NULL;
     p_sys->p_decoder->pf_queue_video = decoder_queue_video;
     p_sys->p_decoder->p_queue_ctx = p_stream;
@@ -306,8 +315,7 @@ static sout_stream_id_sys_t * Add( sout_stream_t *p_stream, const es_format_t *p
     p_sys->p_decoder->p_owner->video = p_fmt->video;
     //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 );
+    p_sys->p_decoder->p_module = decoder_LoadModule( p_sys->p_decoder, DecoderStart );
 
     if( !p_sys->p_decoder->p_module )
     {
diff --git a/modules/stream_out/transcode/audio.c b/modules/stream_out/transcode/audio.c
index bd688fc5e9..efb85e8c0b 100644
--- a/modules/stream_out/transcode/audio.c
+++ b/modules/stream_out/transcode/audio.c
@@ -155,6 +155,18 @@ static block_t *transcode_dequeue_all_audios( sout_stream_id_sys_t *id )
     return p_audio_bufs;
 }
 
+static int DecoderStart(void *func, va_list ap)
+{
+    decoder_t *p_dec = va_arg(ap, decoder_t *);
+    int (*activate)(vlc_object_t *) = func;
+
+    p_dec->fmt_out = p_dec->fmt_in;
+    p_dec->fmt_out.i_extra = 0;
+    p_dec->fmt_out.p_extra = 0;
+
+    return activate( VLC_OBJECT(p_dec) );
+}
+
 static int transcode_audio_new( sout_stream_t *p_stream,
                                 sout_stream_id_sys_t *id )
 {
@@ -166,16 +178,12 @@ static int transcode_audio_new( sout_stream_t *p_stream,
      */
 
     /* Initialization of decoder structures */
-    id->p_decoder->fmt_out = id->p_decoder->fmt_in;
-    id->p_decoder->fmt_out.i_extra = 0;
-    id->p_decoder->fmt_out.p_extra = 0;
     id->p_decoder->pf_decode = NULL;
     id->p_decoder->pf_queue_audio = decoder_queue_audio;
     id->p_decoder->p_queue_ctx = id;
     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 );
+    id->p_decoder->p_module = decoder_LoadModule( id->p_decoder, DecoderStart );
     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 fef25f13ac..8df0983b08 100644
--- a/modules/stream_out/transcode/spu.c
+++ b/modules/stream_out/transcode/spu.c
@@ -83,8 +83,7 @@ static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_sys_t *id
     id->p_decoder->p_owner = (decoder_owner_sys_t *)p_stream;
     /* id->p_decoder->p_cfg = p_sys->p_spu_cfg; */
 
-    id->p_decoder->p_module =
-        module_need( id->p_decoder, "spu decoder", "$codec", false );
+    id->p_decoder->p_module = decoder_LoadModule( id->p_decoder, NULL );
 
     if( !id->p_decoder->p_module )
     {
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index fe2e0b27f9..130c99f140 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -170,6 +170,19 @@ static picture_t *transcode_dequeue_all_pics( sout_stream_id_sys_t *id )
     return p_pics;
 }
 
+static int DecoderStart(void *func, va_list ap)
+{
+    decoder_t *p_dec = va_arg(ap, decoder_t *);
+    int (*activate)(vlc_object_t *) = func;
+
+    p_dec->fmt_out = p_dec->fmt_in;
+    p_dec->fmt_out.i_extra = 0;
+    p_dec->fmt_out.p_extra = 0;
+    p_dec->fmt_out.psz_language = NULL;
+
+    return activate( VLC_OBJECT(p_dec) );
+}
+
 static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
@@ -177,10 +190,6 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_sys_t *i
     /* Open decoder
      * Initialization of decoder structures
      */
-    id->p_decoder->fmt_out = id->p_decoder->fmt_in;
-    id->p_decoder->fmt_out.i_extra = 0;
-    id->p_decoder->fmt_out.p_extra = NULL;
-    id->p_decoder->fmt_out.psz_language = NULL;
     id->p_decoder->pf_decode = NULL;
     id->p_decoder->pf_queue_video = decoder_queue_video;
     id->p_decoder->p_queue_ctx = id;
@@ -195,8 +204,7 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_sys_t *i
     id->p_decoder->p_owner->p_stream = p_stream;
     id->p_decoder->p_owner->id = id;
 
-    id->p_decoder->p_module =
-        module_need( id->p_decoder, "video decoder", "$codec", false );
+    id->p_decoder->p_module = decoder_LoadModule( id->p_decoder, DecoderStart );
 
     if( !id->p_decoder->p_module )
     {
-- 
2.12.1



More information about the vlc-devel mailing list