#include "quartz_private.h"
-#include "wine/debug.h"
-#include "wine/unicode.h"
-#include <assert.h>
+#include <wine/debug.h>
+//#include "wine/unicode.h"
+//#include <assert.h>
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
};
typedef struct SystemClockImpl {
- const IReferenceClockVtbl *lpVtbl;
+ IReferenceClock IReferenceClock_iface;
LONG ref;
/** IReferenceClock */
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;
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;
}
/** First SingleShots Advice: sorted list */
- for (it = This->pSingleShotAdvise; NULL != it && (it->rtBaseTime + it->rtIntervalTime) <= curTime; it = it->next) {
+ it = This->pSingleShotAdvise;
+ while ((NULL != it) && (it->rtBaseTime + it->rtIntervalTime) <= curTime) {
+ SystemClockAdviseEntry* nextit = it->next;
/** send event ... */
SetEvent(it->hEvent);
/** ... and Release it */
QUARTZ_RemoveAviseEntryFromQueue(This, it);
CoTaskMemFree(it);
+ it = nextit;
}
if (NULL != it) timeOut = (DWORD) ((it->rtBaseTime + it->rtIntervalTime) - curTime) / (REFERENCE_TIME)10000;
outrefresh:
LeaveCriticalSection(&This->safe);
- while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) {
+ while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
/** if hwnd we suppose that is a windows event ... */
if (NULL != msg.hwnd) {
TranslateMessage(&msg);
- DispatchMessageA(&msg);
+ DispatchMessageW(&msg);
} else {
switch (msg.message) {
case WM_QUIT:
SetThreadPriority(This->adviseThread, THREAD_PRIORITY_TIME_CRITICAL);
This->adviseThreadActive = TRUE;
while(1) {
- res = PostThreadMessageA(This->adviseThreadId, iMsg, 0, 0);
+ res = PostThreadMessageW(This->adviseThreadId, iMsg, 0, 0);
/* Let the thread creates its message queue (with MsgWaitForMultipleObjects call) by yielding and retrying */
if (!res && (GetLastError() == ERROR_INVALID_THREAD_ID))
Sleep(0);
}
return res;
}
- return PostThreadMessageA(This->adviseThreadId, iMsg, 0, 0);
+ return PostThreadMessageW(This->adviseThreadId, iMsg, 0, 0);
}
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);
}
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) ||
}
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) {
}
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;
}
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),
}
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),
}
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;
}
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);
}