Zebediah Figura : quartz/systemclock: Simplify SystemClockImpl_GetTime().
Alexandre Julliard
julliard at winehq.org
Wed Mar 13 18:10:51 CDT 2019
Module: wine
Branch: master
Commit: 9068ad0f0935ff512ff9f0277cf5d988ff8e86f0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9068ad0f0935ff512ff9f0277cf5d988ff8e86f0
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Wed Mar 13 09:54:05 2019 -0500
quartz/systemclock: Simplify SystemClockImpl_GetTime().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/quartz/systemclock.c | 38 +++++++++++++++++++-------------------
dlls/quartz/tests/systemclock.c | 4 ++--
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/dlls/quartz/systemclock.c b/dlls/quartz/systemclock.c
index 1638e11..c809ce4 100644
--- a/dlls/quartz/systemclock.c
+++ b/dlls/quartz/systemclock.c
@@ -44,8 +44,7 @@ typedef struct SystemClockImpl {
HANDLE adviseThread;
DWORD adviseThreadId;
BOOL adviseThreadActive;
- REFERENCE_TIME lastRefTime;
- DWORD lastTimeTickCount;
+ REFERENCE_TIME last_time;
CRITICAL_SECTION safe;
SystemClockAdviseEntry* pSingleShotAdvise;
@@ -240,26 +239,28 @@ static ULONG WINAPI SystemClockImpl_Release(IReferenceClock* iface) {
return ref;
}
-static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock* iface, REFERENCE_TIME* pTime) {
- SystemClockImpl *This = impl_from_IReferenceClock(iface);
- DWORD curTimeTickCount;
- HRESULT hr = S_OK;
+static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock *iface, REFERENCE_TIME *time)
+{
+ SystemClockImpl *clock = impl_from_IReferenceClock(iface);
+ REFERENCE_TIME ret;
+ HRESULT hr;
- TRACE("(%p, %p)\n", This, pTime);
+ TRACE("clock %p, time %p.\n", clock, time);
- if (NULL == pTime) {
- return E_POINTER;
- }
+ if (!time) {
+ return E_POINTER;
+ }
- curTimeTickCount = GetTickCount();
+ ret = GetTickCount64() * 10000;
- EnterCriticalSection(&This->safe);
- if (This->lastTimeTickCount == curTimeTickCount) hr = S_FALSE;
- This->lastRefTime += (REFERENCE_TIME) (DWORD) (curTimeTickCount - This->lastTimeTickCount) * (REFERENCE_TIME) 10000;
- This->lastTimeTickCount = curTimeTickCount;
- *pTime = This->lastRefTime;
- LeaveCriticalSection(&This->safe);
- return hr;
+ EnterCriticalSection(&clock->safe);
+
+ hr = (ret == clock->last_time) ? S_FALSE : S_OK;
+ *time = clock->last_time = ret;
+
+ LeaveCriticalSection(&clock->safe);
+
+ return hr;
}
static HRESULT WINAPI SystemClockImpl_AdviseTime(IReferenceClock* iface, REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime, HEVENT hEvent, DWORD_PTR* pdwAdviseCookie) {
@@ -389,7 +390,6 @@ HRESULT QUARTZ_CreateSystemClock(IUnknown * pUnkOuter, LPVOID * ppv) {
obj->IReferenceClock_iface.lpVtbl = &SystemClock_Vtbl;
obj->ref = 0; /* will be inited by QueryInterface */
- obj->lastTimeTickCount = GetTickCount();
InitializeCriticalSection(&obj->safe);
obj->safe.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SystemClockImpl.safe");
diff --git a/dlls/quartz/tests/systemclock.c b/dlls/quartz/tests/systemclock.c
index c960d98..258e198 100644
--- a/dlls/quartz/tests/systemclock.c
+++ b/dlls/quartz/tests/systemclock.c
@@ -77,10 +77,10 @@ static void test_get_time(void)
time2 = GetTickCount64() * 10000;
else
time2 = GetTickCount() * 10000;
- todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time1 % 10000 == 0, "Expected no less than 1ms coarseness, but got time %s.\n",
wine_dbgstr_longlong(time1));
- todo_wine ok(abs(time1 - time2) < 20 * 10000, "Expected about %s, got %s.\n",
+ ok(abs(time1 - time2) < 20 * 10000, "Expected about %s, got %s.\n",
wine_dbgstr_longlong(time2), wine_dbgstr_longlong(time1));
hr = IReferenceClock_GetTime(clock, &time2);
More information about the wine-cvs
mailing list