[vlc-commits] clock: handle the INT64_MAX slave update early

Steve Lhomme git at videolan.org
Mon Aug 17 16:14:22 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Aug 11 13:54:48 2020 +0200| [3b6de5fc0159f93fe5f9b5e5a97f10f57632aabd] | committer: Steve Lhomme

clock: handle the INT64_MAX slave update early

Don't lock the main clock when we don't need to.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3b6de5fc0159f93fe5f9b5e5a97f10f57632aabd
---

 src/clock/clock.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/clock/clock.c b/src/clock/clock.c
index 26e380b439..e6c126d1c0 100644
--- a/src/clock/clock.c
+++ b/src/clock/clock.c
@@ -292,17 +292,23 @@ static vlc_tick_t vlc_clock_slave_update(vlc_clock_t *clock,
                                          unsigned frame_rate_base)
 {
     vlc_clock_main_t *main_clock = clock->owner;
+
+    if (system_now == INT64_MAX)
+    {
+        /* If system_now is INT64_MAX, the update is forced, don't modify anything
+        * but only notify the new clock point. */
+        vlc_clock_on_update(clock, INT64_MAX, ts, rate, frame_rate, frame_rate_base);
+        return INT64_MAX;
+    }
+
     vlc_mutex_lock(&main_clock->lock);
 
-    /* If system_now is INT64_MAX, the update is forced, don't modify anything
-     * but only notify the new clock point. */
-    vlc_tick_t computed = system_now == INT64_MAX ? INT64_MAX
-                        : clock->to_system_locked(clock, system_now, ts, rate);
+    vlc_tick_t computed = clock->to_system_locked(clock, system_now, ts, rate);
 
     vlc_mutex_unlock(&main_clock->lock);
 
     vlc_clock_on_update(clock, computed, ts, rate, frame_rate, frame_rate_base);
-    return computed != INT64_MAX ? computed - system_now : INT64_MAX;
+    return computed - system_now;
 }
 
 static void vlc_clock_slave_reset(vlc_clock_t *clock)



More information about the vlc-commits mailing list