[vlc-devel] [PATCH 17/31] input: resource: split input_resource_GetVout()

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


So we can create the display separately, when the video context will be created.
---
 src/input/decoder.c  | 23 ++++++++++++++++-------
 src/input/resource.c | 20 ++++++++++++++------
 src/input/resource.h |  1 +
 3 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index d19d75f5e4..09c2e498a5 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -546,13 +546,22 @@ static int vout_update_format( decoder_t *p_dec )
         }
         enum vlc_vout_order order;
         vlc_decoder_device *dec_dev;
-        p_vout = input_resource_GetVout( p_owner->p_resource,
-            &(vout_configuration_t) {
-                .vout = p_vout, .clock = p_owner->p_clock, .fmt = &fmt,
-                .dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1,
-                .mouse_event = MouseEvent, .mouse_opaque = p_dec,
-                .dec_devive = p_dec_dev,
-            }, &order, &dec_dev );
+        vout_configuration_t cfg = {
+            .vout = p_vout, .clock = p_owner->p_clock, .fmt = &fmt,
+            .dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1,
+            .mouse_event = MouseEvent, .mouse_opaque = p_dec,
+            .dec_devive = p_dec_dev,
+        };
+        p_vout = input_resource_GetVout( p_owner->p_resource, &cfg, &order, &dec_dev );
+        if (p_vout)
+        {
+            cfg.vout = p_vout;
+            if (input_resource_GetDisplay( p_owner->p_resource, &cfg) != 0)
+            {
+                p_vout = NULL;
+            }
+        }
+
         if (p_vout)
             decoder_Notify(p_owner, on_vout_added, p_vout, order);
 
diff --git a/src/input/resource.c b/src/input/resource.c
index 34b5e23f54..19b5928bc3 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -432,15 +432,25 @@ vout_thread_t *input_resource_GetVout(input_resource_t *p_resource,
         return NULL;
     }
 
+    vout = cfg->vout;
+
+out:
+    vlc_mutex_unlock( &p_resource->lock );
+    return vout;
+}
+
+int input_resource_GetDisplay(input_resource_t *p_resource,
+                              const vout_configuration_t *cfg)
+{
+    vlc_mutex_lock( &p_resource->lock );
     int res = vout_RequestDisplay(cfg, p_resource->p_input);
     if (res != 0) {
         input_resource_PutVoutLocked(p_resource, cfg->vout, false);
         vlc_mutex_unlock(&p_resource->lock);
-        return NULL;
+        return res;
     }
 
-    vout = cfg->vout;
-    DisplayVoutTitle(p_resource, vout);
+    DisplayVoutTitle(p_resource, cfg->vout);
 
     /* Send original viewpoint to the input in order to update other ESes */
     if (p_resource->p_input != NULL)
@@ -449,10 +459,8 @@ vout_thread_t *input_resource_GetVout(input_resource_t *p_resource,
         input_ControlPush(p_resource->p_input, INPUT_CONTROL_SET_INITIAL_VIEWPOINT,
                           &param);
     }
-
-out:
     vlc_mutex_unlock( &p_resource->lock );
-    return vout;
+    return 0;
 }
 
 vout_thread_t *input_resource_HoldVout( input_resource_t *p_resource )
diff --git a/src/input/resource.h b/src/input/resource.h
index 468ae196fb..f4031dd6dc 100644
--- a/src/input/resource.h
+++ b/src/input/resource.h
@@ -41,6 +41,7 @@ vout_thread_t *input_resource_GetVout(input_resource_t *,
                                       const vout_configuration_t *,
                                       enum vlc_vout_order *order,
                                       vlc_decoder_device **);
+int input_resource_GetDisplay(input_resource_t *, const vout_configuration_t *);
 void input_resource_PutVout(input_resource_t *, vout_thread_t *);
 
 /**
-- 
2.17.1



More information about the vlc-devel mailing list