static input_thread_t * Create ( vlc_object_t *, input_item_t *,
const char *, bool, sout_instance_t * );
static int Init ( input_thread_t *p_input );
-static void Error ( input_thread_t *p_input );
+static void WaitDie ( input_thread_t *p_input );
static void End ( input_thread_t *p_input );
static void MainLoop( input_thread_t *p_input );
/* If we failed, wait before we are killed, and exit */
p_input->b_error = true;
- Error( p_input );
+ WaitDie( p_input );
/* Tell we're dead */
p_input->b_dead = true;
/* Wait until we are asked to die */
if( !p_input->b_die )
{
- Error( p_input );
+ WaitDie( p_input );
}
/* Clean up */
}
/*****************************************************************************
- * Error: RunThread() error loop
+ * WaitDie: Wait until we are asked to die.
*****************************************************************************
* This function is called when an error occurred during thread main's loop.
*****************************************************************************/
-static void Error( input_thread_t *p_input )
+static void WaitDie( input_thread_t *p_input )
{
- input_ChangeState( p_input, ERROR_S );
+ input_ChangeState( p_input, p_input->b_error ? ERROR_S : END_S );
while( !p_input->b_die )
{
/* Sleep a while */
static inline void input_ChangeStateWithVarCallback( input_thread_t *p_input, int state, bool callback )
{
- bool changed = (p_input->i_state != state);
+ const bool changed = p_input->i_state != state;
+
+ p_input->i_state = state;
+
if( callback )
- var_SetInteger( p_input, "state", p_input->i_state = state );
+ {
+ var_SetInteger( p_input, "state", state );
+ }
else
{
vlc_value_t val;
- p_input->i_state = val.i_int = state;
+ val.i_int = state;
var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
}
if( changed )