[vlc-devel] [PATCH 1/5] input: add ViewpointApply()

Thomas Guillem thomas at gllm.fr
Mon Sep 4 12:33:01 CEST 2017


---
 src/input/input.c | 59 +++++++++++++++++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 26 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index f03584262b..49653db76f 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1731,6 +1731,38 @@ static void ControlUnpause( input_thread_t *p_input, mtime_t i_control_date )
     es_out_SetPauseState( input_priv(p_input)->p_es_out, false, false, i_control_date );
 }
 
+static void ViewpointApply( input_thread_t *p_input )
+{
+    input_thread_private_t *priv = input_priv(p_input);
+
+    vlc_viewpoint_clip( &priv->viewpoint );
+
+    vout_thread_t **pp_vout;
+    size_t i_vout;
+    input_resource_HoldVouts( priv->p_resource, &pp_vout, &i_vout );
+
+    for( size_t i = 0; i < i_vout; ++i )
+    {
+        var_SetAddress( pp_vout[i], "viewpoint", &priv->viewpoint );
+        /* This variable can only be read from callbacks */
+        var_Change( pp_vout[i], "viewpoint", VLC_VAR_SETVALUE,
+                    &(vlc_value_t) { .p_address = NULL }, NULL );
+        vlc_object_release( pp_vout[i] );
+    }
+    free( pp_vout );
+
+    audio_output_t *p_aout = input_resource_HoldAout( priv->p_resource );
+    if( p_aout )
+    {
+
+        var_SetAddress( p_aout, "viewpoint", &priv->viewpoint );
+        /* This variable can only be read from callbacks */
+        var_Change( p_aout, "viewpoint", VLC_VAR_SETVALUE,
+                    &(vlc_value_t) { .p_address = NULL }, NULL );
+        vlc_object_release( p_aout );
+    }
+}
+
 static bool Control( input_thread_t *p_input,
                      int i_type, vlc_value_t val )
 {
@@ -1971,32 +2003,7 @@ static bool Control( input_thread_t *p_input,
                 priv->viewpoint.fov   += p_vp->fov;
             }
 
-            vlc_viewpoint_clip( &priv->viewpoint );
-
-            vout_thread_t **pp_vout;
-            size_t i_vout;
-            input_resource_HoldVouts( priv->p_resource, &pp_vout, &i_vout );
-
-            for( size_t i = 0; i < i_vout; ++i )
-            {
-                var_SetAddress( pp_vout[i], "viewpoint", &priv->viewpoint );
-                /* This variable can only be read from callbacks */
-                var_Change( pp_vout[i], "viewpoint", VLC_VAR_SETVALUE,
-                            &(vlc_value_t) { .p_address = NULL }, NULL );
-                vlc_object_release( pp_vout[i] );
-            }
-            free( pp_vout );
-
-            audio_output_t *p_aout = input_resource_HoldAout( priv->p_resource );
-            if( p_aout )
-            {
-
-                var_SetAddress( p_aout, "viewpoint", &priv->viewpoint );
-                /* This variable can only be read from callbacks */
-                var_Change( p_aout, "viewpoint", VLC_VAR_SETVALUE,
-                            &(vlc_value_t) { .p_address = NULL }, NULL );
-                vlc_object_release( p_aout );
-            }
+            ViewpointApply( p_input );
             break;
         }
 
-- 
2.11.0



More information about the vlc-devel mailing list