mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-13 02:45:35 +00:00
systemclock: pre-calculate the ratio for multiplying the perf-count on win
Saves a lot of computations.
This commit is contained in:
parent
4b3872f757
commit
c6e5f59b2c
1 changed files with 3 additions and 2 deletions
|
@ -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;
|
||||
|
@ -195,6 +196,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__
|
||||
|
@ -580,8 +582,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
|
||||
|
|
Loading…
Reference in a new issue