Module: wine
Branch: oldstable
Commit: 0d24c0f5ab65a26affbb91345a0f4089878356b8
URL: https://gitlab.winehq.org/wine/wine/-/commit/0d24c0f5ab65a26affbb91345a0f40…
Author: Zebediah Figura <zfigura(a)codeweavers.com>
Date: Sat May 14 15:20:16 2022 -0500
quartz/systemclock: Use timeGetTime() to retrieve the current time.
There is no evidence that the extra overhead should matter, and this allows us
to be consistent, and potentially change timeGetTime() without having to worry
about quartz.
On Windows, timeGetTime() has identical resolution to the interrupt time [i.e.
the "InterruptTime" member of the shared user data, or QueryInterruptTime()].
Like those sources, it approximately measures the boot time. However, the values
are not identical; timeGetTime() lags behind QueryInterruptTime() anywhere from
1 to 12 ms (regardless of timer period) on my Windows 10 virtual machine. The
actual lag is consistent within a process but varies between runs. I have not
been able to account for this lag—it's not the suspend bias, nor is it an
attempt to match the tick count more closely.
In short, timeGetTime() seems to be idiosyncratic to winmm. Since quartz has
been shown to follow winmm exactly on Windows, let's follow it on Wine as well.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53005
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
(cherry picked from commit 2a44723d4dbea74892d6eee1c8ba463a1f38d014)
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/quartz/Makefile.in | 2 +-
dlls/quartz/systemclock.c | 13 ++++---------
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/dlls/quartz/Makefile.in b/dlls/quartz/Makefile.in
index e7e1b43da79..7854a87e846 100644
--- a/dlls/quartz/Makefile.in
+++ b/dlls/quartz/Makefile.in
@@ -1,6 +1,6 @@
MODULE = quartz.dll
IMPORTLIB = quartz
-IMPORTS = strmiids dxguid strmbase uuid dsound msacm32 msvfw32 ole32 oleaut32 rpcrt4 user32 gdi32 advapi32
+IMPORTS = strmiids dxguid strmbase uuid dsound msacm32 msvfw32 ole32 oleaut32 rpcrt4 user32 gdi32 advapi32 winmm
C_SRCS = \
acmwrapper.c \
diff --git a/dlls/quartz/systemclock.c b/dlls/quartz/systemclock.c
index f579ae754ea..20859659402 100644
--- a/dlls/quartz/systemclock.c
+++ b/dlls/quartz/systemclock.c
@@ -44,7 +44,6 @@ struct system_clock
BOOL thread_created, thread_stopped;
HANDLE thread;
- LARGE_INTEGER frequency;
REFERENCE_TIME last_time;
CRITICAL_SECTION cs;
CONDITION_VARIABLE cv;
@@ -52,12 +51,9 @@ struct system_clock
struct list sinks;
};
-static REFERENCE_TIME get_current_time(const struct system_clock *clock)
+static REFERENCE_TIME get_current_time(void)
{
- LARGE_INTEGER time;
-
- QueryPerformanceCounter(&time);
- return (time.QuadPart * 1000) / clock->frequency.QuadPart * 10000;
+ return (REFERENCE_TIME)timeGetTime() * 10000;
}
static inline struct system_clock *impl_from_IUnknown(IUnknown *iface)
@@ -154,7 +150,7 @@ static DWORD WINAPI SystemClockAdviseThread(void *param)
EnterCriticalSection(&clock->cs);
- current_time = get_current_time(clock);
+ current_time = get_current_time();
LIST_FOR_EACH_ENTRY_SAFE(sink, cursor, &clock->sinks, struct advise_sink, entry)
{
@@ -249,7 +245,7 @@ static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock *iface, REFERENCE_
return E_POINTER;
}
- ret = get_current_time(clock);
+ ret = get_current_time();
EnterCriticalSection(&clock->cs);
@@ -345,7 +341,6 @@ HRESULT system_clock_create(IUnknown *outer, IUnknown **out)
list_init(&object->sinks);
InitializeCriticalSection(&object->cs);
object->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SystemClockImpl.cs");
- QueryPerformanceFrequency(&object->frequency);
TRACE("Created system clock %p.\n", object);
*out = &object->IUnknown_inner;