[vlc-commits] win32: fix delay rounding error

Rémi Denis-Courmont git at videolan.org
Fri May 27 23:34:12 CEST 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat May 28 00:32:22 2016 +0300| [113ded6ac31fd8061deadf211be55c8df1d5ea97] | committer: Rémi Denis-Courmont

win32: fix delay rounding error

Delay must be rounded up, not down.

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

 src/win32/thread.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/win32/thread.c b/src/win32/thread.c
index 1995556..8df74c8 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -301,7 +301,7 @@ void vlc_cond_wait(vlc_cond_t *wait, vlc_mutex_t *lock)
 
 int vlc_cond_timedwait(vlc_cond_t *wait, vlc_mutex_t *lock, mtime_t deadline)
 {
-    return vlc_cond_wait_delay(wait, lock, (deadline - mdate()) / 1000);
+    return vlc_cond_wait_delay(wait, lock, (deadline + 999 - mdate()) / 1000);
 }
 
 int vlc_cond_timedwait_daytime(vlc_cond_t *wait, vlc_mutex_t *lock,
@@ -771,7 +771,7 @@ void mwait (mtime_t deadline)
     vlc_testcancel();
     while ((delay = (deadline - mdate())) > 0)
     {
-        delay /= 1000;
+        delay = (delay + 999) / 1000;
         if (unlikely(delay > 0x7fffffff))
             delay = 0x7fffffff;
         vlc_Sleep (delay);



More information about the vlc-commits mailing list