+static inline void input_ChangeStateWithVarCallback( input_thread_t *p_input, int state, bool callback )
+{
+ const bool changed = p_input->i_state != state;
+
+ p_input->i_state = state;
+
+ input_item_SetHasErrorWhenReading( p_input->p->input.p_item, (state == ERROR_S) );
+
+ if( callback )
+ {
+ var_SetInteger( p_input, "state", state );
+ }
+ else
+ {
+ vlc_value_t val;
+ val.i_int = state;
+ var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
+ }
+ if( changed )
+ {
+ vlc_event_t event;
+ event.type = vlc_InputStateChanged;
+ event.u.input_state_changed.new_state = state;
+ vlc_event_send( &p_input->p->event_manager, &event );
+ }
+}
+