[vlc-devel] [PATCH] clock: check condition before calculation

Zhao Zhili quinkblack at foxmail.com
Wed May 20 17:28:04 CEST 2020


---
 src/clock/clock.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/clock/clock.c b/src/clock/clock.c
index f373460abe..26e380b439 100644
--- a/src/clock/clock.c
+++ b/src/clock/clock.c
@@ -132,12 +132,12 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
         if (main_clock->offset != VLC_TICK_INVALID
          && ts != main_clock->last.stream)
         {
-            /* We have a reference so we can update coeff */
-            double instant_coeff = (system_now - main_clock->last.system)
-                                 / (double)(ts - main_clock->last.stream);
             if (rate == main_clock->rate)
             {
-                instant_coeff *= rate;
+                /* We have a reference so we can update coeff */
+                double instant_coeff = (system_now - main_clock->last.system)
+                                     / (double)(ts - main_clock->last.stream)
+                                     * rate;
                 AvgUpdate(&main_clock->coeff_avg, instant_coeff);
                 main_clock->coeff = AvgGet(&main_clock->coeff_avg);
             }
-- 
2.25.1



More information about the vlc-devel mailing list