1 /* IDirectMusicPerformance 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.
26 #include "wine/debug.h"
28 #include "dmime_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(dmime
);
32 /* IDirectMusicPerformance8 IUnknown part: */
33 HRESULT WINAPI
IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface
, REFIID riid
, LPVOID
*ppobj
)
35 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
37 if (IsEqualIID (riid
, &IID_IUnknown
) ||
38 IsEqualIID (riid
, &IID_IDirectMusicPerformance
) ||
39 IsEqualIID (riid
, &IID_IDirectMusicPerformance8
)) {
40 IDirectMusicPerformance8Impl_AddRef(iface
);
45 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
49 ULONG WINAPI
IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface
)
51 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
52 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
56 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 /* IDirectMusicPerformance8 IDirectMusicPerformance Interface part: */
68 HRESULT WINAPI
IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusic
** ppDirectMusic
, LPDIRECTSOUND pDirectSound
, HWND hWnd
)
70 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
72 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This
, ppDirectMusic
, pDirectSound
, hWnd
);
73 if (This
->pDirectMusic
|| This
->pDirectSound
)
74 return DMUS_E_ALREADY_INITED
;
76 if (NULL
!= pDirectSound
) {
77 This
->pDirectSound
= (IDirectSound
*) pDirectSound
;
78 IDirectSound_AddRef((LPDIRECTSOUND
) This
->pDirectSound
);
80 DirectSoundCreate8(&IID_IDirectSound8
, (LPDIRECTSOUND8
*) &This
->pDirectSound
, NULL
);
84 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp
87 IDirectSound8_SetCooperativeLevel(This
->pDirectSound
, hWnd
, DSSCL_PRIORITY
);
89 /* how to get the ForeGround window handle ? */
90 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
92 if (!This
->pDirectSound
)
93 return DSERR_NODRIVER
;
96 if (NULL
!= ppDirectMusic
&& NULL
!= *ppDirectMusic
) {
97 /* app creates it's own dmusic object and gives it to performance */
98 This
->pDirectMusic
= (IDirectMusic8
*) *ppDirectMusic
;
99 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) This
->pDirectMusic
);
101 /* app allows the performance to initialise itfself and needs a pointer to object*/
102 CoCreateInstance (&CLSID_DirectMusic
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusic8
, (void**)&This
->pDirectMusic
);
104 *ppDirectMusic
= (LPDIRECTMUSIC
) This
->pDirectMusic
;
105 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) *ppDirectMusic
);
112 HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
)
114 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
116 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
)
123 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
125 FIXME("(%p, %p, %p, %ld, %ld): stub\n", This
, pSegment
, pSegmentState
, mtTime
, dwFlags
);
130 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegmentState
** ppSegmentState
, MUSIC_TIME mtTime
)
132 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
134 FIXME("(%p,%p, %ld): stub\n", This
, ppSegmentState
, mtTime
);
139 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
)
141 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
143 FIXME("(%p, %ld): stub\n", This
, dwMilliSeconds
);
148 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
)
150 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
152 FIXME("(%p, %p): stub\n", This
, pdwMilliSeconds
);
157 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
)
159 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
161 FIXME("(%p, %ld): stub\n", This
, dwMilliSeconds
);
166 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
)
168 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
170 FIXME("(%p, %p): stub\n", This
, pdwMilliSeconds
);
175 HRESULT WINAPI
IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
)
177 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
179 FIXME("(%p, %p): stub\n", This
, pPMSG
);
184 HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, REFERENCE_TIME
* prtTime
)
186 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
188 FIXME("(%p, %ld, %p): stub\n", This
, mtTime
, prtTime
);
193 HRESULT WINAPI
IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, MUSIC_TIME
* pmtTime
)
195 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
197 FIXME("(%p, %lli, %p): stub\n", This
, rtTime
, pmtTime
);
202 HRESULT WINAPI
IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegState
)
204 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
206 FIXME("(%p, %p, %p): stub\n", This
, pSegment
, pSegState
);
211 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtNow
, MUSIC_TIME
* pmtNow
)
213 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
215 FIXME("(%p, %p, %p): stub\n", This
, prtNow
, pmtNow
);
220 HRESULT WINAPI
IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, ULONG cb
, DMUS_PMSG
** ppPMSG
)
222 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
224 FIXME("(%p, %ld, %p): stub\n", This
, cb
, ppPMSG
);
229 HRESULT WINAPI
IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
)
231 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
233 FIXME("(%p, %p): stub\n", This
, pPMSG
);
238 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
** ppGraph
)
240 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
242 FIXME("(%p, %p): to check\n", This
, ppGraph
);
244 if (NULL
!= This
->pToolGraph
) {
245 *ppGraph
= (LPDIRECTMUSICGRAPH
) This
->pToolGraph
;
246 IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH
) *ppGraph
);
251 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
* pGraph
)
253 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
255 FIXME("(%p, %p): to check\n", This
, pGraph
);
257 if (NULL
!= This
->pToolGraph
) {
258 /* Todo clean buffers and tools before */
259 IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH
) This
->pToolGraph
);
261 This
->pToolGraph
= pGraph
;
262 if (NULL
!= This
->pToolGraph
) {
263 IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH
) This
->pToolGraph
);
268 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface
, HANDLE hNotification
, REFERENCE_TIME rtMinimum
)
270 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
272 FIXME("(%p, %p, %lli): stub\n", This
, hNotification
, rtMinimum
);
277 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_NOTIFICATION_PMSG
** ppNotificationPMsg
)
279 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
281 FIXME("(%p, %p): stub\n", This
, ppNotificationPMsg
);
286 HRESULT WINAPI
IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
)
288 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
290 FIXME("(%p, %s): stub\n", This
, debugstr_guid(rguidNotificationType
));
295 HRESULT WINAPI
IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
)
297 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
299 FIXME("(%p, %s): stub\n", This
, debugstr_guid(rguidNotificationType
));
304 HRESULT WINAPI
IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
)
306 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
308 FIXME("(%p, %p): stub\n", This
, pPort
);
309 IDirectMusicPort_AddRef (pPort
);
314 HRESULT WINAPI
IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
)
316 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
318 FIXME("(%p, %p): stub\n", This
, pPort
);
319 IDirectMusicPort_Release (pPort
);
324 HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwBlockNum
, IDirectMusicPort
* pPort
, DWORD dwGroup
)
326 int i
, j
, range
/* min value in range */;
327 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
329 FIXME("(%p, %ld, %p, %ld): semi-stub\n", This
, dwBlockNum
, pPort
, dwGroup
-1);
330 range
= 16 * dwBlockNum
;
333 for (i
= range
; i
< range
+16; i
++) {
334 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
335 This
->PChannel
[i
].port
= pPort
;
336 This
->PChannel
[i
].group
= dwGroup
- 1; /* first index is always zero */
337 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
344 HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
* pPort
, DWORD dwGroup
, DWORD dwMChannel
)
346 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
348 TRACE("(%p, %ld, %p, %ld, %ld)\n", This
, dwPChannel
, pPort
, dwGroup
, dwMChannel
);
349 This
->PChannel
[dwPChannel
].port
= pPort
;
350 This
->PChannel
[dwPChannel
].group
= dwGroup
;
351 This
->PChannel
[dwPChannel
].channel
= dwMChannel
;
356 HRESULT WINAPI
IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
)
358 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
360 FIXME("(%p, %ld, %p, %p, %p): stub\n", This
, dwPChannel
, ppPort
, pdwGroup
, pdwMChannel
);
365 HRESULT WINAPI
IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicInstrument
* pInst
, DWORD dwPChannel
, IDirectMusicDownloadedInstrument
** ppDownInst
, DMUS_NOTERANGE
* pNoteRanges
, DWORD dwNumNoteRanges
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
)
367 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
369 FIXME("(%p, %p, %ld, %p, %p, %ld, %p, %p, %p): stub\n", This
, pInst
, dwPChannel
, ppDownInst
, pNoteRanges
, dwNumNoteRanges
, ppPort
, pdwGroup
, pdwMChannel
);
374 HRESULT WINAPI
IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DWORD dwFlags
)
376 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
378 FIXME("(%p, %ld, %ld): stub\n", This
, mtTime
, dwFlags
);
383 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
)
385 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
387 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This
, debugstr_guid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
392 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, void* pParam
)
394 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
396 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This
, debugstr_guid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pParam
);
401 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
)
403 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
405 TRACE("(%p, %s, %p, %ld): stub\n", This
, debugstr_guid(rguidType
), pParam
, dwSize
);
407 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
))
408 memcpy(pParam
, &This
->fAutoDownload
, sizeof(&This
->fAutoDownload
));
409 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
))
410 memcpy(pParam
, &This
->cMasterGrooveLevel
, sizeof(&This
->cMasterGrooveLevel
));
411 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
))
412 memcpy(pParam
, &This
->fMasterTempo
, sizeof(&This
->fMasterTempo
));
413 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
))
414 memcpy(pParam
, &This
->lMasterVolume
, sizeof(&This
->lMasterVolume
));
419 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
)
421 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
423 TRACE("(%p, %s, %p, %ld)\n", This
, debugstr_guid(rguidType
), pParam
, dwSize
);
425 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
)) {
426 memcpy(&This
->fAutoDownload
, pParam
, dwSize
);
427 TRACE("=> AutoDownload set to %d\n", This
->fAutoDownload
);
429 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
)) {
430 memcpy(&This
->cMasterGrooveLevel
, pParam
, dwSize
);
431 TRACE("=> MasterGrooveLevel set to %i\n", This
->cMasterGrooveLevel
);
433 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
)) {
434 memcpy(&This
->fMasterTempo
, pParam
, dwSize
);
435 TRACE("=> MasterTempo set to %f\n", This
->fMasterTempo
);
437 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
)) {
438 memcpy(&This
->lMasterVolume
, pParam
, dwSize
);
439 TRACE("=> MasterVolume set to %li\n", This
->lMasterVolume
);
445 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
)
447 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
449 FIXME("(%p, %p): stub\n", This
, prtTime
);
454 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
)
456 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
458 FIXME("(%p, %p): stub\n", This
, prtTime
);
463 HRESULT WINAPI
IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtAmount
)
465 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
467 FIXME("(%p, %lli): stub\n", This
, rtAmount
);
472 HRESULT WINAPI
IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface
)
474 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
476 FIXME("(%p): stub\n", This
);
481 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, REFERENCE_TIME
* prtResolved
, DWORD dwTimeResolveFlags
)
483 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
485 FIXME("(%p, %lli, %p, %ld): stub\n", This
, rtTime
, prtResolved
, dwTimeResolveFlags
);
490 HRESULT WINAPI
IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface
, BYTE bMIDIValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, WORD
* pwMusicValue
)
492 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
494 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, bMIDIValue
, pChord
, bPlayMode
, bChordLevel
, pwMusicValue
);
499 HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMusicValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, BYTE
* pbMIDIValue
)
501 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
503 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, wMusicValue
, pChord
, bPlayMode
, bChordLevel
, pbMIDIValue
);
508 HRESULT WINAPI
IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DMUS_TIMESIGNATURE
* pTimeSig
, WORD
* pwMeasure
, BYTE
* pbBeat
, BYTE
* pbGrid
, short* pnOffset
)
510 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
512 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This
, mtTime
, pTimeSig
, pwMeasure
, pbBeat
, pbGrid
, pnOffset
);
517 HRESULT WINAPI
IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMeasure
, BYTE bBeat
, BYTE bGrid
, short nOffset
, DMUS_TIMESIGNATURE
* pTimeSig
, MUSIC_TIME
* pmtTime
)
519 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
521 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This
, wMeasure
, bBeat
, bGrid
, nOffset
, pTimeSig
, pmtTime
);
526 /* IDirectMusicPerformance8 Interface part follow: */
527 HRESULT WINAPI
IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 iface
,
528 IDirectMusic
** ppDirectMusic
,
529 IDirectSound
** ppDirectSound
,
531 DWORD dwDefaultPathType
,
532 DWORD dwPChannelCount
,
534 DMUS_AUDIOPARAMS
* pParams
)
536 IDirectSound
* dsound
;
539 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
540 FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This
, ppDirectMusic
, ppDirectSound
, hWnd
, dwDefaultPathType
, dwPChannelCount
, dwFlags
, pParams
);
542 if (This
->pDirectMusic
|| This
->pDirectSound
)
543 return DMUS_E_ALREADY_INITED
;
545 if (NULL
!= ppDirectSound
&& NULL
!= *ppDirectSound
) {
546 dsound
= *ppDirectSound
;
548 DirectSoundCreate8 (&IID_IDirectSound8
, (LPDIRECTSOUND8
*) &dsound
, NULL
);
550 return DSERR_NODRIVER
;
552 *ppDirectSound
= dsound
;
555 IDirectMusicPerformance8Impl_Init(iface
, ppDirectMusic
, dsound
, hWnd
);
557 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
559 IDirectSound_Release(This
->pDirectSound
);
561 /* as seen in msdn we need params init before audio path creation */
562 if (NULL
!= pParams
) {
563 memcpy(&This
->pParams
, pParams
, sizeof(DMUS_AUDIOPARAMS
));
566 * TODO, how can i fill the struct
567 * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp
569 This
->pParams
.dwSize
= sizeof(DMUS_AUDIOPARAMS
);
570 This
->pParams
.fInitNow
= FALSE
;
571 This
->pParams
.dwValidData
= DMUS_AUDIOPARAMS_FEATURES
| DMUS_AUDIOPARAMS_VOICES
| DMUS_AUDIOPARAMS_SAMPLERATE
| DMUS_AUDIOPARAMS_DEFAULTSYNTH
;
572 This
->pParams
.dwVoices
= 64;
573 This
->pParams
.dwSampleRate
= (DWORD
) 22.050;
574 This
->pParams
.dwFeatures
= dwFlags
;
575 This
->pParams
.clsidDefaultSynth
= CLSID_DirectMusicSynthSink
;
577 hr
= IDirectMusicPerformance8ImplCreateStandardAudioPath(iface
, dwDefaultPathType
, dwPChannelCount
, FALSE
, (IDirectMusicAudioPath
**) &This
->pDefaultPath
);
582 HRESULT WINAPI
IDirectMusicPerformance8ImplPlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSource
, WCHAR
* pwzSegmentName
, IUnknown
* pTransition
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
, IUnknown
* pFrom
, IUnknown
* pAudioPath
)
584 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
586 FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This
, pSource
, pwzSegmentName
, pTransition
, dwFlags
, i64StartTime
, ppSegmentState
, pFrom
, pAudioPath
);
591 HRESULT WINAPI
IDirectMusicPerformance8ImplStopEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pObjectToStop
, __int64 i64StopTime
, DWORD dwFlags
)
593 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
595 FIXME("(%p, %p, %lli, %ld): stub\n", This
, pObjectToStop
, i64StopTime
, dwFlags
);
600 HRESULT WINAPI
IDirectMusicPerformance8ImplClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pSourcePMSG
, DMUS_PMSG
** ppCopyPMSG
)
602 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
604 FIXME("(%p, %p, %p): stub\n", This
, pSourcePMSG
, ppCopyPMSG
);
609 HRESULT WINAPI
IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSourceConfig
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
)
611 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
613 FIXME("(%p, %p, %d, %p): stub\n", This
, pSourceConfig
, fActivate
, ppNewPath
);
619 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp
621 HRESULT WINAPI
IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwType
, DWORD dwPChannelCount
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
)
623 IDirectMusicAudioPathImpl
*default_path
;
626 LPDIRECTSOUNDBUFFER8 buffer
;
629 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
631 FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This
, dwType
, dwPChannelCount
, fActivate
, ppNewPath
);
633 if (NULL
== ppNewPath
) {
636 default_path
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicAudioPathImpl
));
637 if (NULL
== default_path
) {
638 *ppNewPath
= (LPDIRECTMUSICAUDIOPATH
) NULL
;
639 return E_OUTOFMEMORY
;
641 default_path
->lpVtbl
= &DirectMusicAudioPath_Vtbl
;
642 default_path
->ref
= 1;
643 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
645 /* Secondary buffer description */
646 format
.wFormatTag
= WAVE_FORMAT_PCM
;
647 format
.nChannels
= 1;
648 format
.nSamplesPerSec
= 44000;
649 format
.nAvgBytesPerSec
= 44000*2;
650 format
.nBlockAlign
= 2;
651 format
.wBitsPerSample
= 16;
654 desc
.dwSize
= sizeof(desc
);
655 desc
.dwFlags
= DSBCAPS_CTRLFX
| DSBCAPS_CTRLPAN
| DSBCAPS_CTRLVOLUME
| DSBCAPS_GLOBALFOCUS
;
656 desc
.dwBufferBytes
= DSBSIZE_MIN
;
658 desc
.lpwfxFormat
= &format
;
659 desc
.guid3DAlgorithm
= GUID_NULL
;
662 case DMUS_APATH_DYNAMIC_3D
:
663 desc
.dwFlags
|= DSBCAPS_CTRL3D
| DSBCAPS_CTRLFREQUENCY
| DSBCAPS_MUTE3DATMAXDISTANCE
;
665 case DMUS_APATH_DYNAMIC_MONO
:
666 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
668 case DMUS_APATH_SHARED_STEREOPLUSREVERB
:
669 /* normally we havet to create 2 buffers (one for music other for reverb)
670 * in this case. See msdn
672 case DMUS_APATH_DYNAMIC_STEREO
:
673 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
674 format
.nChannels
= 2;
675 format
.nBlockAlign
*= 2;
676 format
.nAvgBytesPerSec
*=2;
679 HeapFree(GetProcessHeap(), 0, default_path
);
685 /* FIXME: Should we create one secondary buffer for each PChannel? */
686 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
688 HeapFree(GetProcessHeap(), 0, default_path
);
690 return DSERR_BUFFERLOST
;
692 default_path
->pDSBuffer
= (IDirectSoundBuffer
*) buffer
;
694 /* Update description for creating primary buffer */
695 desc
.dwFlags
|= DSBCAPS_PRIMARYBUFFER
;
696 desc
.dwBufferBytes
= 0;
697 desc
.lpwfxFormat
= NULL
;
699 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
701 IDirectSoundBuffer_Release(default_path
->pDSBuffer
);
702 HeapFree(GetProcessHeap(), 0, default_path
);
704 return DSERR_BUFFERLOST
;
706 default_path
->pPrimary
= (IDirectSoundBuffer
*) buffer
;
708 *ppNewPath
= (LPDIRECTMUSICAUDIOPATH
) default_path
;
710 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath
);
715 HRESULT WINAPI
IDirectMusicPerformance8ImplSetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
* pAudioPath
)
717 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
719 FIXME("(%p, %p): semi-stub\n", This
, pAudioPath
);
720 if (NULL
!= This
->pDefaultPath
) {
721 IDirectMusicAudioPathImpl_Release((LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
);
722 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= NULL
;
723 This
->pDefaultPath
= NULL
;
725 This
->pDefaultPath
= pAudioPath
;
726 if (NULL
!= This
->pDefaultPath
) {
727 IDirectMusicAudioPathImpl_AddRef((LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
);
728 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= (IDirectMusicPerformance8
*) This
;
734 HRESULT WINAPI
IDirectMusicPerformance8ImplGetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
** ppAudioPath
)
736 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
738 FIXME("(%p, %p): semi-stub\n", This
, ppAudioPath
);
740 if (NULL
!= This
->pDefaultPath
) {
741 *ppAudioPath
= (LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
;
742 IDirectMusicAudioPathImpl_AddRef(*ppAudioPath
);
749 HRESULT WINAPI
IDirectMusicPerformance8ImplGetParamEx (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwTrackID
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
)
751 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
753 FIXME("(%p, %s, %ld, %ld, %ld, %ld, %p, %p): stub\n", This
, debugstr_guid(rguidType
), dwTrackID
, dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
758 ICOM_VTABLE(IDirectMusicPerformance8
) DirectMusicPerformance8_Vtbl
=
760 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
761 IDirectMusicPerformance8Impl_QueryInterface
,
762 IDirectMusicPerformance8Impl_AddRef
,
763 IDirectMusicPerformance8Impl_Release
,
764 IDirectMusicPerformance8Impl_Init
,
765 IDirectMusicPerformance8Impl_PlaySegment
,
766 IDirectMusicPerformance8Impl_Stop
,
767 IDirectMusicPerformance8Impl_GetSegmentState
,
768 IDirectMusicPerformance8Impl_SetPrepareTime
,
769 IDirectMusicPerformance8Impl_GetPrepareTime
,
770 IDirectMusicPerformance8Impl_SetBumperLength
,
771 IDirectMusicPerformance8Impl_GetBumperLength
,
772 IDirectMusicPerformance8Impl_SendPMsg
,
773 IDirectMusicPerformance8Impl_MusicToReferenceTime
,
774 IDirectMusicPerformance8Impl_ReferenceToMusicTime
,
775 IDirectMusicPerformance8Impl_IsPlaying
,
776 IDirectMusicPerformance8Impl_GetTime
,
777 IDirectMusicPerformance8Impl_AllocPMsg
,
778 IDirectMusicPerformance8Impl_FreePMsg
,
779 IDirectMusicPerformance8Impl_GetGraph
,
780 IDirectMusicPerformance8Impl_SetGraph
,
781 IDirectMusicPerformance8Impl_SetNotificationHandle
,
782 IDirectMusicPerformance8Impl_GetNotificationPMsg
,
783 IDirectMusicPerformance8Impl_AddNotificationType
,
784 IDirectMusicPerformance8Impl_RemoveNotificationType
,
785 IDirectMusicPerformance8Impl_AddPort
,
786 IDirectMusicPerformance8Impl_RemovePort
,
787 IDirectMusicPerformance8Impl_AssignPChannelBlock
,
788 IDirectMusicPerformance8Impl_AssignPChannel
,
789 IDirectMusicPerformance8Impl_PChannelInfo
,
790 IDirectMusicPerformance8Impl_DownloadInstrument
,
791 IDirectMusicPerformance8Impl_Invalidate
,
792 IDirectMusicPerformance8Impl_GetParam
,
793 IDirectMusicPerformance8Impl_SetParam
,
794 IDirectMusicPerformance8Impl_GetGlobalParam
,
795 IDirectMusicPerformance8Impl_SetGlobalParam
,
796 IDirectMusicPerformance8Impl_GetLatencyTime
,
797 IDirectMusicPerformance8Impl_GetQueueTime
,
798 IDirectMusicPerformance8Impl_AdjustTime
,
799 IDirectMusicPerformance8Impl_CloseDown
,
800 IDirectMusicPerformance8Impl_GetResolvedTime
,
801 IDirectMusicPerformance8Impl_MIDIToMusic
,
802 IDirectMusicPerformance8Impl_MusicToMIDI
,
803 IDirectMusicPerformance8Impl_TimeToRhythm
,
804 IDirectMusicPerformance8Impl_RhythmToTime
,
805 IDirectMusicPerformance8ImplInitAudio
,
806 IDirectMusicPerformance8ImplPlaySegmentEx
,
807 IDirectMusicPerformance8ImplStopEx
,
808 IDirectMusicPerformance8ImplClonePMsg
,
809 IDirectMusicPerformance8ImplCreateAudioPath
,
810 IDirectMusicPerformance8ImplCreateStandardAudioPath
,
811 IDirectMusicPerformance8ImplSetDefaultAudioPath
,
812 IDirectMusicPerformance8ImplGetDefaultAudioPath
,
813 IDirectMusicPerformance8ImplGetParamEx
816 /* for ClassFactory */
817 HRESULT WINAPI
DMUSIC_CreateDirectMusicPerformance (LPCGUID lpcGUID
, LPDIRECTMUSICPERFORMANCE8
*ppDMPerf
, LPUNKNOWN pUnkOuter
)
819 IDirectMusicPerformance8Impl
*pPerf
;
821 TRACE("(%p,%p,%p)\n",lpcGUID
, ppDMPerf
, pUnkOuter
);
822 if (IsEqualIID (lpcGUID
, &IID_IDirectMusicPerformance
) ||
823 IsEqualIID (lpcGUID
, &IID_IDirectMusicPerformance8
)) {
824 pPerf
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicPerformance8Impl
));
827 *ppDMPerf
= (LPDIRECTMUSICPERFORMANCE8
)NULL
;
828 return E_OUTOFMEMORY
;
830 pPerf
->lpVtbl
= &DirectMusicPerformance8_Vtbl
;
832 pPerf
->pDirectMusic
= NULL
;
833 pPerf
->pDirectSound
= NULL
;
834 pPerf
->pDefaultPath
= NULL
;
836 *ppDMPerf
= (LPDIRECTMUSICPERFORMANCE8
) pPerf
;
839 WARN("No interface found\n");
841 return E_NOINTERFACE
;