Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/GStreamer/gstreamer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Shpuntov <roman.shpuntov@gmail.com>2020-06-18 11:52:40 +0300
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-09-25 04:35:16 +0300
commitcc13705855fa7745c891158ead36160e76d300c8 (patch)
tree0cb13415d9233aecaaadaa1085d76dfd4063b36a
parent90077c2f1d384c403d19fc3f2081ededf1ea725e (diff)
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/635>
-rw-r--r--gst/gstsystemclock.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/gst/gstsystemclock.c b/gst/gstsystemclock.c
index 73dbfb4243..0d8cd5eddf 100644
--- a/gst/gstsystemclock.c
+++ b/gst/gstsystemclock.c
@@ -89,7 +89,6 @@ 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;
@@ -192,11 +191,8 @@ 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)
- /* we take a base time so that time starts from 0 to ease debugging */
- QueryPerformanceCounter (&priv->start);
- priv->ratio = GST_SECOND / priv->frequency.QuadPart;
+ /* we take a base time so that time starts from 0 to ease debugging */
+ QueryPerformanceCounter (&priv->start);
#endif /* G_OS_WIN32 */
#ifdef __APPLE__
@@ -582,8 +578,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->start.QuadPart) * sysclock->priv->ratio);
+ return gst_util_uint64_scale (now.QuadPart - sysclock->priv->start.QuadPart,
+ GST_SECOND, sysclock->priv->frequency.QuadPart);
} else
#endif /* G_OS_WIN32 */
#if !defined HAVE_POSIX_TIMERS || !defined HAVE_CLOCK_GETTIME