Commit 2a44723d authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

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=53005Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 21379f3d
MODULE = quartz.dll MODULE = quartz.dll
IMPORTLIB = quartz 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 = \ C_SRCS = \
acmwrapper.c \ acmwrapper.c \
......
...@@ -45,7 +45,6 @@ struct system_clock ...@@ -45,7 +45,6 @@ struct system_clock
LONG thread_created; LONG thread_created;
BOOL thread_stopped; BOOL thread_stopped;
HANDLE thread; HANDLE thread;
LARGE_INTEGER frequency;
REFERENCE_TIME last_time; REFERENCE_TIME last_time;
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
CONDITION_VARIABLE cv; CONDITION_VARIABLE cv;
...@@ -53,12 +52,9 @@ struct system_clock ...@@ -53,12 +52,9 @@ struct system_clock
struct list sinks; struct list sinks;
}; };
static REFERENCE_TIME get_current_time(const struct system_clock *clock) static REFERENCE_TIME get_current_time(void)
{ {
LARGE_INTEGER time; return (REFERENCE_TIME)timeGetTime() * 10000;
QueryPerformanceCounter(&time);
return (time.QuadPart * 1000) / clock->frequency.QuadPart * 10000;
} }
static inline struct system_clock *impl_from_IUnknown(IUnknown *iface) static inline struct system_clock *impl_from_IUnknown(IUnknown *iface)
...@@ -155,7 +151,7 @@ static DWORD WINAPI SystemClockAdviseThread(void *param) ...@@ -155,7 +151,7 @@ static DWORD WINAPI SystemClockAdviseThread(void *param)
EnterCriticalSection(&clock->cs); 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) 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_ ...@@ -250,7 +246,7 @@ static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock *iface, REFERENCE_
return E_POINTER; return E_POINTER;
} }
ret = get_current_time(clock); ret = get_current_time();
EnterCriticalSection(&clock->cs); EnterCriticalSection(&clock->cs);
...@@ -346,7 +342,6 @@ HRESULT system_clock_create(IUnknown *outer, IUnknown **out) ...@@ -346,7 +342,6 @@ HRESULT system_clock_create(IUnknown *outer, IUnknown **out)
list_init(&object->sinks); list_init(&object->sinks);
InitializeCriticalSection(&object->cs); InitializeCriticalSection(&object->cs);
object->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SystemClockImpl.cs"); object->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SystemClockImpl.cs");
QueryPerformanceFrequency(&object->frequency);
TRACE("Created system clock %p.\n", object); TRACE("Created system clock %p.\n", object);
*out = &object->IUnknown_inner; *out = &object->IUnknown_inner;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment