mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-01 06:01:04 +00:00
systemclock: Fix clock time conversion on Windows/xbox
The returned ratio can be bigger than GST_SECOND, in which case we would forever return 0 for the system clock time. Even in other cases if it's close to GST_SECOND it would result in accuracy loss. Instead of doing the division by GST_CLOCK_TIME_NONE during initialization once, do it every time the clock time is requested. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/575 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/534>
This commit is contained in:
parent
31e6d766ff
commit
fd280c0981
1 changed files with 2 additions and 6 deletions
|
@ -352,7 +352,6 @@ struct _GstSystemClockPrivate
|
|||
|
||||
#ifdef G_OS_WIN32
|
||||
LARGE_INTEGER frequency;
|
||||
guint64 ratio;
|
||||
#endif /* G_OS_WIN32 */
|
||||
#ifdef __APPLE__
|
||||
struct mach_timebase_info mach_timebase;
|
||||
|
@ -453,10 +452,6 @@ gst_system_clock_init (GstSystemClock * clock)
|
|||
|
||||
#ifdef G_OS_WIN32
|
||||
QueryPerformanceFrequency (&priv->frequency);
|
||||
/* can be 0 if the hardware does not have hardware support */
|
||||
if (priv->frequency.QuadPart != 0) {
|
||||
priv->ratio = GST_SECOND / priv->frequency.QuadPart;
|
||||
}
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
@ -845,7 +840,8 @@ gst_system_clock_get_internal_time (GstClock * clock)
|
|||
/* we prefer the highly accurate performance counters on windows */
|
||||
QueryPerformanceCounter (&now);
|
||||
|
||||
return now.QuadPart * sysclock->priv->ratio;
|
||||
return gst_util_uint64_scale (now.QuadPart,
|
||||
GST_SECOND, sysclock->priv->frequency.QuadPart);
|
||||
} else
|
||||
#endif /* G_OS_WIN32 */
|
||||
#if !defined HAVE_POSIX_TIMERS || !defined HAVE_CLOCK_GETTIME
|
||||
|
|
Loading…
Reference in a new issue