d3dx9/tests: Add basic tests for ID3DXRenderToEnvMap.
[wine/multimedia.git] / dlls / dmusic / clock.c
blob4d9a1b40454668f1051c91efac18f3a56fa31124
1 /*
2 * IReferenceClock Implementation
4 * Copyright (C) 2003-2004 Rok Mandeljc
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "dmusic_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
25 static inline IReferenceClockImpl *impl_from_IReferenceClock(IReferenceClock *iface)
27 return CONTAINING_RECORD(iface, IReferenceClockImpl, IReferenceClock_iface);
30 /* IReferenceClockImpl IUnknown part: */
31 static HRESULT WINAPI IReferenceClockImpl_QueryInterface(IReferenceClock *iface, REFIID riid, LPVOID *ppobj)
33 IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
34 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
36 if (IsEqualIID (riid, &IID_IUnknown) ||
37 IsEqualIID (riid, &IID_IReferenceClock)) {
38 IUnknown_AddRef(iface);
39 *ppobj = This;
40 return S_OK;
42 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
43 return E_NOINTERFACE;
46 static ULONG WINAPI IReferenceClockImpl_AddRef(IReferenceClock *iface)
48 IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
49 ULONG refCount = InterlockedIncrement(&This->ref);
51 TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
53 DMUSIC_LockModule();
55 return refCount;
58 static ULONG WINAPI IReferenceClockImpl_Release(IReferenceClock *iface)
60 IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
61 ULONG refCount = InterlockedDecrement(&This->ref);
63 TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
65 if (!refCount) {
66 HeapFree(GetProcessHeap(), 0, This);
69 DMUSIC_UnlockModule();
71 return refCount;
74 /* IReferenceClockImpl IReferenceClock part: */
75 static HRESULT WINAPI IReferenceClockImpl_GetTime(IReferenceClock *iface, REFERENCE_TIME* pTime)
77 IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
79 TRACE("(%p)->(%p)\n", This, pTime);
81 *pTime = This->rtTime;
83 return S_OK;
86 static HRESULT WINAPI IReferenceClockImpl_AdviseTime(IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie)
88 IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
90 FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(baseTime), wine_dbgstr_longlong(streamTime), hEvent, pdwAdviseCookie);
92 return S_OK;
95 static HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie)
97 IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
99 FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(startTime), wine_dbgstr_longlong(periodTime), hSemaphore, pdwAdviseCookie);
101 return S_OK;
104 static HRESULT WINAPI IReferenceClockImpl_Unadvise(IReferenceClock *iface, DWORD dwAdviseCookie)
106 IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
108 FIXME("(%p)->(%d): stub\n", This, dwAdviseCookie);
110 return S_OK;
113 static const IReferenceClockVtbl ReferenceClock_Vtbl = {
114 IReferenceClockImpl_QueryInterface,
115 IReferenceClockImpl_AddRef,
116 IReferenceClockImpl_Release,
117 IReferenceClockImpl_GetTime,
118 IReferenceClockImpl_AdviseTime,
119 IReferenceClockImpl_AdvisePeriodic,
120 IReferenceClockImpl_Unadvise
123 /* for ClassFactory */
124 HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
126 IReferenceClockImpl* clock;
128 TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
130 clock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IReferenceClockImpl));
131 if (!clock) {
132 *ret_iface = NULL;
133 return E_OUTOFMEMORY;
136 clock->IReferenceClock_iface.lpVtbl = &ReferenceClock_Vtbl;
137 clock->ref = 0; /* Will be inited by QueryInterface */
138 clock->rtTime = 0;
139 clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
141 return IReferenceClockImpl_QueryInterface((IReferenceClock*)clock, riid, ret_iface);