[vlc-devel] [PATCH 1/2] input: return the error status from Control()

Thomas Guillem thomas at gllm.fr
Tue Sep 4 14:35:44 CEST 2018


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

diff --git a/src/input/input.c b/src/input/input.c
index d94b94779d..eb7199a804 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -72,7 +72,7 @@ static void             MainLoop( input_thread_t *p_input, bool b_interactive );
 static inline int ControlPop( input_thread_t *, int *, input_control_param_t *, vlc_tick_t i_deadline, bool b_postpone_seek );
 static void       ControlRelease( int i_type, const input_control_param_t *p_param );
 static bool       ControlIsSeekRequest( int i_type );
-static bool       Control( input_thread_t *, int, input_control_param_t );
+static int        Control( input_thread_t *, int, input_control_param_t, bool *force_update );
 static void       ControlPause( input_thread_t *, vlc_tick_t );
 
 static int  UpdateTitleSeekpointFromDemux( input_thread_t * );
@@ -768,7 +768,8 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
                 param.val.i_int = PAUSE_S;
 
                 msg_Dbg( p_input, "pausing at EOF (pause after each)");
-                Control( p_input, INPUT_CONTROL_SET_STATE, param );
+                bool unused;
+                Control( p_input, INPUT_CONTROL_SET_STATE, param, &unused );
 
                 b_paused = true;
                 b_paused_at_eof = true;
@@ -822,7 +823,9 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
 #ifndef NDEBUG
             msg_Dbg( p_input, "control type=%d", i_type );
 #endif
