[vlc-commits] [Git][videolan/vlc][master] 2 commits: clock: don't include the delay for the master clock

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Nov 11 10:03:14 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0fa4d351 by Thomas Guillem at 2023-11-11T09:22:33+00:00
clock: don't include the delay for the master clock

If the source is the master, it needs to handle the delay itself by
delaying the playback by the delta returned by vlc_clock_SetDelay() (for
slaves, the return value will be always 0). This is already done by the
audio output, that is sending silence to reach that delta.

The delay was applied 2 times, one time in the audio output and one time
in the clock. Therefore, remove that extra delay.

- - - - -
6834df46 by Thomas Guillem at 2023-11-11T09:22:33+00:00
clock: fix timing report when decreasing the delay

- - - - -


1 changed file:

- src/clock/clock.c


Changes:

=====================================
src/clock/clock.c
=====================================
@@ -122,18 +122,15 @@ static inline void vlc_clock_on_update(vlc_clock_t *clock,
 
 static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
                                           vlc_tick_t system_now,
-                                          vlc_tick_t original_ts, double rate,
+                                          vlc_tick_t ts, double rate,
                                           unsigned frame_rate,
                                           unsigned frame_rate_base)
 {
     vlc_clock_main_t *main_clock = clock->owner;
 
-    if (unlikely(original_ts == VLC_TICK_INVALID
-     || system_now == VLC_TICK_INVALID))
+    if (unlikely(ts == VLC_TICK_INVALID || system_now == VLC_TICK_INVALID))
         return VLC_TICK_INVALID;
 
-    const vlc_tick_t ts = original_ts + clock->delay;
-
     vlc_mutex_lock(&main_clock->lock);
 
     /* If system_now is VLC_TICK_MAX, the update is forced, don't modify
@@ -212,8 +209,13 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
 
     vlc_mutex_unlock(&main_clock->lock);
 
-    vlc_clock_on_update(clock, system_now, original_ts, rate, frame_rate,
-                        frame_rate_base);
+    /* Fix the reported ts if both master and slaves source are delayed. This
+     * happens if we apply a positive delay to the master, and then lower it. */
+    if (clock->delay > 0 && main_clock->delay < 0 && ts > -main_clock->delay)
+        ts += main_clock->delay;
+
+    vlc_clock_on_update(clock, system_now, ts,
+                        rate, frame_rate, frame_rate_base);
     return VLC_TICK_INVALID;
 }
 
@@ -345,7 +347,7 @@ static vlc_tick_t vlc_clock_master_to_system_locked(vlc_clock_t *clock,
         system = vlc_clock_monotonic_to_system_locked(clock, now, ts, rate);
     }
 
-    return system + clock->delay * rate;
+    return system;
 }
 
 static vlc_tick_t vlc_clock_slave_update(vlc_clock_t *clock,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f58c19a8b4cfb0d0dc3849858f673e9229c2e4e5...6834df46ba90ae5fbe66cb41141f48352036cc64

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f58c19a8b4cfb0d0dc3849858f673e9229c2e4e5...6834df46ba90ae5fbe66cb41141f48352036cc64
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