[vlc-devel] [PATCH 20/31] decoder: keep the decoder device in the decoder

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 5 16:19:59 CEST 2019


So that all decoders can have access to it and create their own video context
---
 include/vlc_codec.h |  3 +++
 src/input/decoder.c | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 95dfbc8ff6..0f7bbf9684 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -197,6 +197,9 @@ struct decoder_t
 
     /* Private structure for the owner of the decoder */
     const struct decoder_owner_callbacks *cbs;
+
+    /* use to create the video context */
+    vlc_decoder_device *init_device;
 };
 
 /* struct for packetizer get_cc polling/decoder queue_cc
diff --git a/src/input/decoder.c b/src/input/decoder.c
index d3d8ea4108..996deb58df 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -527,6 +527,11 @@ static int vout_get_device( decoder_t *p_dec )
         p_dec_dev = p_owner->p_dec_dev;
         p_owner->p_vout = NULL;
         p_owner->p_dec_dev = NULL;
+        if ( p_dec->init_device != NULL )
+        {
+            vlc_decoder_device_Release( p_dec->init_device );
+            p_dec->init_device = NULL;
+        }
         vlc_mutex_unlock( &p_owner->lock );
 
         enum vlc_vout_order order;
@@ -542,6 +547,8 @@ static int vout_get_device( decoder_t *p_dec )
         p_owner->p_vout = p_vout;
         p_owner->p_dec_dev = dec_dev;
 
+        p_dec->init_device = dec_dev;
+
         DecoderUpdateFormatLocked( p_dec );
         p_owner->fmt.video.i_chroma = p_dec->fmt_out.i_codec;
         vlc_mutex_unlock( &p_owner->lock );
@@ -549,6 +556,11 @@ static int vout_get_device( decoder_t *p_dec )
         if( p_vout == NULL )
         {
             msg_Err( p_dec, "failed to create video output" );
+            if ( p_dec->init_device != NULL )
+            {
+                vlc_decoder_device_Release( p_dec->init_device );
+                p_dec->init_device = NULL;
+            }
             return -1;
         }
 
-- 
2.17.1



More information about the vlc-devel mailing list