[vlc-devel] [PATCH 14/31] decoder: create a decoder device only when it's requested by the decoder

Steve Lhomme robux4 at ycbcr.xyz
Mon Sep 23 17:01:19 CEST 2019


---
 src/input/decoder.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 455a12a9007..cbc5949f296 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -543,22 +543,30 @@ static int ModuleThread_HoldDecoderDevice( decoder_t *p_dec, vlc_decoder_device
         p_owner->p_vout = NULL; // the DecoderThread should not use the old vout anymore
         vlc_mutex_unlock( &p_owner->lock );
 
+        if ( pp_dec_dev ) *pp_dec_dev = NULL;
         enum vlc_vout_order order;
-        vlc_decoder_device *dec_dev = NULL;
         vout_configuration_t cfg = {
             .vout = p_vout, .clock = p_owner->p_clock, .fmt = &fmt,
             .mouse_event = MouseEvent, .mouse_opaque = p_dec
         };
-        p_vout = input_resource_GetVoutHoldDevice( p_owner->p_resource, &cfg, &order, &dec_dev );
+        p_vout = input_resource_GetVoutHoldDevice( p_owner->p_resource, &cfg, &order, pp_dec_dev );
 
         if (p_vout)
             decoder_Notify(p_owner, on_vout_added, p_vout, order);
 
         vlc_mutex_lock( &p_owner->lock );
         p_owner->p_vout = p_vout;
-        if ( p_owner->p_dec_dev != NULL )
-            vlc_decoder_device_Release( p_owner->p_dec_dev );
-        p_owner->p_dec_dev = dec_dev;
+        if ( pp_dec_dev )
+        {
+            if ( p_owner->p_dec_dev != NULL )
+                vlc_decoder_device_Release( p_owner->p_dec_dev );
+            if( p_vout == NULL && *pp_dec_dev != NULL )
+            {
+                vlc_decoder_device_Release( *pp_dec_dev );
+                *pp_dec_dev = NULL;
+            }
+            p_owner->p_dec_dev = *pp_dec_dev;
+        }
 
         DecoderUpdateFormatLocked( p_owner );
         p_owner->fmt.video.i_chroma = p_dec->fmt_out.i_codec;
@@ -582,6 +590,12 @@ static int ModuleThread_HoldDecoderDevice( decoder_t *p_dec, vlc_decoder_device
         DecoderUpdateFormatLocked( p_owner );
         vlc_mutex_unlock( &p_owner->lock );
     }
+    else if ( pp_dec_dev )
+    {
+        vlc_mutex_lock( &p_owner->lock );
+        *pp_dec_dev = p_owner->p_dec_dev;
+        vlc_mutex_unlock( &p_owner->lock );
+    }
     return 0;
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list