msi: Implement the RemoveExistingProducts standard action.
[wine/multimedia.git] / dlls / dmsynth / synthsink.c
bloba63f36c3961bbbab2aaeee9f8e27899023a18ef4
1 /*
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"
22 #include "initguid.h"
23 #include "uuids.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 *ret_iface)
35 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
37 TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
39 if (IsEqualIID (riid, &IID_IUnknown) ||
40 IsEqualIID (riid, &IID_IDirectMusicSynthSink))
42 IUnknown_AddRef(iface);
43 *ret_iface = iface;
44 return S_OK;
46 else if (IsEqualIID(riid, &IID_IKsControl))
48 IUnknown_AddRef(iface);
49 *ret_iface = &This->IKsControl_iface;
50 return S_OK;
53 *ret_iface = NULL;
55 WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
57 return E_NOINTERFACE;
60 static ULONG WINAPI IDirectMusicSynthSinkImpl_AddRef(LPDIRECTMUSICSYNTHSINK iface)
62 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
63 ULONG ref = InterlockedIncrement(&This->ref);
65 TRACE("(%p)->(): new ref = %u\n", This, ref);
67 DMSYNTH_LockModule();
69 return ref;
72 static ULONG WINAPI IDirectMusicSynthSinkImpl_Release(LPDIRECTMUSICSYNTHSINK iface)
74 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
75 ULONG ref = InterlockedDecrement(&This->ref);
77 TRACE("(%p)->(): new ref = %u\n", This, ref);
79 if (!ref) {
80 if (This->latency_clock)
81 IReferenceClock_Release(This->latency_clock);
82 HeapFree(GetProcessHeap(), 0, This);
85 DMSYNTH_UnlockModule();
87 return ref;
90 /* IDirectMusicSynthSinkImpl IDirectMusicSynthSink part: */
91 static HRESULT WINAPI IDirectMusicSynthSinkImpl_Init(LPDIRECTMUSICSYNTHSINK iface, IDirectMusicSynth* synth)
93 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
95 FIXME("(%p)->(%p): stub\n", This, synth);
97 return S_OK;
100 static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetMasterClock(LPDIRECTMUSICSYNTHSINK iface, IReferenceClock* clock)
102 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
104 FIXME("(%p)->(%p): stub\n", This, clock);
106 return S_OK;
109 static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock(LPDIRECTMUSICSYNTHSINK iface, IReferenceClock** clock)
111 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
113 TRACE("(%p)->(%p)\n", iface, clock);
115 if (!clock)
116 return E_POINTER;
118 *clock = This->latency_clock;
119 IReferenceClock_AddRef(This->latency_clock);
121 return S_OK;
124 static HRESULT WINAPI IDirectMusicSynthSinkImpl_Activate(LPDIRECTMUSICSYNTHSINK iface, BOOL enable)
126 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
128 FIXME("(%p)->(%d): stub\n", This, enable);
130 return S_OK;
133 static HRESULT WINAPI IDirectMusicSynthSinkImpl_SampleToRefTime(LPDIRECTMUSICSYNTHSINK iface, LONGLONG sample_time, REFERENCE_TIME* ref_time)
135 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
137 FIXME("(%p)->(0x%s, %p): stub\n", This, wine_dbgstr_longlong(sample_time), ref_time);
139 return S_OK;
142 static HRESULT WINAPI IDirectMusicSynthSinkImpl_RefTimeToSample(LPDIRECTMUSICSYNTHSINK iface, REFERENCE_TIME ref_time, LONGLONG* sample_time)
144 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
146 FIXME("(%p)->(0x%s, %p): stub\n", This, wine_dbgstr_longlong(ref_time), sample_time);
148 return S_OK;
151 static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound(LPDIRECTMUSICSYNTHSINK iface, LPDIRECTSOUND dsound, LPDIRECTSOUNDBUFFER dsound_buffer)
153 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
155 FIXME("(%p)->(%p, %p): stub\n", This, dsound, dsound_buffer);
157 return S_OK;
160 static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize(LPDIRECTMUSICSYNTHSINK iface, LPDWORD buffer_size_in_samples)
162 IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
164 FIXME("(%p)->(%p): stub\n", This, buffer_size_in_samples);
166 return S_OK;
169 static const IDirectMusicSynthSinkVtbl DirectMusicSynthSink_Vtbl = {
170 IDirectMusicSynthSinkImpl_QueryInterface,
171 IDirectMusicSynthSinkImpl_AddRef,
172 IDirectMusicSynthSinkImpl_Release,
173 IDirectMusicSynthSinkImpl_Init,
174 IDirectMusicSynthSinkImpl_SetMasterClock,
175 IDirectMusicSynthSinkImpl_GetLatencyClock,
176 IDirectMusicSynthSinkImpl_Activate,
177 IDirectMusicSynthSinkImpl_SampleToRefTime,
178 IDirectMusicSynthSinkImpl_RefTimeToSample,
179 IDirectMusicSynthSinkImpl_SetDirectSound,
180 IDirectMusicSynthSinkImpl_GetDesiredBufferSize
183 static inline IDirectMusicSynthSinkImpl *impl_from_IKsControl(IKsControl *iface)
185 return CONTAINING_RECORD(iface, IDirectMusicSynthSinkImpl, IKsControl_iface);
188 static HRESULT WINAPI DMSynthSinkImpl_IKsControl_QueryInterface(IKsControl* iface, REFIID riid, LPVOID *ppobj)
190 IDirectMusicSynthSinkImpl *This = impl_from_IKsControl(iface);
192 return IDirectMusicSynthSinkImpl_QueryInterface(&This->IDirectMusicSynthSink_iface, riid, ppobj);
195 static ULONG WINAPI DMSynthSinkImpl_IKsControl_AddRef(IKsControl* iface)
197 IDirectMusicSynthSinkImpl *This = impl_from_IKsControl(iface);
199 return IDirectMusicSynthSinkImpl_AddRef(&This->IDirectMusicSynthSink_iface);
202 static ULONG WINAPI DMSynthSinkImpl_IKsControl_Release(IKsControl* iface)
204 IDirectMusicSynthSinkImpl *This = impl_from_IKsControl(iface);
206 return IDirectMusicSynthSinkImpl_Release(&This->IDirectMusicSynthSink_iface);
209 static HRESULT WINAPI DMSynthSinkImpl_IKsControl_KsProperty(IKsControl* iface, PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData,
210 ULONG DataLength, ULONG* BytesReturned)
212 FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Property, PropertyLength, PropertyData, DataLength, BytesReturned);
214 return E_NOTIMPL;
217 static HRESULT WINAPI DMSynthSinkImpl_IKsControl_KsMethod(IKsControl* iface, PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData,
218 ULONG DataLength, ULONG* BytesReturned)
220 FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Method, MethodLength, MethodData, DataLength, BytesReturned);
222 return E_NOTIMPL;
225 static HRESULT WINAPI DMSynthSinkImpl_IKsControl_KsEvent(IKsControl* iface, PKSEVENT Event, ULONG EventLength, LPVOID EventData,
226 ULONG DataLength, ULONG* BytesReturned)
228 FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Event, EventLength, EventData, DataLength, BytesReturned);
230 return E_NOTIMPL;
234 static const IKsControlVtbl DMSynthSinkImpl_IKsControl_Vtbl = {
235 DMSynthSinkImpl_IKsControl_QueryInterface,
236 DMSynthSinkImpl_IKsControl_AddRef,
237 DMSynthSinkImpl_IKsControl_Release,
238 DMSynthSinkImpl_IKsControl_KsProperty,
239 DMSynthSinkImpl_IKsControl_KsMethod,
240 DMSynthSinkImpl_IKsControl_KsEvent
243 /* for ClassFactory */
244 HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSinkImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
246 IDirectMusicSynthSinkImpl *obj;
247 HRESULT hr;
249 TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
251 *ret_iface = NULL;
253 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynthSinkImpl));
254 if (!obj)
255 return E_OUTOFMEMORY;
257 obj->IDirectMusicSynthSink_iface.lpVtbl = &DirectMusicSynthSink_Vtbl;
258 obj->IKsControl_iface.lpVtbl = &DMSynthSinkImpl_IKsControl_Vtbl;
259 obj->ref = 0;
261 hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&obj->latency_clock);
262 if (FAILED(hr))
264 HeapFree(GetProcessHeap(), 0, obj);
265 return hr;
268 hr = IDirectMusicSynthSinkImpl_QueryInterface((LPDIRECTMUSICSYNTHSINK)obj, riid, ret_iface);
269 if (FAILED(hr))
271 IReferenceClock_Release(obj->latency_clock);
272 HeapFree(GetProcessHeap(), 0, obj);
273 return hr;
276 return S_OK;