[vlc-commits] transcode: spu: refactor spu open/close
Francois Cartegnie
git at videolan.org
Mon Jul 9 16:15:48 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul 2 15:16:34 2018 +0200| [3480f1f83da95464f5568c83c67e487d0aba3976] | committer: Francois Cartegnie
transcode: spu: refactor spu open/close
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3480f1f83da95464f5568c83c67e487d0aba3976
---
modules/stream_out/transcode/spu.c | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/modules/stream_out/transcode/spu.c b/modules/stream_out/transcode/spu.c
index 7cecdf9d82..29d42159e8 100644
--- a/modules/stream_out/transcode/spu.c
+++ b/modules/stream_out/transcode/spu.c
@@ -73,6 +73,25 @@ static subpicture_t *transcode_dequeue_all_subs( sout_stream_id_sys_t *id )
return p_subpics;
}
+static void transcode_spu_encoder_close( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
+{
+ VLC_UNUSED(p_stream);
+ if( id->p_encoder->p_module )
+ module_unneed( id->p_encoder, id->p_encoder->p_module );
+}
+
+static int transcode_spu_encoder_open( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
+{
+ sout_stream_sys_t *p_sys = p_stream->p_sys;
+
+ id->p_encoder->p_cfg = p_sys->p_spu_cfg;
+
+ id->p_encoder->p_module = module_need( id->p_encoder, "encoder",
+ p_sys->psz_senc, true );
+
+ return ( id->p_encoder->p_module ) ? VLC_SUCCESS: VLC_EGENERIC;
+}
+
static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
@@ -110,14 +129,11 @@ static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_sys_t *id
es_format_Init( &id->p_encoder->fmt_in, id->p_decoder->fmt_in.i_cat,
id->p_decoder->fmt_in.i_codec );
- id->p_encoder->p_cfg = p_sys->p_spu_cfg;
-
- id->p_encoder->p_module =
- module_need( id->p_encoder, "encoder", p_sys->psz_senc, true );
-
- if( !id->p_encoder->p_module )
+ if( transcode_spu_encoder_open( p_stream, id ) )
{
+ es_format_Clean( &id->p_encoder->fmt_in );
module_unneed( id->p_decoder, id->p_decoder->p_module );
+ id->p_decoder->p_module = NULL;
msg_Err( p_stream, "cannot find spu encoder (%s)", p_sys->psz_senc );
return VLC_EGENERIC;
}
@@ -139,8 +155,7 @@ void transcode_spu_close( sout_stream_t *p_stream, sout_stream_id_sys_t *id)
vlc_meta_Delete( id->p_decoder->p_description );
/* Close encoder */
- if( id->p_encoder->p_module )
- module_unneed( id->p_encoder, id->p_encoder->p_module );
+ transcode_spu_encoder_close( p_stream, id );
if( p_sys->p_spu )
{
More information about the vlc-commits
mailing list