Browse Source

input: add external EOF handling

The INPUT_EVENT_EOF listener can return true if it handles the EOF itself.
In that case, the input_thread_t will wait for any controls
(input_Stop() will definitively stop it).

No changes if the event is not handled.
pull/192/head
Thomas Guillem 4 months ago
committed by Felix Paul Kühne
parent
commit
a1b192fb4b
  1. 18
      src/input/input.c
  2. 3
      src/input/input_internal.h
  3. 3
      src/player/input.c

18
src/input/input.c

@ -664,6 +664,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
bool b_pause_after_eof = b_interactive &&
var_InheritBool( p_input, "play-and-pause" );
bool b_paused_at_eof = false;
bool eof_signaled = false;
demux_t *p_demux = input_priv(p_input)->master->p_demux;
const bool b_can_demux = p_demux->ops != NULL ?
@ -695,6 +696,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
i_intf_update = 0;
b_paused_at_eof = false;
eof_signaled = false;
}
else if( !es_out_IsEmpty( input_priv(p_input)->p_es_out ) )
{
@ -703,9 +705,23 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
}
else
{
bool eof_handled;
if( !eof_signaled )
{
eof_handled =
input_SendEvent(p_input, &(struct vlc_input_event) {
.type = INPUT_EVENT_EOF,
});
eof_signaled = true;
}
else
eof_handled = true;
if (eof_handled)
i_wakeup = -1;
/* Pause after eof only if the input is pausable.
* This way we won't trigger timeshifting for nothing */
if( b_pause_after_eof && input_priv(p_input)->master->b_can_pause )
else if( b_pause_after_eof && input_priv(p_input)->master->b_can_pause )
{
if( b_paused_at_eof )
break;

3
src/input/input_internal.h

@ -82,6 +82,9 @@ typedef enum input_event_type_e
INPUT_EVENT_STATE,
/* b_dead is true */
INPUT_EVENT_DEAD,
/* If the event is not handled, or if the listener is returning false,
* the input will be stopped normally at EOF */
INPUT_EVENT_EOF,
/* "rate" has changed */
INPUT_EVENT_RATE,

3
src/player/input.c

@ -926,6 +926,9 @@ input_thread_Events(input_thread_t *input_thread,
vlc_player_input_HandleStateEvent(input, event->state.value,
event->state.date);
break;
case INPUT_EVENT_EOF:
handled = false;
break;
case INPUT_EVENT_RATE:
input->rate = event->rate;
vlc_player_SendEvent(player, on_rate_changed, input->rate);

Loading…
Cancel
Save