diff options
author | Havard Graff <havard@pexip.com> | 2018-09-20 11:42:48 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2018-11-08 00:10:52 +0300 |
commit | e4093f05f36b3a80984109064df67825e4f8f851 (patch) | |
tree | c5934d17fe1d1a3db3a02116ccb99702799817d1 | |
parent | d819f6913c900fd07e240f5f307cbff23763f1dd (diff) |
systemclock: pre-calculate the ratio for multiplying the perf-count on win
Saves a lot of computations.
-rw-r--r-- | gst/gstsystemclock.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gst/gstsystemclock.c b/gst/gstsystemclock.c index 02f56b11e0..2fcb7f8741 100644 --- a/gst/gstsystemclock.c +++ b/gst/gstsystemclock.c @@ -89,6 +89,7 @@ struct _GstSystemClockPrivate #ifdef G_OS_WIN32 LARGE_INTEGER start; LARGE_INTEGER frequency; + guint64 ratio; #endif /* G_OS_WIN32 */ #ifdef __APPLE__ struct mach_timebase_info mach_timebase; @@ -201,6 +202,7 @@ gst_system_clock_init (GstSystemClock * clock) if (priv->frequency.QuadPart != 0) /* we take a base time so that time starts from 0 to ease debugging */ QueryPerformanceCounter (&priv->start); + priv->ratio = GST_SECOND / priv->frequency.QuadPart; #endif /* G_OS_WIN32 */ #ifdef __APPLE__ @@ -586,8 +588,7 @@ gst_system_clock_get_internal_time (GstClock * clock) /* we prefer the highly accurate performance counters on windows */ QueryPerformanceCounter (&now); - return gst_util_uint64_scale (now.QuadPart - sysclock->priv->start.QuadPart, - GST_SECOND, sysclock->priv->frequency.QuadPart); + return ((now.QuadPart - sysclock->priv->start.QuadPart) * sysclock->priv->ratio); } else #endif /* G_OS_WIN32 */ #if !defined HAVE_POSIX_TIMERS || !defined HAVE_CLOCK_GETTIME |