[vlc-devel] [PATCH 4/9] modules:decoders: reset the fmt_out on error

Steve Lhomme robux4 at videolabs.io
Wed Jul 12 16:54:07 CEST 2017


Since the module loading doesn't go back to the decoder loading between
elements, it's up to the failing decoder to clean up the mess it did before
trying the next decoder.
---
 modules/codec/a52.c              | 1 +
 modules/codec/avcodec/video.c    | 1 +
 modules/codec/dca.c              | 1 +
 modules/codec/jpeg.c             | 2 +-
 modules/codec/mad.c              | 1 +
 modules/codec/mft.c              | 1 +
 modules/codec/omxil/mediacodec.c | 1 +
 modules/codec/spdif.c            | 3 +++
 modules/codec/wmafixed/wma.c     | 1 +
 9 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/modules/codec/a52.c b/modules/codec/a52.c
index af9f55996a..122e971276 100644
--- a/modules/codec/a52.c
+++ b/modules/codec/a52.c
@@ -364,6 +364,7 @@ static int Open( vlc_object_t *p_this )
 
     if( decoder_UpdateAudioFormat( p_dec ) )
     {
+        decoder_ResetOuput( p_dec );
         Close( p_this );
         return VLC_EGENERIC;
     }
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 506d15a209..7a82b9e001 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -594,6 +594,7 @@ int InitVideoDec( vlc_object_t *obj )
     /* ***** Open the codec ***** */
     if( OpenVideoCodec( p_dec ) < 0 )
     {
+        decoder_ResetOuput( p_dec );
         vlc_sem_destroy( &p_sys->sem_mt );
         free( p_sys );
         avcodec_free_context( &p_context );
diff --git a/modules/codec/dca.c b/modules/codec/dca.c
index bb8f96dbb2..160720403b 100644
--- a/modules/codec/dca.c
+++ b/modules/codec/dca.c
@@ -330,6 +330,7 @@ static int Open( vlc_object_t *p_this )
 
     if( decoder_UpdateAudioFormat( p_dec ) )
     {
+        decoder_ResetOuput( p_dec );
         Close( p_this );
         return VLC_EGENERIC;
     }
diff --git a/modules/codec/jpeg.c b/modules/codec/jpeg.c
index c3119db968..d62c35c0a1 100644
--- a/modules/codec/jpeg.c
+++ b/modules/codec/jpeg.c
@@ -577,7 +577,7 @@ static int DecodeBlock(decoder_t *p_dec, block_t *p_block)
     return VLCDEC_SUCCESS;
 
 error:
-
+    decoder_ResetOuput( p_dec );
     jpeg_destroy_decompress(&p_sys->p_jpeg);
     free(p_row_pointers);
 
diff --git a/modules/codec/mad.c b/modules/codec/mad.c
index 047243dd5f..21dc9b75f7 100644
--- a/modules/codec/mad.c
+++ b/modules/codec/mad.c
@@ -275,6 +275,7 @@ static int Open( vlc_object_t *p_this )
 
     if( decoder_UpdateAudioFormat( p_dec ) )
     {
+        decoder_ResetOuput( p_dec );
         Close( p_this );
         return VLC_EGENERIC;
     }
diff --git a/modules/codec/mft.c b/modules/codec/mft.c
index c0412cf38e..4ac7bae7eb 100644
--- a/modules/codec/mft.c
+++ b/modules/codec/mft.c
@@ -1145,6 +1145,7 @@ static int Open(vlc_object_t *p_this)
     return VLC_SUCCESS;
 
 error:
+    decoder_ResetOuput( p_dec );
     Close(p_this);
     return VLC_EGENERIC;
 }
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 3373a7293e..405818cee6 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -733,6 +733,7 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
     return VLC_SUCCESS;
 
 bailout:
+    decoder_ResetOuput( p_dec );
     CleanDecoder(p_dec);
     return VLC_EGENERIC;
 }
diff --git a/modules/codec/spdif.c b/modules/codec/spdif.c
index f1ebcbdfe6..15203d9d17 100644
--- a/modules/codec/spdif.c
+++ b/modules/codec/spdif.c
@@ -78,7 +78,10 @@ OpenDecoder(vlc_object_t *p_this)
     p_dec->fmt_out.audio.i_format = p_dec->fmt_out.i_codec;
 
     if (decoder_UpdateAudioFormat(p_dec))
+    {
+        decoder_ResetOuput( p_dec );
         return VLC_EGENERIC;
+    }
 
     p_dec->pf_decode = DecodeBlock;
     p_dec->pf_flush  = NULL;
diff --git a/modules/codec/wmafixed/wma.c b/modules/codec/wmafixed/wma.c
index 1d65b89174..dd05f51594 100644
--- a/modules/codec/wmafixed/wma.c
+++ b/modules/codec/wmafixed/wma.c
@@ -180,6 +180,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     if( wma_decode_init(&p_sys->wmadec, &wfx ) < 0 )
     {
         msg_Err( p_dec, "codec init failed" );
+        decoder_ResetOuput( p_dec );
         free( p_sys );
         return VLC_EGENERIC;
     }
-- 
2.12.1



More information about the vlc-devel mailing list