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@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-05-14 15:20:16 -05:00 committed by Alexandre Julliard
parent 21379f3ddf
commit 2a44723d4d
2 changed files with 5 additions and 10 deletions

View File

@ -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 \

View File

@ -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;