[vlc-devel] [PATCHv3 05/12] input: request a vlc_renderer when needed

Thomas Guillem thomas at gllm.fr
Tue Mar 29 15:06:36 CEST 2016


---
 src/input/input.c          | 33 +++++++++++++++++++++++++++++----
 src/input/input_internal.h |  1 +
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 4a0caf4..1ae06b3 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -324,6 +324,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     TAB_INIT( p_input->p->i_attachment, p_input->p->attachment );
     p_input->p->attachment_demux = NULL;
     p_input->p->p_sout   = NULL;
+    p_input->p->p_renderer = NULL;
     p_input->p->b_out_pace_control = false;
 
     vlc_gc_incref( p_item ); /* Released in Destructor() */
@@ -814,18 +815,37 @@ static int InitSout( input_thread_t * p_input )
 {
     if( p_input->b_preparsing )
         return VLC_SUCCESS;
+    char *psz;
+    const bool b_is_cmd = !strncasecmp( p_input->p->p_item->psz_uri, "vlc:", 4 );
+
+    if( !b_is_cmd && ( psz = var_InheritString( p_input, "renderer" ) ) )
+    {
+        p_input->p->p_renderer =
+            input_resource_RequestRenderer( p_input->p->p_resource, NULL, psz );
+        free( psz );
+        if( !p_input->p->p_renderer )
+        {
+            input_ChangeState( p_input, ERROR_S );
+            msg_Err( p_input, "cannot start renderer instance, " \
+                              "aborting" );
+            return VLC_EGENERIC;
+        }
+    }
+    else
+    {
+        input_resource_RequestRenderer( p_input->p->p_resource, NULL, NULL );
+    }
 
     /* Find a usable sout and attach it to p_input */
-    char *psz = var_GetNonEmptyString( p_input, "sout" );
-    if( psz && strncasecmp( p_input->p->p_item->psz_uri, "vlc:", 4 ) )
+    if( !b_is_cmd && ( psz = var_GetNonEmptyString( p_input, "sout" ) ) )
     {
         p_input->p->p_sout  = input_resource_RequestSout( p_input->p->p_resource, NULL, psz );
+        free( psz );
         if( !p_input->p->p_sout )
         {
             input_ChangeState( p_input, ERROR_S );
             msg_Err( p_input, "cannot start stream output instance, " \
                               "aborting" );
-            free( psz );
             return VLC_EGENERIC;
         }
         if( libvlc_stats( p_input ) )
@@ -839,7 +859,6 @@ static int InitSout( input_thread_t * p_input )
     {
         input_resource_RequestSout( p_input->p->p_resource, NULL, NULL );
     }
-    free( psz );
 
     return VLC_SUCCESS;
 }
@@ -1249,6 +1268,9 @@ error:
         if( p_input->p->p_sout )
             input_resource_RequestSout( p_input->p->p_resource,
                                          p_input->p->p_sout, NULL );
+        if( p_input->p->p_renderer )
+            input_resource_RequestRenderer( p_input->p->p_resource,
+                                            p_input->p->p_renderer, NULL );
         input_resource_SetInput( p_input->p->p_resource, NULL );
         if( p_input->p->p_resource_private )
             input_resource_Terminate( p_input->p->p_resource_private );
@@ -1286,6 +1308,7 @@ error:
     /* Mark them deleted */
     p_input->p->p_es_out = NULL;
     p_input->p->p_sout = NULL;
+    p_input->p->p_renderer = NULL;
 
     return VLC_EGENERIC;
 }
@@ -1364,6 +1387,8 @@ static void End( input_thread_t * p_input )
     /* */
     input_resource_RequestSout( p_input->p->p_resource,
                                  p_input->p->p_sout, NULL );
+    input_resource_RequestRenderer( p_input->p->p_resource,
+                                    p_input->p->p_renderer, NULL );
     input_resource_SetInput( p_input->p->p_resource, NULL );
     if( p_input->p->p_resource_private )
         input_resource_Terminate( p_input->p->p_resource_private );
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index b68bec7..7458050 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -102,6 +102,7 @@ struct input_thread_private_t
     /* Output */
     bool            b_out_pace_control; /* XXX Move it ot es_sout ? */
     sout_instance_t *p_sout;            /* Idem ? */
+    vlc_renderer    *p_renderer;
     es_out_t        *p_es_out;
     es_out_t        *p_es_out_display;
 
-- 
2.8.0.rc3



More information about the vlc-devel mailing list