[vlc-commits] timer: fix possible missed interval/delay in the timer

Steve Lhomme git at videolan.org
Fri Feb 1 17:36:31 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jan 30 10:35:33 2019 +0100| [09fd2e48c471b072b7cede3b52523c15e270dabc] | committer: Steve Lhomme

timer: fix possible missed interval/delay in the timer

Due to rounding errors. For example an interval of 999 ticks will give a 0
interval in the end.

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

 src/win32/timer.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/win32/timer.c b/src/win32/timer.c
index e9f78c1b11..4fe3d2b067 100644
--- a/src/win32/timer.c
+++ b/src/win32/timer.c
@@ -80,9 +80,15 @@ void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
             value = 0;
     }
 
+    DWORD val    = MS_FROM_VLC_TICK(value);
+    DWORD interv = MS_FROM_VLC_TICK(interval);
+    if (val == 0 && value != 0)
+        val = 1; /* rounding error */
+    if (interv == 0 && interval != 0)
+        interv = 1; /* rounding error */
+
     if (!CreateTimerQueueTimer(&timer->handle, NULL, vlc_timer_do, timer,
-                               MS_FROM_VLC_TICK(value),
-                               MS_FROM_VLC_TICK(interval), WT_EXECUTEDEFAULT))
+                               val, interv, WT_EXECUTEDEFAULT))
         abort ();
 }
 



More information about the vlc-commits mailing list