2 * IDirectMusicSynthSink 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 "dmsynth_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
27 static inline IDirectMusicSynthSinkImpl *impl_from_IDirectMusicSynthSink(IDirectMusicSynthSink *iface)
29 return CONTAINING_RECORD(iface, IDirectMusicSynthSinkImpl, IDirectMusicSynthSink_iface);
32 /* IDirectMusicSynthSinkImpl IUnknown part: */
33 static HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface(LPDIRECTMUSICSYNTHSINK iface, REFIID riid, LPVOID *ppobj)
35 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
36 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
38 if (IsEqualIID (riid, &IID_IUnknown) ||
39 IsEqualIID (riid, &IID_IDirectMusicSynthSink)) {
40 IUnknown_AddRef(iface);
44 else if (IsEqualIID(riid, &IID_IKsControl)) {
45 IUnknown_AddRef(iface);
46 *ppobj = &This->IKsControl_iface;
50 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
54 static ULONG WINAPI IDirectMusicSynthSinkImpl_AddRef(LPDIRECTMUSICSYNTHSINK iface)
56 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
57 ULONG refCount = InterlockedIncrement(&This->ref);
59 TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
66 static ULONG WINAPI IDirectMusicSynthSinkImpl_Release(LPDIRECTMUSICSYNTHSINK iface)
68 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
69 ULONG refCount = InterlockedDecrement(&This->ref);
71 TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
74 if (This->latency_clock)
75 IReferenceClock_Release(This->latency_clock);
76 HeapFree(GetProcessHeap(), 0, This);
79 DMSYNTH_UnlockModule();
84 /* IDirectMusicSynthSinkImpl IDirectMusicSynthSink part: */
85 static HRESULT WINAPI IDirectMusicSynthSinkImpl_Init(LPDIRECTMUSICSYNTHSINK iface, IDirectMusicSynth* synth)
87 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
89 FIXME("(%p)->(%p): stub\n", This, synth);
94 static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetMasterClock(LPDIRECTMUSICSYNTHSINK iface, IReferenceClock* clock)
96 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
98 FIXME("(%p)->(%p): stub\n", This, clock);
103 static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock(LPDIRECTMUSICSYNTHSINK iface, IReferenceClock** clock)
105 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
107 TRACE("(%p)->(%p)\n", iface, clock);
112 *clock = This->latency_clock;
113 IReferenceClock_AddRef(This->latency_clock);
118 static HRESULT WINAPI IDirectMusicSynthSinkImpl_Activate(LPDIRECTMUSICSYNTHSINK iface, BOOL enable)
120 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
122 FIXME("(%p)->(%d): stub\n", This, enable);
127 static HRESULT WINAPI IDirectMusicSynthSinkImpl_SampleToRefTime(LPDIRECTMUSICSYNTHSINK iface, LONGLONG sample_time, REFERENCE_TIME* ref_time)
129 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
131 FIXME("(%p)->(0x%s, %p): stub\n", This, wine_dbgstr_longlong(sample_time), ref_time);
136 static HRESULT WINAPI IDirectMusicSynthSinkImpl_RefTimeToSample(LPDIRECTMUSICSYNTHSINK iface, REFERENCE_TIME ref_time, LONGLONG* sample_time)
138 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
140 FIXME("(%p)->(0x%s, %p): stub\n", This, wine_dbgstr_longlong(ref_time), sample_time);
145 static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound(LPDIRECTMUSICSYNTHSINK iface, LPDIRECTSOUND dsound, LPDIRECTSOUNDBUFFER dsound_buffer)
147 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
149 FIXME("(%p)->(%p, %p): stub\n", This, dsound, dsound_buffer);
154 static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize(LPDIRECTMUSICSYNTHSINK iface, LPDWORD buffer_size_in_samples)
156 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
158 FIXME("(%p)->(%p): stub\n", This, buffer_size_in_samples);
163 static const IDirectMusicSynthSinkVtbl DirectMusicSynthSink_Vtbl = {
164 IDirectMusicSynthSinkImpl_QueryInterface,
165 IDirectMusicSynthSinkImpl_AddRef,
166 IDirectMusicSynthSinkImpl_Release,
167 IDirectMusicSynthSinkImpl_Init,
168 IDirectMusicSynthSinkImpl_SetMasterClock,
169 IDirectMusicSynthSinkImpl_GetLatencyClock,
170 IDirectMusicSynthSinkImpl_Activate,
171 IDirectMusicSynthSinkImpl_SampleToRefTime,
172 IDirectMusicSynthSinkImpl_RefTimeToSample,
173 IDirectMusicSynthSinkImpl_SetDirectSound,
174 IDirectMusicSynthSinkImpl_GetDesiredBufferSize
177 static inline IDirectMusicSynthSinkImpl *impl_from_IKsControl(IKsControl *iface)
179 return CONTAINING_RECORD(iface, IDirectMusicSynthSinkImpl, IKsControl_iface);
182 static HRESULT WINAPI DMSynthSinkImpl_IKsControl_QueryInterface(IKsControl* iface, REFIID riid, LPVOID *ppobj)
184 IDirectMusicSynthSinkImpl *This = impl_from_IKsControl(iface);
186 return IDirectMusicSynthSinkImpl_QueryInterface(&This->IDirectMusicSynthSink_iface, riid, ppobj);
189 static ULONG WINAPI DMSynthSinkImpl_IKsControl_AddRef(IKsControl* iface)
191 IDirectMusicSynthSinkImpl *This = impl_from_IKsControl(iface);
193 return IDirectMusicSynthSinkImpl_AddRef(&This->IDirectMusicSynthSink_iface);
196 static ULONG WINAPI DMSynthSinkImpl_IKsControl_Release(IKsControl* iface)
198 IDirectMusicSynthSinkImpl *This = impl_from_IKsControl(iface);
200 return IDirectMusicSynthSinkImpl_Release(&This->IDirectMusicSynthSink_iface);
203 static HRESULT WINAPI DMSynthSinkImpl_IKsControl_KsProperty(IKsControl* iface, PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData,
204 ULONG DataLength, ULONG* BytesReturned)
206 FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Property, PropertyLength, PropertyData, DataLength, BytesReturned);
211 static HRESULT WINAPI DMSynthSinkImpl_IKsControl_KsMethod(IKsControl* iface, PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData,
212 ULONG DataLength, ULONG* BytesReturned)
214 FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Method, MethodLength, MethodData, DataLength, BytesReturned);
219 static HRESULT WINAPI DMSynthSinkImpl_IKsControl_KsEvent(IKsControl* iface, PKSEVENT Event, ULONG EventLength, LPVOID EventData,
220 ULONG DataLength, ULONG* BytesReturned)
222 FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Event, EventLength, EventData, DataLength, BytesReturned);
228 static const IKsControlVtbl DMSynthSinkImpl_IKsControl_Vtbl = {
229 DMSynthSinkImpl_IKsControl_QueryInterface,
230 DMSynthSinkImpl_IKsControl_AddRef,
231 DMSynthSinkImpl_IKsControl_Release,
232 DMSynthSinkImpl_IKsControl_KsProperty,
233 DMSynthSinkImpl_IKsControl_KsMethod,
234 DMSynthSinkImpl_IKsControl_KsEvent
237 /* for ClassFactory */
238 HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSinkImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
240 IDirectMusicSynthSinkImpl *obj;
243 TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
247 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynthSinkImpl));
249 return E_OUTOFMEMORY;
251 obj->IDirectMusicSynthSink_iface.lpVtbl = &DirectMusicSynthSink_Vtbl;
252 obj->IKsControl_iface.lpVtbl = &DMSynthSinkImpl_IKsControl_Vtbl;
255 hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&obj->latency_clock);
258 HeapFree(GetProcessHeap(), 0, obj);
262 hr = IDirectMusicSynthSinkImpl_QueryInterface((LPDIRECTMUSICSYNTHSINK)obj, riid, ret_iface);
265 IReferenceClock_Release(obj->latency_clock);
266 HeapFree(GetProcessHeap(), 0, obj);