[vlc-devel] [PATCH 3/3] decoder: make sure each packetizer is loaded with a clean fmt_out
Steve Lhomme
robux4 at videolabs.io
Wed Jul 19 16:03:01 CEST 2017
and also doesn't reuse callbacks from a previous load
---
src/input/decoder.c | 31 +++++++++++++++++++++++++------
src/input/demux.c | 3 ---
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index c7ab1e3052..22fce39282 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -151,6 +151,24 @@ struct decoder_owner_sys_t
#define DECODER_SPU_VOUT_WAIT_DURATION ((int)(0.200*CLOCK_FREQ))
#define BLOCK_FLAG_CORE_PRIVATE_RELOADED (1 << BLOCK_FLAG_CORE_PRIVATE_SHIFT)
+static int PacketizerLoader(void *func, va_list ap)
+{
+ decoder_t *p_dec = va_arg(ap, decoder_t *);
+ int (*activate)(vlc_object_t *) = func;
+
+ int res = activate( VLC_OBJECT(p_dec) );
+ if ( res != VLC_SUCCESS )
+ {
+ p_dec->pf_decode = NULL;
+ p_dec->pf_packetize = NULL;
+ p_dec->pf_flush = NULL;
+ p_dec->pf_get_cc = NULL;
+
+ es_format_Change( &p_dec->fmt_out, p_dec->fmt_in.i_cat, 0 );
+ }
+ return res;
+}
+
module_t *packetizer_LoadModule( decoder_t *p_dec, const char *name )
{
switch (p_dec->fmt_in.i_cat)
@@ -163,8 +181,14 @@ module_t *packetizer_LoadModule( decoder_t *p_dec, const char *name )
return NULL; /* no packetizer possible */
}
+ p_dec->pf_decode = NULL;
+ p_dec->pf_packetize = NULL;
+ p_dec->pf_flush = NULL;
+ p_dec->pf_get_cc = NULL;
+
es_format_Init( &p_dec->fmt_out, p_dec->fmt_in.i_cat, 0 );
- module_t *p_module = module_need( p_dec, "packetizer", name, false );
+ module_t *p_module = vlc_module_load( p_dec, "packetizer", name,
+ false, PacketizerLoader, p_dec );
if ( p_module != NULL )
p_dec->fmt_out.b_packetized = true;
return p_module;
@@ -179,11 +203,6 @@ static int LoadDecoder( decoder_t *p_dec, bool b_packetizer,
p_dec->b_frame_drop_allowed = true;
p_dec->i_extra_picture_buffers = 0;
- p_dec->pf_decode = NULL;
- p_dec->pf_get_cc = NULL;
- p_dec->pf_packetize = NULL;
- p_dec->pf_flush = NULL;
-
es_format_Copy( &p_dec->fmt_in, p_fmt );
/* Find a suitable decoder/packetizer module */
diff --git a/src/input/demux.c b/src/input/demux.c
index f5102e42f5..ed229719ad 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -518,9 +518,6 @@ decoder_t *demux_PacketizerNew( demux_t *p_demux, es_format_t *p_fmt, const char
}
p_fmt->b_packetized = false;
- p_packetizer->pf_decode = NULL;
- p_packetizer->pf_packetize = NULL;
-
p_packetizer->fmt_in = *p_fmt;
p_packetizer->p_module = packetizer_LoadModule( p_packetizer, NULL );
--
2.12.1
More information about the vlc-devel
mailing list