From 2a44723d4dbea74892d6eee1c8ba463a1f38d014 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sat, 14 May 2022 15:20:16 -0500 Subject: [PATCH] quartz/systemclock: Use timeGetTime() to retrieve the current time. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Alexandre Julliard --- 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 729122fec46..01a8e9fa1ee 100644 --- a/dlls/quartz/systemclock.c +++ b/dlls/quartz/systemclock.c @@ -45,7 +45,6 @@ struct system_clock LONG thread_created; BOOL thread_stopped; HANDLE thread; - LARGE_INTEGER frequency; REFERENCE_TIME last_time; CRITICAL_SECTION cs; CONDITION_VARIABLE cv; @@ -53,12 +52,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) @@ -155,7 +151,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) { @@ -250,7 +246,7 @@ static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock *iface, REFERENCE_ return E_POINTER; } - ret = get_current_time(clock); + ret = get_current_time(); EnterCriticalSection(&clock->cs); @@ -346,7 +342,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;