[vlc-commits] core: make the decoder owners use the decoder_Destroy()

Steve Lhomme git at videolan.org
Mon Feb 18 17:02:48 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Feb 18 14:50:49 2019 +0100| [94a8dbbc2883fa18944ccd41e0b12753a5f7ddb0] | committer: Steve Lhomme

core: make the decoder owners use the decoder_Destroy()

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

 src/input/decoder.c      |  8 ++------
 src/misc/image.c         | 24 +++++-------------------
 test/src/input/decoder.c | 10 +++-------
 3 files changed, 10 insertions(+), 32 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 0a957317c7..2269985eff 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -2032,11 +2032,7 @@ static void DeleteDecoder( decoder_t * p_dec )
     if( p_owner->p_description )
         vlc_meta_Delete( p_owner->p_description );
 
-    if( p_owner->p_packetizer )
-    {
-        UnloadDecoder( p_owner->p_packetizer );
-        vlc_object_release( p_owner->p_packetizer );
-    }
+    decoder_Destroy( p_owner->p_packetizer );
 
     vlc_cond_destroy( &p_owner->wait_timed );
     vlc_cond_destroy( &p_owner->wait_fifo );
@@ -2045,7 +2041,7 @@ static void DeleteDecoder( decoder_t * p_dec )
     vlc_mutex_destroy( &p_owner->lock );
     vlc_mutex_destroy( &p_owner->mouse_lock );
 
-    vlc_object_release( p_dec );
+    decoder_Destroy( p_dec );
 }
 
 /* */
diff --git a/src/misc/image.c b/src/misc/image.c
index 7fb0c6baa5..52edd0ff67 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -73,7 +73,6 @@ static picture_t *ImageConvert( image_handler_t *, picture_t *,
                                 const video_format_t *, video_format_t * );
 
 static decoder_t *CreateDecoder( image_handler_t *, const es_format_t * );
-static void DeleteDecoder( decoder_t * );
 static encoder_t *CreateEncoder( vlc_object_t *, const video_format_t *,
                                  const video_format_t * );
 static void DeleteEncoder( encoder_t * );
@@ -117,7 +116,7 @@ void image_HandlerDelete( image_handler_t *p_image )
 {
     if( !p_image ) return;
 
-    if( p_image->p_dec ) DeleteDecoder( p_image->p_dec );
+    decoder_Destroy( p_image->p_dec );
     if( p_image->p_enc ) DeleteEncoder( p_image->p_enc );
     if( p_image->p_converter ) DeleteConverter( p_image->p_converter );
 
@@ -154,8 +153,8 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
     if( p_image->p_dec &&
         p_image->p_dec->fmt_in.i_codec != p_es_in->video.i_chroma )
     {
-        DeleteDecoder( p_image->p_dec );
-        p_image->p_dec = 0;
+        decoder_Destroy( p_image->p_dec );
+        p_image->p_dec = NULL;
     }
 
     /* Start a decoder */
@@ -169,7 +168,7 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
         }
         if( p_image->p_dec->fmt_out.i_cat != VIDEO_ES )
         {
-            DeleteDecoder( p_image->p_dec );
+            decoder_Destroy( p_image->p_dec );
             p_image->p_dec = NULL;
             block_Release(p_block);
             return NULL;
@@ -693,26 +692,13 @@ static decoder_t *CreateDecoder( image_handler_t *p_image, const es_format_t *fm
                  "VLC probably does not support this image format.",
                  (char*)&p_dec->fmt_in.i_codec );
 
-        DeleteDecoder( p_dec );
+        decoder_Destroy( p_dec );
         p_dec = NULL;
     }
 
     return p_dec;
 }
 
-static void DeleteDecoder( decoder_t * p_dec )
-{
-    if( p_dec->p_module ) module_unneed( p_dec, p_dec->p_module );
-
-    es_format_Clean( &p_dec->fmt_in );
-    es_format_Clean( &p_dec->fmt_out );
-
-    if( p_dec->p_description )
-        vlc_meta_Delete( p_dec->p_description );
-
-    vlc_object_release( p_dec );
-    p_dec = NULL;
-}
 
 static encoder_t *CreateEncoder( vlc_object_t *p_this, const video_format_t *fmt_in,
                                  const video_format_t *fmt_out )
diff --git a/test/src/input/decoder.c b/test/src/input/decoder.c
index 7fe2a1bf43..b140d89110 100644
--- a/test/src/input/decoder.c
+++ b/test/src/input/decoder.c
@@ -131,12 +131,9 @@ static void decoder_unload(decoder_t *decoder)
 void test_decoder_destroy(decoder_t *decoder)
 {
     struct decoder_owner *owner = dec_get_owner(decoder);
-    decoder_t *packetizer = owner->packetizer;
 
-    decoder_unload(packetizer);
-    decoder_unload(decoder);
-    vlc_object_release(packetizer);
-    vlc_object_release(decoder);
+    decoder_Destroy(owner->packetizer);
+    decoder_Destroy(decoder);
 }
 
 decoder_t *test_decoder_create(vlc_object_t *parent, const es_format_t *fmt)
@@ -205,8 +202,7 @@ decoder_t *test_decoder_create(vlc_object_t *parent, const es_format_t *fmt)
 
     if (decoder_load(decoder, false, &packetizer->fmt_out) != VLC_SUCCESS)
     {
-        decoder_unload(packetizer);
-        vlc_object_release(packetizer);
+        decoder_Destroy(packetizer);
         vlc_object_release(decoder);
         return NULL;
     }



More information about the vlc-commits mailing list