[vlc-devel] [PATCH 1/2] input: refactor enabling recording

Francois Cartegnie fcvlcdev at free.fr
Tue Oct 13 21:29:15 CEST 2020


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

diff --git a/src/input/input.c b/src/input/input.c
index 4be4d304f6..1f5ac9189a 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -957,6 +957,31 @@ static void SetSubtitlesOptions( input_thread_t *p_input )
     }
 }
 
+static bool ToggleRecording(input_thread_t *p_input, bool b_record)
+{
+    input_thread_private_t *priv = input_priv(p_input);
+    if( !!priv->b_recording != !!b_record )
+    {
+        if( priv->master->b_can_stream_record )
+        {
+            if( demux_Control( priv->master->p_demux,
+                               DEMUX_SET_RECORD_STATE, b_record ) )
+                b_record = false;
+        }
+        else
+        {
+            if( es_out_SetRecordState( priv->p_es_out_display, b_record ) )
+                b_record = false;
+        }
+        priv->b_recording = b_record;
+
+        input_SendEventRecord( p_input, b_record );
+
+        return true;
+    }
+    return false;
+}
+
 static void GetVarSlaves( input_thread_t *p_input,
                           input_item_slave_t ***ppp_slaves, int *p_slaves )
 {
@@ -1897,7 +1922,6 @@ static bool Control( input_thread_t *p_input,
     const vlc_tick_t i_control_date = vlc_tick_now();
     /* FIXME b_force_update is abused, it should be carefully checked */
     bool b_force_update = false;
-    vlc_value_t val;
 
     switch( i_type )
     {
@@ -2250,26 +2274,7 @@ static bool Control( input_thread_t *p_input,
             break;
 
         case INPUT_CONTROL_SET_RECORD_STATE:
-            val = param.val;
-            if( !!priv->b_recording != !!val.b_bool )
-            {
-                if( priv->master->b_can_stream_record )
-                {
-                    if( demux_Control( priv->master->p_demux,
-                                       DEMUX_SET_RECORD_STATE, val.b_bool ) )
-                        val.b_bool = false;
-                }
-                else
-                {
-                    if( es_out_SetRecordState( priv->p_es_out_display, val.b_bool ) )
-                        val.b_bool = false;
-                }
-                priv->b_recording = val.b_bool;
-
-                input_SendEventRecord( p_input, val.b_bool );
-
-                b_force_update = true;
-            }
+            b_force_update = ToggleRecording( p_input, param.val.b_bool );
             break;
 
         case INPUT_CONTROL_SET_FRAME_NEXT:
-- 
2.26.2



More information about the vlc-devel mailing list