[vlc-commits] core: use vlc_tick_from_frac() to convert clock ticks
Steve Lhomme
git at videolan.org
Tue Sep 25 12:19:54 CEST 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Sep 25 09:47:59 2018 +0200| [fdc5af257000eda4b44533005c27a7064275428e] | committer: Steve Lhomme
core: use vlc_tick_from_frac() to convert clock ticks
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fdc5af257000eda4b44533005c27a7064275428e
---
src/darwin/thread.c | 6 ++----
src/win32/thread.c | 4 +---
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/darwin/thread.c b/src/darwin/thread.c
index 8f4bba370c..f5eb4f234e 100644
--- a/src/darwin/thread.c
+++ b/src/darwin/thread.c
@@ -520,12 +520,10 @@ vlc_tick_t vlc_tick_now (void)
uint64_t denom = vlc_clock_conversion_factor.denom;
/* Switch to microsecs */
- denom *= 1000LL;
+ denom *= UINT64_C(1000);
/* Split the division to prevent overflow */
- lldiv_t d = lldiv (vlc_clock_conversion_factor.numer, denom);
-
- return (d.quot * date) + ((d.rem * date) / denom);
+ return vlc_tick_from_frac( date * vlc_clock_conversion_factor.numer, denom );
}
#undef vlc_tick_wait
diff --git a/src/win32/thread.c b/src/win32/thread.c
index e4c1e840a4..930b8a8f81 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -741,9 +741,7 @@ static vlc_tick_t mdate_perf (void)
/* Convert to from (1/freq) to microsecond resolution */
/* We need to split the division to avoid 63-bits overflow */
- lldiv_t d = lldiv (counter.QuadPart, clk.perf.freq.QuadPart);
-
- return vlc_tick_from_sec( d.quot ) + ((d.rem * CLOCK_FREQ) / clk.perf.freq.QuadPart);
+ return vlc_tick_from_frac(counter.QuadPart, clk.perf.freq.QuadPart);
}
static vlc_tick_t mdate_wall (void)
More information about the vlc-commits
mailing list