[vlc-commits] [Git][videolan/vlc][master] 2 commits: player: input: change ES delay without controls

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Apr 1 11:39:09 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
5e4dbfac by Alexandre Janniaux at 2023-04-01T11:08:07+00:00
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 at gllm.fr>

Refs #27918

- - - - -
1718facc by Alexandre Janniaux at 2023-04-01T11:08:07+00:00
player: use input_SetEsCatDelay instead of control

input_SetEsCatDelay will apply the delay synchronously if the input is
not running yet, or push a control to apply it from the input thread
otherwise.

Co-authored-by: Thomas Guillem <thomas at gllm.fr>

Refs #27918

- - - - -


4 changed files:

- src/input/input.c
- src/input/input_internal.h
- src/player/input.c
- src/player/player.c


Changes:

=====================================
src/input/input.c
=====================================
@@ -1862,6 +1862,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)
 {


=====================================
src/input/input_internal.h
=====================================
@@ -625,6 +625,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
  *


=====================================
src/player/input.c
=====================================
@@ -1023,12 +1023,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]);


=====================================
src/player/player.c
=====================================
@@ -1663,9 +1663,7 @@ vlc_player_SetCategoryDelay(vlc_player_t *player, enum es_format_category_e cat,
         delay = *cat_delay;
     }
 
-    const input_control_param_t param = { .cat_delay = { cat, delay } };
-    int ret = input_ControlPush(input->thread, INPUT_CONTROL_SET_CATEGORY_DELAY,
-                                &param);
+    int ret = input_SetEsCatDelay(input->thread, cat, delay);
     if (ret == VLC_SUCCESS)
     {
         vlc_player_osd_Message(player, _("%s delay: %i ms"),



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/181e91d00132d57205936d1cd6844b08756b0b4c...1718faccc63808e40ded77ad3c90939e9339d890

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/181e91d00132d57205936d1cd6844b08756b0b4c...1718faccc63808e40ded77ad3c90939e9339d890
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list