[vlc-devel] [PATCH V2 06/17] resource: always return a valid vout from HoldVout*()

Thomas Guillem thomas at gllm.fr
Tue Apr 16 16:25:16 CEST 2019


Small reminder: a "free vout" is just a stopped vout, not used by any video
decoders.
---
 src/input/resource.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/input/resource.c b/src/input/resource.c
index bc83f51e07..fc95a4cde6 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -398,9 +398,20 @@ static vout_thread_t *
 input_resource_HoldVoutLocked( input_resource_t *p_resource )
 {
     /* TODO FIXME: p_resource->pp_vout order is NOT stable */
-    vout_thread_t *p_vout = p_resource->i_vout > 0 ? p_resource->pp_vout[0] : NULL;
+    vout_thread_t *p_vout = p_resource->i_vout > 0 ? p_resource->pp_vout[0] : p_resource->p_vout_free;
     if( p_vout )
         vout_Hold(p_vout);
+    else
+    {
+        /* Create a vout_thread_t in a stopped state. This will allow clients to
+         * configure it (filters, crop...) before first playback. */
+        p_vout = vout_Create( p_resource->p_parent );
+        if( p_vout )
+        {
+            p_resource->p_vout_free = p_vout;
+            vout_Hold( p_vout );
+        }
+    }
 
     return p_vout;
 }
@@ -424,7 +435,20 @@ void input_resource_HoldVouts( input_resource_t *p_resource, vout_thread_t ***pp
     vlc_mutex_lock( &p_resource->lock );
 
     if( p_resource->i_vout <= 0 )
+    {
+        vout_thread_t *vout = input_resource_HoldVoutLocked( p_resource );
+        if (vout)
+        {
+            pp_vout = vlc_alloc( 1, sizeof(*pp_vout) );
+            if( pp_vout )
+            {
+                *ppp_vout = pp_vout;
+                *pi_vout = 1;
+                pp_vout[0] = vout;
+            }
+        }
         goto exit;
+    }
 
     pp_vout = vlc_alloc( p_resource->i_vout, sizeof(*pp_vout) );
     if( !pp_vout )
-- 
2.20.1



More information about the vlc-devel mailing list