1 /* IDirectMusicSynth8 Implementation
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmsynth_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
24 static inline IDirectMusicSynth8Impl *impl_from_IDirectMusicSynth8(IDirectMusicSynth8 *iface)
26 return CONTAINING_RECORD(iface, IDirectMusicSynth8Impl, IDirectMusicSynth8_iface);
29 /* IDirectMusicSynth8Impl IUnknown part: */
30 static HRESULT WINAPI IDirectMusicSynth8Impl_QueryInterface(LPDIRECTMUSICSYNTH8 iface, REFIID riid, LPVOID *ppobj)
32 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
34 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
36 if (IsEqualIID (riid, &IID_IUnknown) ||
37 IsEqualIID (riid, &IID_IDirectMusicSynth) ||
38 IsEqualIID (riid, &IID_IDirectMusicSynth8)) {
39 IUnknown_AddRef(iface);
43 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
47 static ULONG WINAPI IDirectMusicSynth8Impl_AddRef(LPDIRECTMUSICSYNTH8 iface)
49 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
50 ULONG refCount = InterlockedIncrement(&This->ref);
52 TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
59 static ULONG WINAPI IDirectMusicSynth8Impl_Release(LPDIRECTMUSICSYNTH8 iface)
61 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
62 ULONG refCount = InterlockedDecrement(&This->ref);
64 TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
67 HeapFree(GetProcessHeap(), 0, This);
70 DMSYNTH_UnlockModule();
75 /* IDirectMusicSynth8Impl IDirectMusicSynth part: */
76 static HRESULT WINAPI IDirectMusicSynth8Impl_Open(LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTPARAMS pPortParams)
78 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
80 FIXME("(%p)->(%p): stub\n", This, pPortParams);
85 static HRESULT WINAPI IDirectMusicSynth8Impl_Close(LPDIRECTMUSICSYNTH8 iface)
87 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
89 FIXME("(%p)->(): stub\n", This);
94 static HRESULT WINAPI IDirectMusicSynth8Impl_SetNumChannelGroups(LPDIRECTMUSICSYNTH8 iface, DWORD groups)
96 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
98 FIXME("(%p->(%d): stub\n", This, groups);
103 static HRESULT WINAPI IDirectMusicSynth8Impl_Download(LPDIRECTMUSICSYNTH8 iface, LPHANDLE hDownload, LPVOID data, LPBOOL free)
105 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
107 FIXME("(%p)->(%p, %p, %p): stub\n", This, hDownload, data, free);
112 static HRESULT WINAPI IDirectMusicSynth8Impl_Unload(LPDIRECTMUSICSYNTH8 iface, HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData)
114 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
116 FIXME("(%p)->(%p, %p, %p): stub\n", This, hDownload, lpFreeHandle, hUserData);
121 static HRESULT WINAPI IDirectMusicSynth8Impl_PlayBuffer(LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, LPBYTE buffer, DWORD size)
123 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
125 FIXME("(%p)->(0x%s, %p, %u): stub\n", This, wine_dbgstr_longlong(rt), buffer, size);
130 static HRESULT WINAPI IDirectMusicSynth8Impl_GetRunningStats(LPDIRECTMUSICSYNTH8 iface, LPDMUS_SYNTHSTATS stats)
132 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
134 FIXME("(%p)->(%p): stub\n", This, stats);
139 static HRESULT WINAPI IDirectMusicSynth8Impl_GetPortCaps(LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTCAPS caps)
141 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
143 TRACE("(%p)->(%p)\n", This, caps);
150 static HRESULT WINAPI IDirectMusicSynth8Impl_SetMasterClock(LPDIRECTMUSICSYNTH8 iface, IReferenceClock* clock)
152 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
154 FIXME("(%p)->(%p): stub\n", This, clock);
159 static HRESULT WINAPI IDirectMusicSynth8Impl_GetLatencyClock(LPDIRECTMUSICSYNTH8 iface, IReferenceClock** clock)
161 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
163 TRACE("(%p)->(%p)\n", This, clock);
165 *clock = This->pLatencyClock;
170 static HRESULT WINAPI IDirectMusicSynth8Impl_Activate(LPDIRECTMUSICSYNTH8 iface, BOOL enable)
172 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
174 TRACE("(%p)->(%d)\n", This, enable);
176 This->fActive = enable;
181 static HRESULT WINAPI IDirectMusicSynth8Impl_SetSynthSink(LPDIRECTMUSICSYNTH8 iface, IDirectMusicSynthSink* synth_sink)
183 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
185 TRACE("(%p)->(%p)\n", This, synth_sink);
187 This->pSynthSink = (IDirectMusicSynthSinkImpl*)synth_sink;
192 static HRESULT WINAPI IDirectMusicSynth8Impl_Render(LPDIRECTMUSICSYNTH8 iface, short* buffer, DWORD length, LONGLONG position)
194 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
196 FIXME("(%p)->(%p, %d, 0x%s): stub\n", This, buffer, length, wine_dbgstr_longlong(position));
201 static HRESULT WINAPI IDirectMusicSynth8Impl_SetChannelPriority(LPDIRECTMUSICSYNTH8 iface, DWORD channel_group, DWORD channel, DWORD priority)
203 /* IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface); */
205 /* Silenced because of too many messages - 1000 groups * 16 channels ;=) */
206 /* FIXME("(%p)->(%ld, %ld, %ld): stub\n", This, channel_group, channel, priority); */
211 static HRESULT WINAPI IDirectMusicSynth8Impl_GetChannelPriority(LPDIRECTMUSICSYNTH8 iface, DWORD channel_group, DWORD channel, LPDWORD priority)
213 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
215 FIXME("(%p)->(%d, %d, %p): stub\n", This, channel_group, channel, priority);
220 static HRESULT WINAPI IDirectMusicSynth8Impl_GetFormat(LPDIRECTMUSICSYNTH8 iface, LPWAVEFORMATEX wave_format, LPDWORD wave_format_size)
222 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
224 FIXME("(%p)->(%p, %p): stub\n", This, wave_format, wave_format_size);
229 static HRESULT WINAPI IDirectMusicSynth8Impl_GetAppend(LPDIRECTMUSICSYNTH8 iface, DWORD* append)
231 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
233 FIXME("(%p)->(%p): stub\n", This, append);
238 /* IDirectMusicSynth8Impl IDirectMusicSynth8 part: */
239 static HRESULT WINAPI IDirectMusicSynth8Impl_PlayVoice(LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME ref_time, DWORD voice_id, DWORD channel_group, DWORD channel,
240 DWORD dwDLId, LONG prPitch, LONG vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd)
242 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
244 FIXME("(%p)->(0x%s, %d, %d, %d, %d, %i, %i,0x%s, 0x%s, 0x%s): stub\n",
245 This, wine_dbgstr_longlong(ref_time), voice_id, channel_group, channel, dwDLId, prPitch, vrVolume,
246 wine_dbgstr_longlong(stVoiceStart), wine_dbgstr_longlong(stLoopStart), wine_dbgstr_longlong(stLoopEnd));
251 static HRESULT WINAPI IDirectMusicSynth8Impl_StopVoice(LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME ref_time, DWORD voice_id)
253 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
255 FIXME("(%p)->(0x%s, %d): stub\n", This, wine_dbgstr_longlong(ref_time), voice_id);
260 static HRESULT WINAPI IDirectMusicSynth8Impl_GetVoiceState(LPDIRECTMUSICSYNTH8 iface, DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[])
262 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
264 FIXME("(%p)->(%p, %d, %p): stub\n", This, dwVoice, cbVoice, dwVoiceState);
269 static HRESULT WINAPI IDirectMusicSynth8Impl_Refresh(LPDIRECTMUSICSYNTH8 iface, DWORD download_id, DWORD flags)
271 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
273 FIXME("(%p)->(%d, %d): stub\n", This, download_id, flags);
278 static HRESULT WINAPI IDirectMusicSynth8Impl_AssignChannelToBuses(LPDIRECTMUSICSYNTH8 iface, DWORD channel_group, DWORD channel, LPDWORD pdwBuses, DWORD cBuses)
280 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
282 FIXME("(%p)->(%d, %d, %p, %d): stub\n", This, channel_group, channel, pdwBuses, cBuses);
287 static const IDirectMusicSynth8Vtbl DirectMusicSynth8_Vtbl = {
288 IDirectMusicSynth8Impl_QueryInterface,
289 IDirectMusicSynth8Impl_AddRef,
290 IDirectMusicSynth8Impl_Release,
291 IDirectMusicSynth8Impl_Open,
292 IDirectMusicSynth8Impl_Close,
293 IDirectMusicSynth8Impl_SetNumChannelGroups,
294 IDirectMusicSynth8Impl_Download,
295 IDirectMusicSynth8Impl_Unload,
296 IDirectMusicSynth8Impl_PlayBuffer,
297 IDirectMusicSynth8Impl_GetRunningStats,
298 IDirectMusicSynth8Impl_GetPortCaps,
299 IDirectMusicSynth8Impl_SetMasterClock,
300 IDirectMusicSynth8Impl_GetLatencyClock,
301 IDirectMusicSynth8Impl_Activate,
302 IDirectMusicSynth8Impl_SetSynthSink,
303 IDirectMusicSynth8Impl_Render,
304 IDirectMusicSynth8Impl_SetChannelPriority,
305 IDirectMusicSynth8Impl_GetChannelPriority,
306 IDirectMusicSynth8Impl_GetFormat,
307 IDirectMusicSynth8Impl_GetAppend,
308 IDirectMusicSynth8Impl_PlayVoice,
309 IDirectMusicSynth8Impl_StopVoice,
310 IDirectMusicSynth8Impl_GetVoiceState,
311 IDirectMusicSynth8Impl_Refresh,
312 IDirectMusicSynth8Impl_AssignChannelToBuses
315 /* for ClassFactory */
316 HRESULT WINAPI DMUSIC_CreateDirectMusicSynthImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter)
318 IDirectMusicSynth8Impl *obj;
320 TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
321 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynth8Impl));
324 return E_OUTOFMEMORY;
326 obj->IDirectMusicSynth8_iface.lpVtbl = &DirectMusicSynth8_Vtbl;
329 obj->pCaps.dwSize = sizeof(DMUS_PORTCAPS);
330 obj->pCaps.dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
331 obj->pCaps.guidPort = CLSID_DirectMusicSynth;
332 obj->pCaps.dwClass = DMUS_PC_OUTPUTCLASS;
333 obj->pCaps.dwType = DMUS_PORT_USER_MODE_SYNTH;
334 obj->pCaps.dwMemorySize = DMUS_PC_SYSTEMMEMORY;
335 obj->pCaps.dwMaxChannelGroups = 1000;
336 obj->pCaps.dwMaxVoices = 1000;
337 obj->pCaps.dwMaxAudioChannels = 2;
338 obj->pCaps.dwEffectFlags = DMUS_EFFECT_REVERB;
339 MultiByteToWideChar (CP_ACP, 0, "Microsoft Synthesizer", -1, obj->pCaps.wszDescription, sizeof(obj->pCaps.wszDescription)/sizeof(WCHAR));
340 /* assign latency clock */
341 /*DMUSIC_CreateReferenceClockImpl (&IID_IReferenceClock, (LPVOID*)&This->pLatencyClock, NULL); */
343 return IDirectMusicSynth8Impl_QueryInterface ((LPDIRECTMUSICSYNTH8)obj, lpcGUID, ppobj);