msvcp90: Separate num_get::get(long double) and num_get::get(double) functions.
[wine/multimedia.git] / dlls / dmsynth / synth.c
blob29761d728a2c351689898dd6747ce25b8ebc52dc
1 /*
2 * IDirectMusicSynth8 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 #define COBJMACROS
23 #include "objbase.h"
24 #include "initguid.h"
25 #include "dmksctrl.h"
27 #include "dmsynth_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
31 static inline IDirectMusicSynth8Impl *impl_from_IDirectMusicSynth8(IDirectMusicSynth8 *iface)
33 return CONTAINING_RECORD(iface, IDirectMusicSynth8Impl, IDirectMusicSynth8_iface);
36 /* IDirectMusicSynth8Impl IUnknown part: */
37 static HRESULT WINAPI IDirectMusicSynth8Impl_QueryInterface(LPDIRECTMUSICSYNTH8 iface, REFIID riid, LPVOID *ret_iface)
39 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
41 TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
43 if (IsEqualIID (riid, &IID_IUnknown) ||
44 IsEqualIID (riid, &IID_IDirectMusicSynth) ||
45 IsEqualIID (riid, &IID_IDirectMusicSynth8))
47 IUnknown_AddRef(iface);
48 *ret_iface = iface;
49 return S_OK;
51 else if (IsEqualIID(riid, &IID_IKsControl))
53 IUnknown_AddRef(iface);
54 *ret_iface = &This->IKsControl_iface;
55 return S_OK;
58 *ret_iface = NULL;
60 WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
62 return E_NOINTERFACE;
65 static ULONG WINAPI IDirectMusicSynth8Impl_AddRef(LPDIRECTMUSICSYNTH8 iface)
67 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
68 ULONG ref = InterlockedIncrement(&This->ref);
70 TRACE("(%p)->(): new ref = %u\n", This, ref);
72 DMSYNTH_LockModule();
74 return ref;
77 static ULONG WINAPI IDirectMusicSynth8Impl_Release(LPDIRECTMUSICSYNTH8 iface)
79 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
80 ULONG ref = InterlockedDecrement(&This->ref);
82 TRACE("(%p)->(): new ref = %u\n", This, ref);
84 if (!ref) {
85 if (This->pLatencyClock)
86 IReferenceClock_Release(This->pLatencyClock);
87 HeapFree(GetProcessHeap(), 0, This);
90 DMSYNTH_UnlockModule();
92 return ref;
95 /* IDirectMusicSynth8Impl IDirectMusicSynth part: */
96 static HRESULT WINAPI IDirectMusicSynth8Impl_Open(LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTPARAMS pPortParams)
98 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
100 FIXME("(%p)->(%p): stub\n", This, pPortParams);
102 return S_OK;
105 static HRESULT WINAPI IDirectMusicSynth8Impl_Close(LPDIRECTMUSICSYNTH8 iface)
107 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
109 FIXME("(%p)->(): stub\n", This);
111 return S_OK;
114 static HRESULT WINAPI IDirectMusicSynth8Impl_SetNumChannelGroups(LPDIRECTMUSICSYNTH8 iface, DWORD groups)
116 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
118 FIXME("(%p->(%d): stub\n", This, groups);
120 return S_OK;
123 static HRESULT WINAPI IDirectMusicSynth8Impl_Download(LPDIRECTMUSICSYNTH8 iface, LPHANDLE hDownload, LPVOID data, LPBOOL free)
125 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
126 DMUS_DOWNLOADINFO* info = (DMUS_DOWNLOADINFO*)data;
128 FIXME("(%p)->(%p, %p, %p): stub\n", This, hDownload, data, free);
130 if (!hDownload || !data || !free)
131 return E_POINTER;
133 if (TRACE_ON(dmsynth))
135 TRACE("Dump DMUS_DOWNLOADINFO struct:\n");
136 TRACE(" - dwDLType = %u\n", info->dwDLType);
137 TRACE(" - dwDLId = %u\n", info->dwDLId);
138 TRACE(" - dwNumOffsetTableEntries = %u\n", info->dwNumOffsetTableEntries);
139 TRACE(" - cbSize = %u\n", info->cbSize);
142 if (info->dwDLType == DMUS_DOWNLOADINFO_INSTRUMENT)
144 FIXME("Download type DMUS_DOWNLOADINFO_INSTRUMENT not yet supported\n");
146 else if (info->dwDLType == DMUS_DOWNLOADINFO_WAVE)
148 FIXME("Download type DMUS_DOWNLOADINFO_WAVE not yet supported\n");
150 else if (info->dwDLType == DMUS_DOWNLOADINFO_INSTRUMENT2)
152 FIXME("Download type DMUS_DOWNLOADINFO_INSTRUMENT2 not yet supported\n");
154 else if (info->dwDLType == DMUS_DOWNLOADINFO_WAVEARTICULATION)
156 FIXME("Download type DMUS_DOWNLOADINFO_WAVEARTICULATION not yet supported\n");
158 else if (info->dwDLType == DMUS_DOWNLOADINFO_STREAMINGWAVE)
160 FIXME("Download type DMUS_DOWNLOADINFO_STREAMINGWAVE not yet supported\n");
162 else if (info->dwDLType == DMUS_DOWNLOADINFO_ONESHOTWAVE)
164 FIXME("Download type DMUS_DOWNLOADINFO_ONESHOTWAVE not yet supported\n");
166 else
168 WARN("Unknown download type %u\n", info->dwDLType);
169 return DMUS_E_UNKNOWNDOWNLOAD;
172 return S_OK;
175 static HRESULT WINAPI IDirectMusicSynth8Impl_Unload(LPDIRECTMUSICSYNTH8 iface, HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData)
177 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
179 FIXME("(%p)->(%p, %p, %p): stub\n", This, hDownload, lpFreeHandle, hUserData);
181 return S_OK;
184 static HRESULT WINAPI IDirectMusicSynth8Impl_PlayBuffer(LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, LPBYTE buffer, DWORD size)
186 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
188 FIXME("(%p)->(0x%s, %p, %u): stub\n", This, wine_dbgstr_longlong(rt), buffer, size);
190 return S_OK;
193 static HRESULT WINAPI IDirectMusicSynth8Impl_GetRunningStats(LPDIRECTMUSICSYNTH8 iface, LPDMUS_SYNTHSTATS stats)
195 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
197 FIXME("(%p)->(%p): stub\n", This, stats);
199 return S_OK;
202 static HRESULT WINAPI IDirectMusicSynth8Impl_GetPortCaps(LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTCAPS caps)
204 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
206 TRACE("(%p)->(%p)\n", This, caps);
208 *caps = This->pCaps;
210 return S_OK;
213 static HRESULT WINAPI IDirectMusicSynth8Impl_SetMasterClock(LPDIRECTMUSICSYNTH8 iface, IReferenceClock* clock)
215 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
217 FIXME("(%p)->(%p): stub\n", This, clock);
219 return S_OK;
222 static HRESULT WINAPI IDirectMusicSynth8Impl_GetLatencyClock(LPDIRECTMUSICSYNTH8 iface, IReferenceClock** clock)
224 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
226 TRACE("(%p)->(%p)\n", iface, clock);
228 if (!clock)
229 return E_POINTER;
231 if (!This->pSynthSink)
232 return DMUS_E_NOSYNTHSINK;
234 *clock = This->pLatencyClock;
235 IReferenceClock_AddRef(This->pLatencyClock);
237 return S_OK;
240 static HRESULT WINAPI IDirectMusicSynth8Impl_Activate(LPDIRECTMUSICSYNTH8 iface, BOOL enable)
242 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
244 TRACE("(%p)->(%d)\n", This, enable);
246 This->fActive = enable;
248 return S_OK;
251 static HRESULT WINAPI IDirectMusicSynth8Impl_SetSynthSink(LPDIRECTMUSICSYNTH8 iface, IDirectMusicSynthSink* synth_sink)
253 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
255 TRACE("(%p)->(%p)\n", iface, synth_sink);
257 This->pSynthSink = (IDirectMusicSynthSinkImpl*)synth_sink;
259 if (synth_sink)
260 return IDirectMusicSynthSink_GetLatencyClock(synth_sink, &This->pLatencyClock);
262 return S_OK;
265 static HRESULT WINAPI IDirectMusicSynth8Impl_Render(LPDIRECTMUSICSYNTH8 iface, short* buffer, DWORD length, LONGLONG position)
267 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
269 FIXME("(%p)->(%p, %d, 0x%s): stub\n", This, buffer, length, wine_dbgstr_longlong(position));
271 return S_OK;
274 static HRESULT WINAPI IDirectMusicSynth8Impl_SetChannelPriority(LPDIRECTMUSICSYNTH8 iface, DWORD channel_group, DWORD channel, DWORD priority)
276 /* IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface); */
278 /* Silenced because of too many messages - 1000 groups * 16 channels ;=) */
279 /* FIXME("(%p)->(%ld, %ld, %ld): stub\n", This, channel_group, channel, priority); */
281 return S_OK;
284 static HRESULT WINAPI IDirectMusicSynth8Impl_GetChannelPriority(LPDIRECTMUSICSYNTH8 iface, DWORD channel_group, DWORD channel, LPDWORD priority)
286 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
288 FIXME("(%p)->(%d, %d, %p): stub\n", This, channel_group, channel, priority);
290 return S_OK;
293 static HRESULT WINAPI IDirectMusicSynth8Impl_GetFormat(LPDIRECTMUSICSYNTH8 iface, LPWAVEFORMATEX wave_format, LPDWORD wave_format_size)
295 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
297 FIXME("(%p)->(%p, %p): stub\n", This, wave_format, wave_format_size);
299 return S_OK;
302 static HRESULT WINAPI IDirectMusicSynth8Impl_GetAppend(LPDIRECTMUSICSYNTH8 iface, DWORD* append)
304 TRACE("(%p)->(%p)\n", iface, append);
306 /* We don't need extra space at the end of buffers passed to us for now */
307 *append = 0;
309 return S_OK;
312 /* IDirectMusicSynth8Impl IDirectMusicSynth8 part: */
313 static HRESULT WINAPI IDirectMusicSynth8Impl_PlayVoice(LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME ref_time, DWORD voice_id, DWORD channel_group, DWORD channel,
314 DWORD dwDLId, LONG prPitch, LONG vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd)
316 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
318 FIXME("(%p)->(0x%s, %d, %d, %d, %d, %i, %i,0x%s, 0x%s, 0x%s): stub\n",
319 This, wine_dbgstr_longlong(ref_time), voice_id, channel_group, channel, dwDLId, prPitch, vrVolume,
320 wine_dbgstr_longlong(stVoiceStart), wine_dbgstr_longlong(stLoopStart), wine_dbgstr_longlong(stLoopEnd));
322 return S_OK;
325 static HRESULT WINAPI IDirectMusicSynth8Impl_StopVoice(LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME ref_time, DWORD voice_id)
327 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
329 FIXME("(%p)->(0x%s, %d): stub\n", This, wine_dbgstr_longlong(ref_time), voice_id);
331 return S_OK;
334 static HRESULT WINAPI IDirectMusicSynth8Impl_GetVoiceState(LPDIRECTMUSICSYNTH8 iface, DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[])
336 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
338 FIXME("(%p)->(%p, %d, %p): stub\n", This, dwVoice, cbVoice, dwVoiceState);
340 return S_OK;
343 static HRESULT WINAPI IDirectMusicSynth8Impl_Refresh(LPDIRECTMUSICSYNTH8 iface, DWORD download_id, DWORD flags)
345 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
347 FIXME("(%p)->(%d, %d): stub\n", This, download_id, flags);
349 return S_OK;
352 static HRESULT WINAPI IDirectMusicSynth8Impl_AssignChannelToBuses(LPDIRECTMUSICSYNTH8 iface, DWORD channel_group, DWORD channel, LPDWORD pdwBuses, DWORD cBuses)
354 IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
356 FIXME("(%p)->(%d, %d, %p, %d): stub\n", This, channel_group, channel, pdwBuses, cBuses);
358 return S_OK;
361 static const IDirectMusicSynth8Vtbl DirectMusicSynth8_Vtbl = {
362 IDirectMusicSynth8Impl_QueryInterface,
363 IDirectMusicSynth8Impl_AddRef,
364 IDirectMusicSynth8Impl_Release,
365 IDirectMusicSynth8Impl_Open,
366 IDirectMusicSynth8Impl_Close,
367 IDirectMusicSynth8Impl_SetNumChannelGroups,
368 IDirectMusicSynth8Impl_Download,
369 IDirectMusicSynth8Impl_Unload,
370 IDirectMusicSynth8Impl_PlayBuffer,
371 IDirectMusicSynth8Impl_GetRunningStats,
372 IDirectMusicSynth8Impl_GetPortCaps,
373 IDirectMusicSynth8Impl_SetMasterClock,
374 IDirectMusicSynth8Impl_GetLatencyClock,
375 IDirectMusicSynth8Impl_Activate,
376 IDirectMusicSynth8Impl_SetSynthSink,
377 IDirectMusicSynth8Impl_Render,
378 IDirectMusicSynth8Impl_SetChannelPriority,
379 IDirectMusicSynth8Impl_GetChannelPriority,
380 IDirectMusicSynth8Impl_GetFormat,
381 IDirectMusicSynth8Impl_GetAppend,
382 IDirectMusicSynth8Impl_PlayVoice,
383 IDirectMusicSynth8Impl_StopVoice,
384 IDirectMusicSynth8Impl_GetVoiceState,
385 IDirectMusicSynth8Impl_Refresh,
386 IDirectMusicSynth8Impl_AssignChannelToBuses
389 static inline IDirectMusicSynth8Impl *impl_from_IKsControl(IKsControl *iface)
391 return CONTAINING_RECORD(iface, IDirectMusicSynth8Impl, IKsControl_iface);
394 static HRESULT WINAPI DMSynthImpl_IKsControl_QueryInterface(IKsControl* iface, REFIID riid, LPVOID *ppobj)
396 IDirectMusicSynth8Impl *This = impl_from_IKsControl(iface);
398 return IDirectMusicSynth8Impl_QueryInterface(&This->IDirectMusicSynth8_iface, riid, ppobj);
401 static ULONG WINAPI DMSynthImpl_IKsControl_AddRef(IKsControl* iface)
403 IDirectMusicSynth8Impl *This = impl_from_IKsControl(iface);
405 return IDirectMusicSynth8Impl_AddRef(&This->IDirectMusicSynth8_iface);
408 static ULONG WINAPI DMSynthImpl_IKsControl_Release(IKsControl* iface)
410 IDirectMusicSynth8Impl *This = impl_from_IKsControl(iface);
412 return IDirectMusicSynth8Impl_Release(&This->IDirectMusicSynth8_iface);
415 static HRESULT WINAPI DMSynthImpl_IKsControl_KsProperty(IKsControl* iface, PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData,
416 ULONG DataLength, ULONG* BytesReturned)
418 FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Property, PropertyLength, PropertyData, DataLength, BytesReturned);
420 return E_NOTIMPL;
423 static HRESULT WINAPI DMSynthImpl_IKsControl_KsMethod(IKsControl* iface, PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData,
424 ULONG DataLength, ULONG* BytesReturned)
426 FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Method, MethodLength, MethodData, DataLength, BytesReturned);
428 return E_NOTIMPL;
431 static HRESULT WINAPI DMSynthImpl_IKsControl_KsEvent(IKsControl* iface, PKSEVENT Event, ULONG EventLength, LPVOID EventData,
432 ULONG DataLength, ULONG* BytesReturned)
434 FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Event, EventLength, EventData, DataLength, BytesReturned);
436 return E_NOTIMPL;
440 static const IKsControlVtbl DMSynthImpl_IKsControl_Vtbl = {
441 DMSynthImpl_IKsControl_QueryInterface,
442 DMSynthImpl_IKsControl_AddRef,
443 DMSynthImpl_IKsControl_Release,
444 DMSynthImpl_IKsControl_KsProperty,
445 DMSynthImpl_IKsControl_KsMethod,
446 DMSynthImpl_IKsControl_KsEvent
449 /* for ClassFactory */
450 HRESULT WINAPI DMUSIC_CreateDirectMusicSynthImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter)
452 IDirectMusicSynth8Impl *obj;
454 TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
455 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynth8Impl));
456 if (NULL == obj) {
457 *ppobj = NULL;
458 return E_OUTOFMEMORY;
460 obj->IDirectMusicSynth8_iface.lpVtbl = &DirectMusicSynth8_Vtbl;
461 obj->IKsControl_iface.lpVtbl = &DMSynthImpl_IKsControl_Vtbl;
462 obj->ref = 0;
463 /* fill in caps */
464 obj->pCaps.dwSize = sizeof(DMUS_PORTCAPS);
465 obj->pCaps.dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
466 obj->pCaps.guidPort = CLSID_DirectMusicSynth;
467 obj->pCaps.dwClass = DMUS_PC_OUTPUTCLASS;
468 obj->pCaps.dwType = DMUS_PORT_USER_MODE_SYNTH;
469 obj->pCaps.dwMemorySize = DMUS_PC_SYSTEMMEMORY;
470 obj->pCaps.dwMaxChannelGroups = 1000;
471 obj->pCaps.dwMaxVoices = 1000;
472 obj->pCaps.dwMaxAudioChannels = 2;
473 obj->pCaps.dwEffectFlags = DMUS_EFFECT_REVERB;
474 MultiByteToWideChar (CP_ACP, 0, "Microsoft Synthesizer", -1, obj->pCaps.wszDescription, sizeof(obj->pCaps.wszDescription)/sizeof(WCHAR));
476 return IDirectMusicSynth8Impl_QueryInterface ((LPDIRECTMUSICSYNTH8)obj, lpcGUID, ppobj);