1 /* IDirectMusicPerformance Implementation
3 * Copyright (C) 2003-2004 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 "dmime_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
24 typedef struct DMUS_PMSGItem DMUS_PMSGItem;
25 struct DMUS_PMSGItem {
34 /* IDirectMusicPerformance8 IUnknown part: */
35 HRESULT WINAPI IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface, REFIID riid, LPVOID *ppobj) {
36 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
37 TRACE("(%p, %s,%p)\n", This, debugstr_dmguid(riid), ppobj);
39 if (IsEqualIID (riid, &IID_IUnknown) ||
40 IsEqualIID (riid, &IID_IDirectMusicPerformance) ||
41 IsEqualIID (riid, &IID_IDirectMusicPerformance8)) {
42 IDirectMusicPerformance8Impl_AddRef(iface);
47 WARN("(%p, %s,%p): not found\n", This, debugstr_dmguid(riid), ppobj);
51 ULONG WINAPI IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface) {
52 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
53 TRACE("(%p): AddRef from %ld\n", This, This->ref);
57 ULONG WINAPI IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface) {
58 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
59 ULONG ref = --This->ref;
60 TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
62 HeapFree(GetProcessHeap(), 0, This);
67 /* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
68 HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd) {
69 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
71 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This, ppDirectMusic, pDirectSound, hWnd);
72 if (This->pDirectMusic || This->pDirectSound)
73 return DMUS_E_ALREADY_INITED;
76 hWnd = GetForegroundWindow();
79 if (NULL != pDirectSound) {
80 This->pDirectSound = (IDirectSound*) pDirectSound;
81 IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound);
83 DirectSoundCreate8(NULL, (LPDIRECTSOUND8*) &This->pDirectSound, NULL);
87 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp
90 IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);
92 /* how to get the ForeGround window handle ? */
93 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
95 if (!This->pDirectSound)
96 return DSERR_NODRIVER;
99 if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
100 /* app creates it's own dmusic object and gives it to performance */
101 This->pDirectMusic = (IDirectMusic8*) *ppDirectMusic;
102 IDirectMusic8_AddRef((LPDIRECTMUSIC8) This->pDirectMusic);
104 /* app allows the performance to initialise itfself and needs a pointer to object*/
105 CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic);
107 *ppDirectMusic = (LPDIRECTMUSIC) This->pDirectMusic;
108 IDirectMusic8_AddRef((LPDIRECTMUSIC8) *ppDirectMusic);
115 HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState) {
116 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
117 FIXME("(%p, %p, %ld, %lli, %p): stub\n", This, pSegment, dwFlags, i64StartTime, ppSegmentState);
121 HRESULT WINAPI IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegmentState, MUSIC_TIME mtTime, DWORD dwFlags) {
122 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
123 FIXME("(%p, %p, %p, %ld, %ld): stub\n", This, pSegment, pSegmentState, mtTime, dwFlags);
127 HRESULT WINAPI IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegmentState** ppSegmentState, MUSIC_TIME mtTime) {
128 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
129 FIXME("(%p,%p, %ld): stub\n", This, ppSegmentState, mtTime);
133 HRESULT WINAPI IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds) {
134 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
135 FIXME("(%p, %ld): stub\n", This, dwMilliSeconds);
139 HRESULT WINAPI IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds) {
140 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
141 FIXME("(%p, %p): stub\n", This, pdwMilliSeconds);
145 HRESULT WINAPI IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds) {
146 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
147 FIXME("(%p, %ld): stub\n", This, dwMilliSeconds);
151 HRESULT WINAPI IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds) {
152 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
153 FIXME("(%p, %p): stub\n", This, pdwMilliSeconds);
157 HRESULT WINAPI IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG) {
158 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
159 FIXME("(%p, %p): stub\n", This, pPMSG);
163 HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, REFERENCE_TIME* prtTime) {
164 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
165 FIXME("(%p, %ld, %p): stub\n", This, mtTime, prtTime);
169 HRESULT WINAPI IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, MUSIC_TIME* pmtTime) {
170 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
171 FIXME("(%p, %lli, %p): stub\n", This, rtTime, pmtTime);
175 HRESULT WINAPI IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegState) {
176 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
177 FIXME("(%p, %p, %p): stub\n", This, pSegment, pSegState);
181 HRESULT WINAPI IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtNow, MUSIC_TIME* pmtNow) {
182 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
183 FIXME("(%p, %p, %p): stub\n", This, prtNow, pmtNow);
187 HRESULT WINAPI IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface, ULONG cb, DMUS_PMSG** ppPMSG) {
188 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
189 DMUS_PMSGItem* pItem = NULL;
191 FIXME("(%p, %ld, %p): stub\n", This, cb, ppPMSG);
193 if (sizeof(DMUS_PMSG) > cb) {
196 if (NULL == ppPMSG) {
199 pItem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb - sizeof(DMUS_PMSG) + sizeof(DMUS_PMSGItem));
201 return E_OUTOFMEMORY;
203 pItem->pMsg.dwSize = cb;
204 *ppPMSG = &(pItem->pMsg);
208 HRESULT WINAPI IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG) {
209 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
210 DMUS_PMSGItem* pItem = NULL;
212 FIXME("(%p, %p): stub\n", This, pPMSG);
217 pItem = (DMUS_PMSGItem*) (((unsigned char*) pPMSG) - sizeof(DMUS_PMSG) - sizeof(DMUS_PMSGItem));
221 if (TRUE == pItem->bInUse) {
222 return DMUS_E_CANNOT_FREE;
224 HeapFree(GetProcessHeap(), 0, pItem);
228 HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph** ppGraph) {
229 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
230 FIXME("(%p, %p): to check\n", This, ppGraph);
231 if (NULL != This->pToolGraph) {
232 *ppGraph = (LPDIRECTMUSICGRAPH) This->pToolGraph;
233 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) *ppGraph);
238 HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph* pGraph) {
239 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
241 FIXME("(%p, %p): to check\n", This, pGraph);
243 if (NULL != This->pToolGraph) {
244 /* Todo clean buffers and tools before */
245 IDirectMusicGraph_Release((LPDIRECTMUSICGRAPH) This->pToolGraph);
247 This->pToolGraph = pGraph;
248 if (NULL != This->pToolGraph) {
249 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) This->pToolGraph);
254 HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface, HANDLE hNotification, REFERENCE_TIME rtMinimum) {
255 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
256 FIXME("(%p, %p, %lli): stub\n", This, hNotification, rtMinimum);
257 This->hNotification = hNotification;
258 if (rtMinimum) This->rtMinimum = rtMinimum;
262 HRESULT WINAPI IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_NOTIFICATION_PMSG** ppNotificationPMsg) {
263 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
264 FIXME("(%p, %p): stub\n", This, ppNotificationPMsg);
265 if (NULL == ppNotificationPMsg) {
272 HRESULT WINAPI IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType) {
273 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
274 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
278 HRESULT WINAPI IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType) {
279 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
280 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
284 HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort) {
285 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
286 FIXME("(%p, %p): stub\n", This, pPort);
287 IDirectMusicPort_AddRef (pPort);
291 HRESULT WINAPI IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort) {
292 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
293 FIXME("(%p, %p): stub\n", This, pPort);
294 IDirectMusicPort_Release (pPort);
298 HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwBlockNum, IDirectMusicPort* pPort, DWORD dwGroup) {
299 int i, j, range /* min value in range */;
300 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
302 FIXME("(%p, %ld, %p, %ld): semi-stub\n", This, dwBlockNum, pPort, dwGroup-1);
303 range = 16 * dwBlockNum;
306 for (i = range; i < range+16; i++) {
307 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
308 This->PChannel[i].port = pPort;
309 This->PChannel[i].group = dwGroup - 1; /* first index is always zero */
310 This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
317 HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel) {
318 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
320 TRACE("(%p, %ld, %p, %ld, %ld)\n", This, dwPChannel, pPort, dwGroup, dwMChannel);
321 This->PChannel[dwPChannel].port = pPort;
322 This->PChannel[dwPChannel].group = dwGroup;
323 This->PChannel[dwPChannel].channel = dwMChannel;
328 HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) {
329 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
330 FIXME("(%p, %ld, %p, %p, %p): stub\n", This, dwPChannel, ppPort, pdwGroup, pdwMChannel);
334 HRESULT WINAPI IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicInstrument* pInst, DWORD dwPChannel, IDirectMusicDownloadedInstrument** ppDownInst, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) {
335 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
336 FIXME("(%p, %p, %ld, %p, %p, %ld, %p, %p, %p): stub\n", This, pInst, dwPChannel, ppDownInst, pNoteRanges, dwNumNoteRanges, ppPort, pdwGroup, pdwMChannel);
340 HRESULT WINAPI IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DWORD dwFlags) {
341 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
342 FIXME("(%p, %ld, %ld): stub\n", This, mtTime, dwFlags);
346 HRESULT WINAPI IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
347 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
348 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
352 HRESULT WINAPI IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam) {
353 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
354 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pParam);
358 HRESULT WINAPI IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize) {
359 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
361 TRACE("(%p, %s, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
363 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload))
364 memcpy(pParam, &This->fAutoDownload, sizeof(&This->fAutoDownload));
365 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel))
366 memcpy(pParam, &This->cMasterGrooveLevel, sizeof(&This->cMasterGrooveLevel));
367 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo))
368 memcpy(pParam, &This->fMasterTempo, sizeof(&This->fMasterTempo));
369 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume))
370 memcpy(pParam, &This->lMasterVolume, sizeof(&This->lMasterVolume));
375 HRESULT WINAPI IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize) {
376 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
378 TRACE("(%p, %s, %p, %ld)\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
380 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload)) {
381 memcpy(&This->fAutoDownload, pParam, dwSize);
382 TRACE("=> AutoDownload set to %d\n", This->fAutoDownload);
384 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel)) {
385 memcpy(&This->cMasterGrooveLevel, pParam, dwSize);
386 TRACE("=> MasterGrooveLevel set to %i\n", This->cMasterGrooveLevel);
388 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo)) {
389 memcpy(&This->fMasterTempo, pParam, dwSize);
390 TRACE("=> MasterTempo set to %f\n", This->fMasterTempo);
392 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume)) {
393 memcpy(&This->lMasterVolume, pParam, dwSize);
394 TRACE("=> MasterVolume set to %li\n", This->lMasterVolume);
400 HRESULT WINAPI IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime) {
401 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
402 FIXME("(%p, %p): stub\n", This, prtTime);
406 HRESULT WINAPI IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime) {
407 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
408 FIXME("(%p, %p): stub\n", This, prtTime);
412 HRESULT WINAPI IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtAmount) {
413 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
414 FIXME("(%p, %lli): stub\n", This, rtAmount);
418 HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface) {
419 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
420 FIXME("(%p): stub\n", This);
424 HRESULT WINAPI IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, REFERENCE_TIME* prtResolved, DWORD dwTimeResolveFlags) {
425 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
426 FIXME("(%p, %lli, %p, %ld): stub\n", This, rtTime, prtResolved, dwTimeResolveFlags);
430 HRESULT WINAPI IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface, BYTE bMIDIValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, WORD* pwMusicValue) {
431 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
432 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, bMIDIValue, pChord, bPlayMode, bChordLevel, pwMusicValue);
436 HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMusicValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, BYTE* pbMIDIValue) {
437 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
438 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, wMusicValue, pChord, bPlayMode, bChordLevel, pbMIDIValue);
442 HRESULT WINAPI IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DMUS_TIMESIGNATURE* pTimeSig, WORD* pwMeasure, BYTE* pbBeat, BYTE* pbGrid, short* pnOffset) {
443 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
444 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This, mtTime, pTimeSig, pwMeasure, pbBeat, pbGrid, pnOffset);
448 HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMeasure, BYTE bBeat, BYTE bGrid, short nOffset, DMUS_TIMESIGNATURE* pTimeSig, MUSIC_TIME* pmtTime) {
449 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
450 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This, wMeasure, bBeat, bGrid, nOffset, pTimeSig, pmtTime);
454 /* IDirectMusicPerformance8 Interface part follow: */
455 HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 iface,
456 IDirectMusic** ppDirectMusic,
457 IDirectSound** ppDirectSound,
459 DWORD dwDefaultPathType,
460 DWORD dwPChannelCount,
462 DMUS_AUDIOPARAMS* pParams) {
464 IDirectSound* dsound = NULL;
467 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
468 FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
470 if (This->pDirectMusic || This->pDirectSound)
471 return DMUS_E_ALREADY_INITED;
473 if (NULL != ppDirectSound && NULL != *ppDirectSound) {
474 dsound = *ppDirectSound;
476 hr = DirectSoundCreate8 (NULL, (LPDIRECTSOUND8*) &dsound, NULL);
477 FIXME("return dsound(%p,%ld)\n", dsound, hr);
478 if (FAILED(hr) || !dsound)
479 return DSERR_NODRIVER;
481 *ppDirectSound = dsound;
484 IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, dsound, hWnd);
486 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
487 if (NULL == ppDirectSound) {
488 IDirectSound_Release(This->pDirectSound);
491 /* as seen in msdn we need params init before audio path creation */
492 if (NULL != pParams) {
493 memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS));
496 * TODO, how can i fill the struct
497 * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp
499 This->pParams.dwSize = sizeof(DMUS_AUDIOPARAMS);
500 This->pParams.fInitNow = FALSE;
501 This->pParams.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES | DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH;
502 This->pParams.dwVoices = 64;
503 This->pParams.dwSampleRate = (DWORD) 22.050;
504 This->pParams.dwFeatures = dwFlags;
505 This->pParams.clsidDefaultSynth = CLSID_DirectMusicSynthSink;
507 hr = IDirectMusicPerformance8Impl_CreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath);
512 HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath) {
513 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
514 FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This, pSource, pwzSegmentName, pTransition, dwFlags, i64StartTime, ppSegmentState, pFrom, pAudioPath);
518 HRESULT WINAPI IDirectMusicPerformance8Impl_StopEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pObjectToStop, __int64 i64StopTime, DWORD dwFlags) {
519 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
520 FIXME("(%p, %p, %lli, %ld): stub\n", This, pObjectToStop, i64StopTime, dwFlags);
524 HRESULT WINAPI IDirectMusicPerformance8Impl_ClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pSourcePMSG, DMUS_PMSG** ppCopyPMSG) {
525 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
526 FIXME("(%p, %p, %p): stub\n", This, pSourcePMSG, ppCopyPMSG);
530 HRESULT WINAPI IDirectMusicPerformance8Impl_CreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSourceConfig, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) {
531 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
532 FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ppNewPath);
537 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp
539 HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) {
540 IDirectMusicAudioPathImpl *default_path;
541 IDirectMusicAudioPath *pPath;
544 LPDIRECTSOUNDBUFFER8 buffer;
547 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
549 FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
551 if (NULL == ppNewPath) {
555 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath, (LPVOID*)&pPath, NULL);
556 default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl));
557 default_path->pPerf = (IDirectMusicPerformance8*) This;
559 /* Secondary buffer description */
560 format.wFormatTag = WAVE_FORMAT_PCM;
561 format.nChannels = 1;
562 format.nSamplesPerSec = 44000;
563 format.nAvgBytesPerSec = 44000*2;
564 format.nBlockAlign = 2;
565 format.wBitsPerSample = 16;
568 desc.dwSize = sizeof(desc);
569 desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS;
570 desc.dwBufferBytes = DSBSIZE_MIN;
572 desc.lpwfxFormat = &format;
573 desc.guid3DAlgorithm = GUID_NULL;
576 case DMUS_APATH_DYNAMIC_3D:
577 desc.dwFlags |= DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE;
579 case DMUS_APATH_DYNAMIC_MONO:
580 desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
582 case DMUS_APATH_SHARED_STEREOPLUSREVERB:
583 /* normally we havet to create 2 buffers (one for music other for reverb)
584 * in this case. See msdn
586 case DMUS_APATH_DYNAMIC_STEREO:
587 desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
588 format.nChannels = 2;
589 format.nBlockAlign *= 2;
590 format.nAvgBytesPerSec *=2;
593 HeapFree(GetProcessHeap(), 0, default_path);
599 /* FIXME: Should we create one secondary buffer for each PChannel? */
600 hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
602 HeapFree(GetProcessHeap(), 0, default_path);
604 return DSERR_BUFFERLOST;
606 default_path->pDSBuffer = (IDirectSoundBuffer*) buffer;
608 /* Update description for creating primary buffer */
609 desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
610 desc.dwBufferBytes = 0;
611 desc.lpwfxFormat = NULL;
613 hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
615 IDirectSoundBuffer_Release(default_path->pDSBuffer);
616 HeapFree(GetProcessHeap(), 0, default_path);
618 return DSERR_BUFFERLOST;
620 default_path->pPrimary = (IDirectSoundBuffer*) buffer;
622 *ppNewPath = (LPDIRECTMUSICAUDIOPATH) pPath;
624 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath);
629 HRESULT WINAPI IDirectMusicPerformance8Impl_SetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath) {
630 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
632 FIXME("(%p, %p): semi-stub\n", This, pAudioPath);
633 if (NULL != This->pDefaultPath) {
634 IDirectMusicAudioPath_Release((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
635 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = NULL;
636 This->pDefaultPath = NULL;
638 This->pDefaultPath = pAudioPath;
639 if (NULL != This->pDefaultPath) {
640 IDirectMusicAudioPath_AddRef((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
641 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = (IDirectMusicPerformance8*) This;
647 HRESULT WINAPI IDirectMusicPerformance8Impl_GetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath** ppAudioPath) {
648 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
650 FIXME("(%p, %p): semi-stub (%p)\n", This, ppAudioPath, This->pDefaultPath);
652 if (NULL != This->pDefaultPath) {
653 *ppAudioPath = (LPDIRECTMUSICAUDIOPATH) This->pDefaultPath;
654 IDirectMusicAudioPath_AddRef(*ppAudioPath);
661 HRESULT WINAPI IDirectMusicPerformance8Impl_GetParamEx (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
662 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
664 FIXME("(%p, %s, %ld, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwTrackID, dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
669 ICOM_VTABLE(IDirectMusicPerformance8) DirectMusicPerformance8_Vtbl = {
670 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
671 IDirectMusicPerformance8Impl_QueryInterface,
672 IDirectMusicPerformance8Impl_AddRef,
673 IDirectMusicPerformance8Impl_Release,
674 IDirectMusicPerformance8Impl_Init,
675 IDirectMusicPerformance8Impl_PlaySegment,
676 IDirectMusicPerformance8Impl_Stop,
677 IDirectMusicPerformance8Impl_GetSegmentState,
678 IDirectMusicPerformance8Impl_SetPrepareTime,
679 IDirectMusicPerformance8Impl_GetPrepareTime,
680 IDirectMusicPerformance8Impl_SetBumperLength,
681 IDirectMusicPerformance8Impl_GetBumperLength,
682 IDirectMusicPerformance8Impl_SendPMsg,
683 IDirectMusicPerformance8Impl_MusicToReferenceTime,
684 IDirectMusicPerformance8Impl_ReferenceToMusicTime,
685 IDirectMusicPerformance8Impl_IsPlaying,
686 IDirectMusicPerformance8Impl_GetTime,
687 IDirectMusicPerformance8Impl_AllocPMsg,
688 IDirectMusicPerformance8Impl_FreePMsg,
689 IDirectMusicPerformance8Impl_GetGraph,
690 IDirectMusicPerformance8Impl_SetGraph,
691 IDirectMusicPerformance8Impl_SetNotificationHandle,
692 IDirectMusicPerformance8Impl_GetNotificationPMsg,
693 IDirectMusicPerformance8Impl_AddNotificationType,
694 IDirectMusicPerformance8Impl_RemoveNotificationType,
695 IDirectMusicPerformance8Impl_AddPort,
696 IDirectMusicPerformance8Impl_RemovePort,
697 IDirectMusicPerformance8Impl_AssignPChannelBlock,
698 IDirectMusicPerformance8Impl_AssignPChannel,
699 IDirectMusicPerformance8Impl_PChannelInfo,
700 IDirectMusicPerformance8Impl_DownloadInstrument,
701 IDirectMusicPerformance8Impl_Invalidate,
702 IDirectMusicPerformance8Impl_GetParam,
703 IDirectMusicPerformance8Impl_SetParam,
704 IDirectMusicPerformance8Impl_GetGlobalParam,
705 IDirectMusicPerformance8Impl_SetGlobalParam,
706 IDirectMusicPerformance8Impl_GetLatencyTime,
707 IDirectMusicPerformance8Impl_GetQueueTime,
708 IDirectMusicPerformance8Impl_AdjustTime,
709 IDirectMusicPerformance8Impl_CloseDown,
710 IDirectMusicPerformance8Impl_GetResolvedTime,
711 IDirectMusicPerformance8Impl_MIDIToMusic,
712 IDirectMusicPerformance8Impl_MusicToMIDI,
713 IDirectMusicPerformance8Impl_TimeToRhythm,
714 IDirectMusicPerformance8Impl_RhythmToTime,
715 IDirectMusicPerformance8Impl_InitAudio,
716 IDirectMusicPerformance8Impl_PlaySegmentEx,
717 IDirectMusicPerformance8Impl_StopEx,
718 IDirectMusicPerformance8Impl_ClonePMsg,
719 IDirectMusicPerformance8Impl_CreateAudioPath,
720 IDirectMusicPerformance8Impl_CreateStandardAudioPath,
721 IDirectMusicPerformance8Impl_SetDefaultAudioPath,
722 IDirectMusicPerformance8Impl_GetDefaultAudioPath,
723 IDirectMusicPerformance8Impl_GetParamEx
726 /* for ClassFactory */
727 HRESULT WINAPI DMUSIC_CreateDirectMusicPerformanceImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
728 IDirectMusicPerformance8Impl *obj;
730 TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
732 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPerformance8Impl));
734 *ppobj = (LPDIRECTMUSICPERFORMANCE8)NULL;
735 return E_OUTOFMEMORY;
737 obj->lpVtbl = &DirectMusicPerformance8_Vtbl;
739 obj->pDirectMusic = NULL;
740 obj->pDirectSound = NULL;
741 obj->pDefaultPath = NULL;
743 return IDirectMusicPerformance8Impl_QueryInterface ((LPDIRECTMUSICPERFORMANCE8)obj, lpcGUID, ppobj);