Browse Source

player: input: change ES delay without controls

When setting delay, audio output flushing and picture drops can happen
and lead to unpleasant result, like stuttering, on both outputs.

Since the delay was set by an input command, demux could send a bit of
data to play before the delay was really applied, leading to this effect
even when starting the playback.

This commit alone doesn't fix the issue, but it ensures that delay is
synchronously set before the start of the input when it's not running
yet, mimicking the other input methods allowing to apply a control
synchronously when the input is not yet running.

Co-authored-by: Thomas Guillem <thomas@gllm.fr>
Alexandre Janniaux 3 years ago
parent
commit
48c1b49468
  1. 25
      src/input/input.c
  2. 20
      src/input/input_internal.h
  3. 7
      src/player/input.c

25
src/input/input.c

@ -1873,6 +1873,31 @@ void input_SetProgramId(input_thread_t *input, int group_id)
}
}
int input_SetEsCatDelay(input_thread_t *input, enum es_format_category_e cat,
vlc_tick_t delay)
{
input_thread_private_t *sys = input_priv(input);
/* A failure can only happen in the input_ControlPush section. */
int ret = VLC_SUCCESS;
if (!sys->is_running && !sys->is_stopped)
{
/* Not running, send the control synchronously since we are sure that
* it won't block */
es_out_SetDelay(sys->p_es_out_display, cat, delay);
}
else
{
const input_control_param_t param = {
.cat_delay = { cat, delay }
};
ret = input_ControlPush(input, INPUT_CONTROL_SET_CATEGORY_DELAY,
&param);
}
return ret;
}
void input_SetEsCatIds(input_thread_t *input, enum es_format_category_e cat,
const char *str_ids)
{

20
src/input/input_internal.h

@ -651,6 +651,26 @@ static inline int input_ControlPushEsHelper( input_thread_t *p_input, int i_type
*/
void input_SetProgramId(input_thread_t *input, int group_id);
/**
* Set the default delay applied to the given category.
*
* Set the default delay for the given \p es_format_category_e synchronously
* if the input is not running yet, otherwise push a control to signal to the
* input which delay should be updated.
*
* @param input Any input to change the delay for.
* @param cat The ES category to apply the delay to.
* @param delay The delay to apply to the category, a positive delay shifting
* the track to the future.
* @return VLC_SUCCESS when the delay has been applied, or signal an error
* otherwise.
*
* @note This function can be called before start or while running.
* @note This function is not thread-safe, the caller should handle the locking.
*/
int input_SetEsCatDelay(input_thread_t *input, enum es_format_category_e cat,
vlc_tick_t delay);
/**
* Set the list of string ids to enable for a category
*

7
src/player/input.c

@ -1077,12 +1077,7 @@ vlc_player_input_New(vlc_player_t *player, input_item_t *item)
input->cat_delays[i] = cat_delays[i];
if (cat_delays[i] != 0)
{
const input_control_param_t param = {
.cat_delay = { i, cat_delays[i] }
};
int ret = input_ControlPush(input->thread,
INPUT_CONTROL_SET_CATEGORY_DELAY,
&param);
int ret = input_SetEsCatDelay(input->thread, i, cat_delays[i]);
if (ret == VLC_SUCCESS)
vlc_player_SendEvent(player, on_category_delay_changed, i,
cat_delays[i]);

Loading…
Cancel
Save