-            if( Control( p_input, i_type, param ) )
+            bool force_update;
+            int ret = Control( p_input, i_type, param, &force_update );
+            if( force_update )
             {
                 if( ControlIsSeekRequest( i_type ) )
                     i_last_seek_mdate = vlc_tick_now();
@@ -1880,21 +1883,23 @@ static int DemuxSetTime(input_thread_t *p_input, vlc_tick_t time, bool fast,
     return demux_Control(priv->master->p_demux, DEMUX_SET_TIME, time, !fast);
 }
 
-static bool Control( input_thread_t *p_input,
-                     int i_type, input_control_param_t param )
+static int Control( input_thread_t *p_input,
+                    int i_type, input_control_param_t param, bool *force_update )
 {
     input_thread_private_t *priv = input_priv(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;
+    int ret = VLC_SUCCESS;
     vlc_value_t val;
 
+    *force_update = false;
     switch( i_type )
     {
         case INPUT_CONTROL_SET_POSITION:
             if( priv->b_recording )
             {
                 msg_Err( p_input, "INPUT_CONTROL_SET_POSITION ignored while recording" );
+                ret = VLC_EGENERIC;
                 break;
             }
 
@@ -1907,6 +1912,7 @@ static bool Control( input_thread_t *p_input,
                          "%s%2.1f%% failed",
                          param.pos.b_absolute ? "@" : param.pos.f_val >= 0 ? "+" : "",
                          (double)(param.pos.f_val * 100.f) );
+                ret = VLC_EGENERIC;
             }
             else
             {
@@ -1914,7 +1920,7 @@ static bool Control( input_thread_t *p_input,
                     SlaveSeek( p_input );
                 priv->master->b_eof = false;
 
-                b_force_update = true;
+                *force_update = true;
             }
             break;
 
@@ -1925,6 +1931,7 @@ static bool Control( input_thread_t *p_input,
             if( priv->b_recording )
             {
                 msg_Err( p_input, "INPUT_CONTROL_SET_TIME ignored while recording" );
+                ret = VLC_EGENERIC;
                 break;
             }
 
@@ -1952,6 +1959,7 @@ static bool Control( input_thread_t *p_input,
                          " failed or not possible",
                          param.time.b_absolute ? "@" : param.time.i_val >= 0 ? "+" : "",
                          param.time.i_val );
+                ret = VLC_EGENERIC;
             }
             else
             {
@@ -1959,7 +1967,7 @@ static bool Control( input_thread_t *p_input,
                     SlaveSeek( p_input );
                 priv->master->b_eof = false;
 
-                b_force_update = true;
+                *force_update = true;
             }
             break;
         }
@@ -1971,17 +1979,18 @@ static bool Control( input_thread_t *p_input,
                     if( priv->i_state == PAUSE_S )
                     {
                         ControlUnpause( p_input, i_control_date );
-                        b_force_update = true;
+                        *force_update = true;
                     }
                     break;
                 case PAUSE_S:
                     if( priv->i_state == PLAYING_S )
                     {
                         ControlPause( p_input, i_control_date );
-                        b_force_update = true;
+                        *force_update = true;
                     }
                     break;
                 default:
+                    ret = VLC_EGENERIC;
                     msg_Err( p_input, "invalid INPUT_CONTROL_SET_STATE" );
             }
             break;
@@ -2052,7 +2061,7 @@ static bool Control( input_thread_t *p_input,
                     es_out_SetRate( priv->p_es_out, i_rate_source, i_rate );
                 }
 
-                b_force_update = true;
+                *force_update = true;
             }
             break;
         }
@@ -2131,6 +2140,7 @@ static bool Control( input_thread_t *p_input,
             if( priv->b_recording )
             {
                 msg_Err( p_input, "INPUT_CONTROL_SET_TITLE(*) ignored while recording" );
+                ret = VLC_EGENERIC;
                 break;
             }
             if( priv->master->i_title <= 0 )
@@ -2159,10 +2169,14 @@ static bool Control( input_thread_t *p_input,
             if( priv->b_recording )
             {
                 msg_Err( p_input, "INPUT_CONTROL_SET_SEEKPOINT(*) ignored while recording" );
+                ret = VLC_EGENERIC;
                 break;
             }
             if( priv->master->i_title <= 0 )
+            {
+                ret = VLC_EGENERIC;
                 break;
+            }
 
             demux_t *p_demux = priv->master->p_demux;
 
@@ -2235,7 +2249,7 @@ static bool Control( input_thread_t *p_input,
 
                 input_SendEventRecord( p_input, val.b_bool );
 
-                b_force_update = true;
+                *force_update = true;
             }
             break;
 
@@ -2250,9 +2264,10 @@ static bool Control( input_thread_t *p_input,
             }
             else
             {
+                ret = VLC_EGENERIC;
                 msg_Err( p_input, "invalid state for frame next" );
             }
-            b_force_update = true;
+            *force_update = true;
             break;
 
         case INPUT_CONTROL_SET_BOOKMARK:
@@ -2271,13 +2286,14 @@ static bool Control( input_thread_t *p_input,
             if( time_offset < 0 )
             {
                 msg_Err( p_input, "invalid bookmark %d", bookmark );
+                ret = VLC_EGENERIC;
                 break;
             }
 
-            b_force_update =
-                Control( p_input, INPUT_CONTROL_SET_TIME,
-                         (input_control_param_t) { .time.i_val = time_offset,
-                                                   .time.b_fast_seek = false } );
+            ret = Control( p_input, INPUT_CONTROL_SET_TIME,
+                           (input_control_param_t) { .time.i_val = time_offset,
+                                                     .time.b_fast_seek = false },
+                           force_update );
             break;
         }
         case INPUT_CONTROL_SET_RENDERER:
@@ -2287,12 +2303,18 @@ static bool Control( input_thread_t *p_input,
             input_thread_private_t *p_priv = input_priv( p_input );
             // We do not support switching from a renderer to another for now
             if ( p_item == NULL && p_priv->p_renderer == NULL )
+            {
+                ret = VLC_EGENERIC;
                 break;
+            }
 
             void *context;
             if( es_out_Control( priv->p_es_out_display,
                                 ES_OUT_STOP_ALL_ES, &context ) != VLC_SUCCESS )
+            {
+                ret = VLC_EGENERIC;
                 break;
+            }
 
             if ( p_priv->p_renderer )
             {
@@ -2332,11 +2354,12 @@ static bool Control( input_thread_t *p_input,
 
         default:
             msg_Err( p_input, "not yet implemented" );
+            ret = VLC_EGENERIC;
             break;
     }
 
     ControlRelease( i_type, &param );
-    return b_force_update;
+    return ret;
 }
 
 /*****************************************************************************
-- 
2.18.0



More information about the vlc-devel mailing list