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@codeweavers.com --- 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..dcc6549682c 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 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;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=114710
Your paranoid android.
=== debian11 (32 bit report) ===
quartz: systemclock.c:176: Test failed: Expected no less than 1ms coarseness, but got time ff5de770. systemclock.c:183: Test failed: Expected no less than 1ms coarseness, but got time ff5de770. systemclock.c:186: Test failed: Got timestamps 4284344176, 3092365830000, 4284344176.
=== debian11 (32 bit Chinese:China report) ===
quartz: systemclock.c:176: Test failed: Expected no less than 1ms coarseness, but got time 32dff070. systemclock.c:183: Test failed: Expected no less than 1ms coarseness, but got time 32dff070. systemclock.c:186: Test failed: Got timestamps 853536880, 3093229990000, 853536880.
=== debian11 (32 bit WoW report) ===
quartz: systemclock.c:176: Test failed: Expected no less than 1ms coarseness, but got time 9b5335c0. systemclock.c:183: Test failed: Expected no less than 1ms coarseness, but got time 9b5335c0. systemclock.c:186: Test failed: Got timestamps 2605921728, 3039147800000, 2605921728.
=== debian11 (64 bit WoW report) ===
quartz: systemclock.c:176: Test failed: Expected no less than 1ms coarseness, but got time dcd513b0. systemclock.c:183: Test failed: Expected no less than 1ms coarseness, but got time dcd513b0. systemclock.c:186: Test failed: Got timestamps 3704951728, 3040246830000, 3704951728.