[vlc-devel] [PATCH 19/38] decoder: allow multiple calls to HoldDecoderDevice before calling UpdateFormat

Steve Lhomme robux4 at ycbcr.xyz
Tue Oct 1 13:12:42 CEST 2019


This is how the VA's will be probed when multiple outputs are possible.
---
 src/input/decoder.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index c30f14c3aa8..9ed967cdb5d 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -460,17 +460,19 @@ static void FixDisplayFormat(decoder_t *p_dec, video_format_t *fmt)
     video_format_AdjustColorSpace( fmt );
 }
 
+static int CreateVoutIfNeeded(struct decoder_owner *, vout_thread_t **, vlc_decoder_device **);
+
+
 static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec )
 {
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
 
-    vlc_mutex_lock( &p_owner->lock );
-
-    vout_thread_t *p_vout = p_owner->p_vout;
-    vlc_mutex_unlock( &p_owner->lock );
+    vout_thread_t *p_vout = NULL;
+    int created_vout = CreateVoutIfNeeded(p_owner, &p_vout, NULL);
+    if (created_vout == -1)
+        return -1; // error
 
-    if (!p_vout)
-        return -1;
+    // configure the new vout
 
     video_format_t fmt;
     FixDisplayFormat( p_dec, &fmt );
@@ -504,7 +506,7 @@ static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec )
     return input_resource_GetDisplay( p_owner->p_resource, p_owner->p_dec_dev, &cfg);
 }
 
-static int CreateVoutIfNeeded(struct decoder_owner *p_owner, vlc_decoder_device **pp_dec_dev)
+static int CreateVoutIfNeeded(struct decoder_owner *p_owner, vout_thread_t **pp_vout, vlc_decoder_device **pp_dec_dev)
 {
     decoder_t *p_dec = &p_owner->dec;
     bool need_vout = false;
@@ -551,7 +553,15 @@ static int CreateVoutIfNeeded(struct decoder_owner *p_owner, vlc_decoder_device
     }
 
     if( !need_vout )
+    {
+        if (pp_vout)
+        {
+            vlc_mutex_lock( &p_owner->lock );
+            *pp_vout = p_owner->p_vout;
+            vlc_mutex_unlock( &p_owner->lock );
+        }
         return 0; // vout unchanged
+    }
 
     if( !p_dec->fmt_out.video.i_width ||
         !p_dec->fmt_out.video.i_height ||
@@ -582,6 +592,9 @@ static int CreateVoutIfNeeded(struct decoder_owner *p_owner, vlc_decoder_device
     if (p_vout)
         decoder_Notify(p_owner, on_vout_added, p_vout, order);
 
+    if (pp_vout)
+        *pp_vout = p_vout;
+
     vlc_mutex_lock( &p_owner->lock );
     p_owner->p_vout = p_vout;
     if ( pp_dec_dev )
@@ -618,7 +631,7 @@ static vlc_decoder_device * ModuleThread_GetDecoderDevice( decoder_t *p_dec )
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
 
     vlc_decoder_device *dec_device = NULL;
-    int created_vout = CreateVoutIfNeeded(p_owner, &dec_device);
+    int created_vout = CreateVoutIfNeeded(p_owner, NULL, &dec_device);
     if (created_vout == -1)
     {
         if ( dec_device )
-- 
2.17.1



More information about the vlc-devel mailing list