Updated.
[wine/multimedia.git] / dlls / dmsynth / synth.c
blob5b89e66c26ea8858528b010055f7420f8cfff71e
1 /* IDirectMusicSynth8 Implementation
3 * Copyright (C) 2003 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (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
13 * GNU Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "wingdi.h"
26 #include "wine/debug.h"
27 #include "winnls.h"
29 #include "dmsynth_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
33 /* IDirectMusicSynth8 IUnknown part: */
34 HRESULT WINAPI IDirectMusicSynth8Impl_QueryInterface (LPDIRECTMUSICSYNTH8 iface, REFIID riid, LPVOID *ppobj)
36 ICOM_THIS(IDirectMusicSynth8Impl,iface);
38 if (IsEqualIID (riid, &IID_IUnknown) ||
39 IsEqualIID (riid, &IID_IDirectMusicSynth) ||
40 IsEqualIID (riid, &IID_IDirectMusicSynth8)) {
41 IDirectMusicSynth8Impl_AddRef(iface);
42 *ppobj = This;
43 return S_OK;
46 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
47 return E_NOINTERFACE;
50 ULONG WINAPI IDirectMusicSynth8Impl_AddRef (LPDIRECTMUSICSYNTH8 iface)
52 ICOM_THIS(IDirectMusicSynth8Impl,iface);
53 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
54 return ++(This->ref);
57 ULONG WINAPI IDirectMusicSynth8Impl_Release (LPDIRECTMUSICSYNTH8 iface)
59 ICOM_THIS(IDirectMusicSynth8Impl,iface);
60 ULONG ref = --This->ref;
61 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
62 if (ref == 0) {
63 HeapFree(GetProcessHeap(), 0, This);
65 return ref;
68 /* IDirectMusicSynth8 IDirectMusicSynth part: */
69 HRESULT WINAPI IDirectMusicSynth8Impl_Open (LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTPARAMS pPortParams)
71 ICOM_THIS(IDirectMusicSynth8Impl,iface);
73 FIXME("(%p, %p): stub\n", This, pPortParams);
75 return S_OK;
78 HRESULT WINAPI IDirectMusicSynth8Impl_Close (LPDIRECTMUSICSYNTH8 iface)
80 ICOM_THIS(IDirectMusicSynth8Impl,iface);
82 FIXME("(%p): stub\n", This);
84 return S_OK;
87 HRESULT WINAPI IDirectMusicSynth8Impl_SetNumChannelGroups (LPDIRECTMUSICSYNTH8 iface, DWORD dwGroups)
89 ICOM_THIS(IDirectMusicSynth8Impl,iface);
91 FIXME("(%p, %ld): stub\n", This, dwGroups);
93 return S_OK;
96 HRESULT WINAPI IDirectMusicSynth8Impl_Download (LPDIRECTMUSICSYNTH8 iface, LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree)
98 ICOM_THIS(IDirectMusicSynth8Impl,iface);
100 FIXME("(%p, %p, %p, %p): stub\n", This, phDownload, pvData, pbFree);
102 return S_OK;
105 HRESULT WINAPI IDirectMusicSynth8Impl_Unload (LPDIRECTMUSICSYNTH8 iface, HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData)
107 ICOM_THIS(IDirectMusicSynth8Impl,iface);
109 FIXME("(%p, %p, %p): stub\n", This, hDownload, hUserData);
111 return S_OK;
114 HRESULT WINAPI IDirectMusicSynth8Impl_PlayBuffer (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer)
116 ICOM_THIS(IDirectMusicSynth8Impl,iface);
118 FIXME("(%p, %lli, %p, %ld): stub\n", This, rt, pbBuffer, cbBuffer);
120 return S_OK;
123 HRESULT WINAPI IDirectMusicSynth8Impl_GetRunningStats (LPDIRECTMUSICSYNTH8 iface, LPDMUS_SYNTHSTATS pStats)
125 ICOM_THIS(IDirectMusicSynth8Impl,iface);
127 FIXME("(%p, %p): stub\n", This, pStats);
129 return S_OK;
132 HRESULT WINAPI IDirectMusicSynth8Impl_GetPortCaps (LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTCAPS pCaps)
134 ICOM_THIS(IDirectMusicSynth8Impl,iface);
136 TRACE("(%p, %p)\n", This, pCaps);
137 *pCaps = This->pCaps;
139 return S_OK;
142 HRESULT WINAPI IDirectMusicSynth8Impl_SetMasterClock (LPDIRECTMUSICSYNTH8 iface, IReferenceClock* pClock)
144 ICOM_THIS(IDirectMusicSynth8Impl,iface);
146 FIXME("(%p, %p): stub\n", This, pClock);
148 return S_OK;
151 HRESULT WINAPI IDirectMusicSynth8Impl_GetLatencyClock (LPDIRECTMUSICSYNTH8 iface, IReferenceClock** ppClock)
153 ICOM_THIS(IDirectMusicSynth8Impl,iface);
155 TRACE("(%p, %p)\n", This, ppClock);
156 *ppClock = This->pLatencyClock;
158 return S_OK;
161 HRESULT WINAPI IDirectMusicSynth8Impl_Activate (LPDIRECTMUSICSYNTH8 iface, BOOL fEnable)
163 ICOM_THIS(IDirectMusicSynth8Impl,iface);
165 TRACE("(%p, %d)\n", This, fEnable);
166 This->fActive = fEnable;
168 return S_OK;
171 HRESULT WINAPI IDirectMusicSynth8Impl_SetSynthSink (LPDIRECTMUSICSYNTH8 iface, IDirectMusicSynthSink* pSynthSink)
173 ICOM_THIS(IDirectMusicSynth8Impl,iface);
175 TRACE("(%p, %p)\n", This, pSynthSink);
176 This->pSynthSink = (IDirectMusicSynthSinkImpl*)pSynthSink;
178 return S_OK;
181 HRESULT WINAPI IDirectMusicSynth8Impl_Render (LPDIRECTMUSICSYNTH8 iface, short* pBuffer, DWORD dwLength, LONGLONG llPosition)
183 ICOM_THIS(IDirectMusicSynth8Impl,iface);
185 FIXME("(%p, %p, %ld, %lli): stub\n", This, pBuffer, dwLength, llPosition);
187 return S_OK;
190 HRESULT WINAPI IDirectMusicSynth8Impl_SetChannelPriority (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority)
192 /*ICOM_THIS(IDirectMusicSynth8Impl,iface); */
194 /* silenced because of too many messages - 1000 groups * 16 channels ;=) */
195 /*FIXME("(%p, %ld, %ld, %ld): stub\n", This, dwChannelGroup, dwChannel, dwPriority); */
197 return S_OK;
200 HRESULT WINAPI IDirectMusicSynth8Impl_GetChannelPriority (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority)
202 ICOM_THIS(IDirectMusicSynth8Impl,iface);
204 FIXME("(%p, %ld, %ld, %p): stub\n", This, dwChannelGroup, dwChannel, pdwPriority);
206 return S_OK;
209 HRESULT WINAPI IDirectMusicSynth8Impl_GetFormat (LPDIRECTMUSICSYNTH8 iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSiz)
211 ICOM_THIS(IDirectMusicSynth8Impl,iface);
213 FIXME("(%p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSiz);
215 return S_OK;
218 HRESULT WINAPI IDirectMusicSynth8Impl_GetAppend (LPDIRECTMUSICSYNTH8 iface, DWORD* pdwAppend)
220 ICOM_THIS(IDirectMusicSynth8Impl,iface);
222 FIXME("(%p, %p): stub\n", This, pdwAppend);
224 return S_OK;
227 /* IDirectMusicSynth8 IDirectMusicSynth8 part: */
228 HRESULT WINAPI IDirectMusicSynth8Impl_PlayVoice (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, long prPitch, long vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd)
230 ICOM_THIS(IDirectMusicSynth8Impl,iface);
232 FIXME("(%p, %lli, %ld, %ld, %ld, %ld, %li, %li,%lli, %lli, %lli): stub\n", This, rt, dwVoiceId, dwChannelGroup, dwChannel, dwDLId, prPitch, vrVolume, stVoiceStart, stLoopStart, stLoopEnd);
234 return S_OK;
237 HRESULT WINAPI IDirectMusicSynth8Impl_StopVoice (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, DWORD dwVoiceId)
239 ICOM_THIS(IDirectMusicSynth8Impl,iface);
241 FIXME("(%p, %lli, %ld): stub\n", This, rt, dwVoiceId);
243 return S_OK;
246 HRESULT WINAPI IDirectMusicSynth8Impl_GetVoiceState (LPDIRECTMUSICSYNTH8 iface, DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[])
248 ICOM_THIS(IDirectMusicSynth8Impl,iface);
250 FIXME("(%p, %p, %ld, %p): stub\n", This, dwVoice, cbVoice, dwVoiceState);
252 return S_OK;
255 HRESULT WINAPI IDirectMusicSynth8Impl_Refresh (LPDIRECTMUSICSYNTH8 iface, DWORD dwDownloadID, DWORD dwFlags)
257 ICOM_THIS(IDirectMusicSynth8Impl,iface);
259 FIXME("(%p, %ld, %ld): stub\n", This, dwDownloadID, dwFlags);
261 return S_OK;
264 HRESULT WINAPI IDirectMusicSynth8Impl_AssignChannelToBuses (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBuses, DWORD cBuses)
266 ICOM_THIS(IDirectMusicSynth8Impl,iface);
268 FIXME("(%p, %ld, %ld, %p, %ld): stub\n", This, dwChannelGroup, dwChannel, pdwBuses, cBuses);
270 return S_OK;
273 ICOM_VTABLE(IDirectMusicSynth8) DirectMusicSynth8_Vtbl =
275 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
276 IDirectMusicSynth8Impl_QueryInterface,
277 IDirectMusicSynth8Impl_AddRef,
278 IDirectMusicSynth8Impl_Release,
279 IDirectMusicSynth8Impl_Open,
280 IDirectMusicSynth8Impl_Close,
281 IDirectMusicSynth8Impl_SetNumChannelGroups,
282 IDirectMusicSynth8Impl_Download,
283 IDirectMusicSynth8Impl_Unload,
284 IDirectMusicSynth8Impl_PlayBuffer,
285 IDirectMusicSynth8Impl_GetRunningStats,
286 IDirectMusicSynth8Impl_GetPortCaps,
287 IDirectMusicSynth8Impl_SetMasterClock,
288 IDirectMusicSynth8Impl_GetLatencyClock,
289 IDirectMusicSynth8Impl_Activate,
290 IDirectMusicSynth8Impl_SetSynthSink,
291 IDirectMusicSynth8Impl_Render,
292 IDirectMusicSynth8Impl_SetChannelPriority,
293 IDirectMusicSynth8Impl_GetChannelPriority,
294 IDirectMusicSynth8Impl_GetFormat,
295 IDirectMusicSynth8Impl_GetAppend,
296 IDirectMusicSynth8Impl_PlayVoice,
297 IDirectMusicSynth8Impl_StopVoice,
298 IDirectMusicSynth8Impl_GetVoiceState,
299 IDirectMusicSynth8Impl_Refresh,
300 IDirectMusicSynth8Impl_AssignChannelToBuses
303 /* for ClassFactory */
304 HRESULT WINAPI DMUSIC_CreateDirectMusicSynth (LPCGUID lpcGUID, LPDIRECTMUSICSYNTH8* ppDMSynth, LPUNKNOWN pUnkOuter)
306 IDirectMusicSynth8Impl *dmsynth;
308 TRACE("(%p,%p,%p)\n", lpcGUID, ppDMSynth, pUnkOuter);
309 if (IsEqualIID (lpcGUID, &IID_IDirectMusicSynth) ||
310 IsEqualIID (lpcGUID, &IID_IDirectMusicSynth8)) {
311 dmsynth = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynth8Impl));
312 if (NULL == dmsynth) {
313 *ppDMSynth = (LPDIRECTMUSICSYNTH8) NULL;
314 return E_OUTOFMEMORY;
316 dmsynth->lpVtbl = &DirectMusicSynth8_Vtbl;
317 dmsynth->ref = 1;
318 /* fill in caps */
319 dmsynth->pCaps.dwSize = sizeof(DMUS_PORTCAPS);
320 dmsynth->pCaps.dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
321 dmsynth->pCaps.guidPort = CLSID_DirectMusicSynth;
322 dmsynth->pCaps.dwClass = DMUS_PC_OUTPUTCLASS;
323 dmsynth->pCaps.dwType = DMUS_PORT_WINMM_DRIVER;
324 dmsynth->pCaps.dwMemorySize = DMUS_PC_SYSTEMMEMORY;
325 dmsynth->pCaps.dwMaxChannelGroups = 1000;
326 dmsynth->pCaps.dwMaxVoices = 1000;
327 dmsynth->pCaps.dwMaxAudioChannels = -1;
328 dmsynth->pCaps.dwEffectFlags = DMUS_EFFECT_REVERB | DMUS_EFFECT_CHORUS | DMUS_EFFECT_DELAY;
329 MultiByteToWideChar (CP_ACP, 0, "Microsotf Synthesizer", -1, dmsynth->pCaps.wszDescription, sizeof(dmsynth->pCaps.wszDescription)/sizeof(WCHAR));
330 /* assign latency clock */
331 /*DMUSIC_CreateReferenceClock (&IID_IReferenceClock, (LPREFERENCECLOCK*)&This->pLatencyClock, NULL); */
333 *ppDMSynth = (LPDIRECTMUSICSYNTH8) dmsynth;
334 return S_OK;
336 WARN("No interface found\n");
338 return E_NOINTERFACE;