quartz: Use an iface instead of a vtbl pointer in SystemClockImpl.

This commit is contained in:
Michael Stefaniuc 2010-12-08 22:59:35 +01:00 committed by Alexandre Julliard
parent e86dff725f
commit 9a0f38e211
1 changed files with 16 additions and 11 deletions

View File

@ -37,7 +37,7 @@ struct SystemClockAdviseEntry {
};
typedef struct SystemClockImpl {
const IReferenceClockVtbl *lpVtbl;
IReferenceClock IReferenceClock_iface;
LONG ref;
/** IReferenceClock */
@ -52,6 +52,11 @@ typedef struct SystemClockImpl {
SystemClockAdviseEntry* pPeriodicAdvise;
} SystemClockImpl;
static inline SystemClockImpl *impl_from_IReferenceClock(IReferenceClock *iface)
{
return CONTAINING_RECORD(iface, SystemClockImpl, IReferenceClock_iface);
}
static void QUARTZ_RemoveAviseEntryFromQueue(SystemClockImpl* This, SystemClockAdviseEntry* pEntry) {
if (pEntry->prev) pEntry->prev->next = pEntry->next;
@ -104,7 +109,7 @@ static DWORD WINAPI SystemClockAdviseThread(LPVOID lpParam) {
EnterCriticalSection(&This->safe);
/*timeOut = IReferenceClock_OnTimerUpdated(This); */
hr = IReferenceClock_GetTime((IReferenceClock*) This, &curTime);
hr = IReferenceClock_GetTime(&This->IReferenceClock_iface, &curTime);
if (FAILED(hr)) {
timeOut = INFINITE;
goto outrefresh;
@ -191,7 +196,7 @@ static BOOL SystemClockPostMessageToAdviseThread(SystemClockImpl* This, UINT iMs
}
static ULONG WINAPI SystemClockImpl_AddRef(IReferenceClock* iface) {
SystemClockImpl *This = (SystemClockImpl *)iface;
SystemClockImpl *This = impl_from_IReferenceClock(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p): AddRef from %d\n", This, ref - 1);
@ -200,7 +205,7 @@ static ULONG WINAPI SystemClockImpl_AddRef(IReferenceClock* iface) {
}
static HRESULT WINAPI SystemClockImpl_QueryInterface(IReferenceClock* iface, REFIID riid, void** ppobj) {
SystemClockImpl *This = (SystemClockImpl *)iface;
SystemClockImpl *This = impl_from_IReferenceClock(iface);
TRACE("(%p, %s,%p)\n", This, debugstr_guid(riid), ppobj);
if (IsEqualIID (riid, &IID_IUnknown) ||
@ -216,7 +221,7 @@ static HRESULT WINAPI SystemClockImpl_QueryInterface(IReferenceClock* iface, REF
}
static ULONG WINAPI SystemClockImpl_Release(IReferenceClock* iface) {
SystemClockImpl *This = (SystemClockImpl *)iface;
SystemClockImpl *This = impl_from_IReferenceClock(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p): ReleaseRef to %d\n", This, ref);
if (ref == 0) {
@ -232,7 +237,7 @@ static ULONG WINAPI SystemClockImpl_Release(IReferenceClock* iface) {
}
static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock* iface, REFERENCE_TIME* pTime) {
SystemClockImpl *This = (SystemClockImpl *)iface;
SystemClockImpl *This = impl_from_IReferenceClock(iface);
DWORD curTimeTickCount;
HRESULT hr = S_OK;
@ -254,7 +259,7 @@ static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock* iface, REFERENCE_
}
static HRESULT WINAPI SystemClockImpl_AdviseTime(IReferenceClock* iface, REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime, HEVENT hEvent, DWORD_PTR* pdwAdviseCookie) {
SystemClockImpl *This = (SystemClockImpl *)iface;
SystemClockImpl *This = impl_from_IReferenceClock(iface);
SystemClockAdviseEntry* pEntry = NULL;
TRACE("(%p, 0x%s, 0x%s, %ld, %p)\n", This, wine_dbgstr_longlong(rtBaseTime),
@ -290,7 +295,7 @@ static HRESULT WINAPI SystemClockImpl_AdviseTime(IReferenceClock* iface, REFEREN
}
static HRESULT WINAPI SystemClockImpl_AdvisePeriodic(IReferenceClock* iface, REFERENCE_TIME rtStartTime, REFERENCE_TIME rtPeriodTime, HSEMAPHORE hSemaphore, DWORD_PTR* pdwAdviseCookie) {
SystemClockImpl *This = (SystemClockImpl *)iface;
SystemClockImpl *This = impl_from_IReferenceClock(iface);
SystemClockAdviseEntry* pEntry = NULL;
TRACE("(%p, 0x%s, 0x%s, %ld, %p)\n", This, wine_dbgstr_longlong(rtStartTime),
@ -326,7 +331,7 @@ static HRESULT WINAPI SystemClockImpl_AdvisePeriodic(IReferenceClock* iface, REF
}
static HRESULT WINAPI SystemClockImpl_Unadvise(IReferenceClock* iface, DWORD_PTR dwAdviseCookie) {
SystemClockImpl *This = (SystemClockImpl *)iface;
SystemClockImpl *This = impl_from_IReferenceClock(iface);
SystemClockAdviseEntry* pEntry = NULL;
SystemClockAdviseEntry* it = NULL;
HRESULT ret = S_OK;
@ -377,12 +382,12 @@ HRESULT QUARTZ_CreateSystemClock(IUnknown * pUnkOuter, LPVOID * ppv) {
}
ZeroMemory(obj, sizeof(SystemClockImpl));
obj->lpVtbl = &SystemClock_Vtbl;
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");
return SystemClockImpl_QueryInterface((IReferenceClock*) obj, &IID_IReferenceClock, ppv);
return SystemClockImpl_QueryInterface(&obj->IReferenceClock_iface, &IID_IReferenceClock, ppv);
}