[vlc-devel] [PATCH] core: fix vlc_tick_now on darwin platform
Zhao Zhili
quinkblack at foxmail.com
Wed Sep 26 19:23:04 CEST 2018
regression by fdc5af257000eda4b44533005c27a7064275428e
1. The math was incorrect. date * vlc_clock_conversion_factor.numer / denom
is in the unit of microsecond, not second
2. It has overflow problem
---
src/darwin/thread.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/darwin/thread.c b/src/darwin/thread.c
index f5eb4f234e..884483fb8a 100644
--- a/src/darwin/thread.c
+++ b/src/darwin/thread.c
@@ -523,7 +523,9 @@ vlc_tick_t vlc_tick_now (void)
denom *= UINT64_C(1000);
/* Split the division to prevent overflow */
- return vlc_tick_from_frac( date * vlc_clock_conversion_factor.numer, denom );
+ lldiv_t d = lldiv (vlc_clock_conversion_factor.numer, denom);
+
+ return (d.quot * date) + ((d.rem * date) / denom);
}
#undef vlc_tick_wait
--
2.15.2 (Apple Git-101.1)
More information about the vlc-devel
mailing list