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.
24 #include "wine/debug.h"
26 #include "dmime_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(dmime
);
30 /* IDirectMusicPerformance8 IUnknown part: */
31 HRESULT WINAPI
IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface
, REFIID riid
, LPVOID
*ppobj
)
33 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
35 if (IsEqualIID (riid
, &IID_IUnknown
) ||
36 IsEqualIID (riid
, &IID_IDirectMusicPerformance
) ||
37 IsEqualIID (riid
, &IID_IDirectMusicPerformance8
)) {
38 IDirectMusicPerformance8Impl_AddRef(iface
);
43 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
47 ULONG WINAPI
IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface
)
49 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
50 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
54 ULONG WINAPI
IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface
)
56 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
57 ULONG ref
= --This
->ref
;
58 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
60 HeapFree(GetProcessHeap(), 0, This
);
65 /* IDirectMusicPerformance8 IDirectMusicPerformance Interface part: */
66 HRESULT WINAPI
IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusic
** ppDirectMusic
, LPDIRECTSOUND pDirectSound
, HWND hWnd
)
68 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
70 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This
, ppDirectMusic
, pDirectSound
, hWnd
);
71 if (This
->pDirectMusic
|| This
->pDirectSound
)
72 return DMUS_E_ALREADY_INITED
;
74 if (NULL
!= pDirectSound
) {
75 This
->pDirectSound
= (IDirectSound
*) pDirectSound
;
76 IDirectSound_AddRef((LPDIRECTSOUND
) This
->pDirectSound
);
78 DirectSoundCreate8(&IID_IDirectSound8
, (LPDIRECTSOUND8
*) &This
->pDirectSound
, NULL
);
79 if (!This
->pDirectSound
)
80 return DSERR_NODRIVER
;
83 if (NULL
!= ppDirectMusic
&& NULL
!= *ppDirectMusic
) {
84 /* app creates it's own dmusic object and gives it to performance */
85 This
->pDirectMusic
= (IDirectMusic8
*) *ppDirectMusic
;
86 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) This
->pDirectMusic
);
88 /* app allows the performance to initialise itfself and needs a pointer to object*/
89 CoCreateInstance (&CLSID_DirectMusic
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusic8
, (void**)&This
->pDirectMusic
);
91 *ppDirectMusic
= (LPDIRECTMUSIC
) This
->pDirectMusic
;
92 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) *ppDirectMusic
);
99 HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
)
101 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
103 FIXME("(%p, %p, %ld, %lli, %p): stub\n", This
, pSegment
, dwFlags
, i64StartTime
, ppSegmentState
);
108 HRESULT WINAPI
IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegmentState
, MUSIC_TIME mtTime
, DWORD dwFlags
)
110 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
112 FIXME("(%p, %p, %p, %ld, %ld): stub\n", This
, pSegment
, pSegmentState
, mtTime
, dwFlags
);
117 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegmentState
** ppSegmentState
, MUSIC_TIME mtTime
)
119 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
121 FIXME("(%p,%p, %ld): stub\n", This
, ppSegmentState
, mtTime
);
126 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
)
128 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
130 FIXME("(%p, %ld): stub\n", This
, dwMilliSeconds
);
135 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
)
137 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
139 FIXME("(%p, %p): stub\n", This
, pdwMilliSeconds
);
144 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
)
146 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
148 FIXME("(%p, %ld): stub\n", This
, dwMilliSeconds
);
153 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
)
155 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
157 FIXME("(%p, %p): stub\n", This
, pdwMilliSeconds
);
162 HRESULT WINAPI
IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
)
164 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
166 FIXME("(%p, %p): stub\n", This
, pPMSG
);
171 HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, REFERENCE_TIME
* prtTime
)
173 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
175 FIXME("(%p, %ld, %p): stub\n", This
, mtTime
, prtTime
);
180 HRESULT WINAPI
IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, MUSIC_TIME
* pmtTime
)
182 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
184 FIXME("(%p, %lli, %p): stub\n", This
, rtTime
, pmtTime
);
189 HRESULT WINAPI
IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegState
)
191 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
193 FIXME("(%p, %p, %p): stub\n", This
, pSegment
, pSegState
);
198 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtNow
, MUSIC_TIME
* pmtNow
)
200 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
202 FIXME("(%p, %p, %p): stub\n", This
, prtNow
, pmtNow
);
207 HRESULT WINAPI
IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, ULONG cb
, DMUS_PMSG
** ppPMSG
)
209 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
211 FIXME("(%p, %ld, %p): stub\n", This
, cb
, ppPMSG
);
216 HRESULT WINAPI
IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
)
218 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
220 FIXME("(%p, %p): stub\n", This
, pPMSG
);
225 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
** ppGraph
)
227 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
229 FIXME("(%p, %p): to check\n", This
, ppGraph
);
231 if (NULL
!= This
->pToolGraph
) {
232 *ppGraph
= (LPDIRECTMUSICGRAPH
) This
->pToolGraph
;
233 IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH
) *ppGraph
);
238 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
* pGraph
)
240 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
242 FIXME("(%p, %p): to check\n", This
, pGraph
);
244 if (NULL
!= This
->pToolGraph
) {
245 /* Todo clean buffers and tools before */
246 IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH
) This
->pToolGraph
);
248 This
->pToolGraph
= pGraph
;
249 if (NULL
!= This
->pToolGraph
) {
250 IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH
) This
->pToolGraph
);
255 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface
, HANDLE hNotification
, REFERENCE_TIME rtMinimum
)
257 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
259 FIXME("(%p, %p, %lli): stub\n", This
, hNotification
, rtMinimum
);
264 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_NOTIFICATION_PMSG
** ppNotificationPMsg
)
266 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
268 FIXME("(%p, %p): stub\n", This
, ppNotificationPMsg
);
273 HRESULT WINAPI
IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
)
275 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
277 FIXME("(%p, %s): stub\n", This
, debugstr_guid(rguidNotificationType
));
282 HRESULT WINAPI
IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
)
284 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
286 FIXME("(%p, %s): stub\n", This
, debugstr_guid(rguidNotificationType
));
291 HRESULT WINAPI
IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
)
293 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
295 FIXME("(%p, %p): stub\n", This
, pPort
);
296 IDirectMusicPort_AddRef (pPort
);
301 HRESULT WINAPI
IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
)
303 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
305 FIXME("(%p, %p): stub\n", This
, pPort
);
306 IDirectMusicPort_Release (pPort
);
311 HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwBlockNum
, IDirectMusicPort
* pPort
, DWORD dwGroup
)
313 int i
, j
, range
/* min value in range */;
314 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
316 FIXME("(%p, %ld, %p, %ld): semi-stub\n", This
, dwBlockNum
, pPort
, dwGroup
-1);
317 range
= 16 * dwBlockNum
;
320 for (i
= range
; i
< range
+16; i
++) {
321 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
322 This
->PChannel
[i
].port
= pPort
;
323 This
->PChannel
[i
].group
= dwGroup
- 1; /* first index is always zero */
324 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
331 HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
* pPort
, DWORD dwGroup
, DWORD dwMChannel
)
333 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
335 TRACE("(%p, %ld, %p, %ld, %ld)\n", This
, dwPChannel
, pPort
, dwGroup
, dwMChannel
);
336 This
->PChannel
[dwPChannel
].port
= pPort
;
337 This
->PChannel
[dwPChannel
].group
= dwGroup
;
338 This
->PChannel
[dwPChannel
].channel
= dwMChannel
;
343 HRESULT WINAPI
IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
)
345 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
347 FIXME("(%p, %ld, %p, %p, %p): stub\n", This
, dwPChannel
, ppPort
, pdwGroup
, pdwMChannel
);
352 HRESULT WINAPI
IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicInstrument
* pInst
, DWORD dwPChannel
, IDirectMusicDownloadedInstrument
** ppDownInst
, DMUS_NOTERANGE
* pNoteRanges
, DWORD dwNumNoteRanges
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
)
354 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
356 FIXME("(%p, %p, %ld, %p, %p, %ld, %p, %p, %p): stub\n", This
, pInst
, dwPChannel
, ppDownInst
, pNoteRanges
, dwNumNoteRanges
, ppPort
, pdwGroup
, pdwMChannel
);
361 HRESULT WINAPI
IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DWORD dwFlags
)
363 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
365 FIXME("(%p, %ld, %ld): stub\n", This
, mtTime
, dwFlags
);
370 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
)
372 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
374 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This
, debugstr_guid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
379 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, void* pParam
)
381 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
383 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This
, debugstr_guid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pParam
);
388 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
)
390 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
392 TRACE("(%p, %s, %p, %ld): stub\n", This
, debugstr_guid(rguidType
), pParam
, dwSize
);
394 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
))
395 memcpy(pParam
, &This
->fAutoDownload
, sizeof(&This
->fAutoDownload
));
396 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
))
397 memcpy(pParam
, &This
->cMasterGrooveLevel
, sizeof(&This
->cMasterGrooveLevel
));
398 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
))
399 memcpy(pParam
, &This
->fMasterTempo
, sizeof(&This
->fMasterTempo
));
400 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
))
401 memcpy(pParam
, &This
->lMasterVolume
, sizeof(&This
->lMasterVolume
));
406 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
)
408 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
410 TRACE("(%p, %s, %p, %ld)\n", This
, debugstr_guid(rguidType
), pParam
, dwSize
);
412 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
)) {
413 memcpy(&This
->fAutoDownload
, pParam
, dwSize
);
414 TRACE("=> AutoDownload set to %d\n", This
->fAutoDownload
);
416 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
)) {
417 memcpy(&This
->cMasterGrooveLevel
, pParam
, dwSize
);
418 TRACE("=> MasterGrooveLevel set to %i\n", This
->cMasterGrooveLevel
);
420 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
)) {
421 memcpy(&This
->fMasterTempo
, pParam
, dwSize
);
422 TRACE("=> MasterTempo set to %f\n", This
->fMasterTempo
);
424 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
)) {
425 memcpy(&This
->lMasterVolume
, pParam
, dwSize
);
426 TRACE("=> MasterVolume set to %li\n", This
->lMasterVolume
);
432 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
)
434 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
436 FIXME("(%p, %p): stub\n", This
, prtTime
);
441 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
)
443 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
445 FIXME("(%p, %p): stub\n", This
, prtTime
);
450 HRESULT WINAPI
IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtAmount
)
452 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
454 FIXME("(%p, %lli): stub\n", This
, rtAmount
);
459 HRESULT WINAPI
IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface
)
461 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
463 FIXME("(%p): stub\n", This
);
468 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, REFERENCE_TIME
* prtResolved
, DWORD dwTimeResolveFlags
)
470 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
472 FIXME("(%p, %lli, %p, %ld): stub\n", This
, rtTime
, prtResolved
, dwTimeResolveFlags
);
477 HRESULT WINAPI
IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface
, BYTE bMIDIValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, WORD
* pwMusicValue
)
479 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
481 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, bMIDIValue
, pChord
, bPlayMode
, bChordLevel
, pwMusicValue
);
486 HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMusicValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, BYTE
* pbMIDIValue
)
488 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
490 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, wMusicValue
, pChord
, bPlayMode
, bChordLevel
, pbMIDIValue
);
495 HRESULT WINAPI
IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DMUS_TIMESIGNATURE
* pTimeSig
, WORD
* pwMeasure
, BYTE
* pbBeat
, BYTE
* pbGrid
, short* pnOffset
)
497 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
499 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This
, mtTime
, pTimeSig
, pwMeasure
, pbBeat
, pbGrid
, pnOffset
);
504 HRESULT WINAPI
IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMeasure
, BYTE bBeat
, BYTE bGrid
, short nOffset
, DMUS_TIMESIGNATURE
* pTimeSig
, MUSIC_TIME
* pmtTime
)
506 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
508 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This
, wMeasure
, bBeat
, bGrid
, nOffset
, pTimeSig
, pmtTime
);
513 /* IDirectMusicPerformance8 Interface part follow: */
514 HRESULT WINAPI
IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 iface
,
515 IDirectMusic
** ppDirectMusic
,
516 IDirectSound
** ppDirectSound
,
518 DWORD dwDefaultPathType
,
519 DWORD dwPChannelCount
,
521 DMUS_AUDIOPARAMS
* pParams
)
523 IDirectSound
* dsound
;
525 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
526 FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This
, ppDirectMusic
, ppDirectSound
, hWnd
, dwDefaultPathType
, dwPChannelCount
, dwFlags
, pParams
);
528 if (This
->pDirectMusic
|| This
->pDirectSound
)
529 return DMUS_E_ALREADY_INITED
;
531 if (NULL
!= ppDirectSound
&& NULL
!= *ppDirectSound
) {
532 dsound
= *ppDirectSound
;
534 DirectSoundCreate8 (&IID_IDirectSound8
, (LPDIRECTSOUND8
*) &dsound
, NULL
);
536 return DSERR_NODRIVER
;
538 *ppDirectSound
= dsound
;
541 IDirectMusicPerformance8Impl_Init(iface
, ppDirectMusic
, dsound
, hWnd
);
543 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
545 IDirectSound_Release(This
->pDirectSound
);
547 /* as seen in msdn we need params init before audio path creation */
548 if (NULL
!= pParams
) {
549 memcpy(&This
->pParams
, pParams
, sizeof(DMUS_AUDIOPARAMS
));
551 /* TODO, how can i fill the struct */
553 IDirectMusicPerformance8ImplCreateStandardAudioPath(iface
, dwDefaultPathType
, dwPChannelCount
, FALSE
, (IDirectMusicAudioPath
**) &This
->pDefaultPath
);
558 HRESULT WINAPI
IDirectMusicPerformance8ImplPlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSource
, WCHAR
* pwzSegmentName
, IUnknown
* pTransition
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
, IUnknown
* pFrom
, IUnknown
* pAudioPath
)
560 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
562 FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This
, pSource
, pwzSegmentName
, pTransition
, dwFlags
, i64StartTime
, ppSegmentState
, pFrom
, pAudioPath
);
567 HRESULT WINAPI
IDirectMusicPerformance8ImplStopEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pObjectToStop
, __int64 i64StopTime
, DWORD dwFlags
)
569 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
571 FIXME("(%p, %p, %lli, %ld): stub\n", This
, pObjectToStop
, i64StopTime
, dwFlags
);
576 HRESULT WINAPI
IDirectMusicPerformance8ImplClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pSourcePMSG
, DMUS_PMSG
** ppCopyPMSG
)
578 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
580 FIXME("(%p, %p, %p): stub\n", This
, pSourcePMSG
, ppCopyPMSG
);
585 HRESULT WINAPI
IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSourceConfig
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
)
587 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
589 FIXME("(%p, %p, %d, %p): stub\n", This
, pSourceConfig
, fActivate
, ppNewPath
);
594 HRESULT WINAPI
IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwType
, DWORD dwPChannelCount
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
)
596 IDirectMusicAudioPathImpl
*default_path
;
599 LPDIRECTSOUNDBUFFER8 buffer
;
601 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
603 FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This
, dwType
, dwPChannelCount
, fActivate
, ppNewPath
);
605 default_path
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicAudioPathImpl
));
606 if (NULL
== default_path
) {
607 *ppNewPath
= (LPDIRECTMUSICAUDIOPATH
) NULL
;
608 return E_OUTOFMEMORY
;
610 default_path
->lpVtbl
= &DirectMusicAudioPath_Vtbl
;
611 default_path
->ref
= 1;
612 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
614 /* Secondary buffer description */
615 format
.wFormatTag
= WAVE_FORMAT_PCM
;
616 format
.nChannels
= 1;
617 format
.nSamplesPerSec
= 44000;
618 format
.nAvgBytesPerSec
= 44000*2;
619 format
.nBlockAlign
= 2;
620 format
.wBitsPerSample
= 16;
623 desc
.dwSize
= sizeof(desc
);
625 desc
.dwBufferBytes
= DSBSIZE_MIN
;
627 desc
.lpwfxFormat
= &format
;
628 desc
.guid3DAlgorithm
= GUID_NULL
;
631 case DMUS_APATH_DYNAMIC_3D
:
632 desc
.dwFlags
|= DSBCAPS_CTRL3D
;
634 case DMUS_APATH_DYNAMIC_MONO
:
636 case DMUS_APATH_SHARED_STEREOPLUSREVERB
:
637 case DMUS_APATH_DYNAMIC_STEREO
:
638 format
.nChannels
= 2;
639 format
.nBlockAlign
*= 2;
640 format
.nAvgBytesPerSec
*=2;
646 /* FIXME: Should we create one secondary buffer for each PChannel? */
647 IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
648 default_path
->pDSBuffer
= (IDirectSoundBuffer
*) buffer
;
650 /* Update description for creating primary buffer */
651 desc
.dwFlags
|= DSBCAPS_PRIMARYBUFFER
;
652 desc
.dwBufferBytes
= 0;
653 desc
.lpwfxFormat
= NULL
;
655 IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
657 default_path
->pPrimary
= (IDirectSoundBuffer
*) buffer
;
659 *ppNewPath
= (LPDIRECTMUSICAUDIOPATH
) default_path
;
661 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath
);
666 HRESULT WINAPI
IDirectMusicPerformance8ImplSetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
* pAudioPath
)
668 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
670 FIXME("(%p, %p): semi-stub\n", This
, pAudioPath
);
671 if (NULL
!= This
->pDefaultPath
) {
672 IDirectMusicAudioPathImpl_Release((LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
);
673 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= NULL
;
674 This
->pDefaultPath
= NULL
;
676 This
->pDefaultPath
= pAudioPath
;
677 if (NULL
!= This
->pDefaultPath
) {
678 IDirectMusicAudioPathImpl_AddRef((LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
);
679 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= (IDirectMusicPerformance8
*) This
;
685 HRESULT WINAPI
IDirectMusicPerformance8ImplGetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
** ppAudioPath
)
687 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
689 FIXME("(%p, %p): semi-stub\n", This
, ppAudioPath
);
691 if (NULL
!= This
->pDefaultPath
) {
692 *ppAudioPath
= (LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
;
693 IDirectMusicAudioPathImpl_AddRef(*ppAudioPath
);
700 HRESULT WINAPI
IDirectMusicPerformance8ImplGetParamEx (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwTrackID
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
)
702 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
704 FIXME("(%p, %s, %ld, %ld, %ld, %ld, %p, %p): stub\n", This
, debugstr_guid(rguidType
), dwTrackID
, dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
709 ICOM_VTABLE(IDirectMusicPerformance8
) DirectMusicPerformance8_Vtbl
=
711 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
712 IDirectMusicPerformance8Impl_QueryInterface
,
713 IDirectMusicPerformance8Impl_AddRef
,
714 IDirectMusicPerformance8Impl_Release
,
715 IDirectMusicPerformance8Impl_Init
,
716 IDirectMusicPerformance8Impl_PlaySegment
,
717 IDirectMusicPerformance8Impl_Stop
,
718 IDirectMusicPerformance8Impl_GetSegmentState
,
719 IDirectMusicPerformance8Impl_SetPrepareTime
,
720 IDirectMusicPerformance8Impl_GetPrepareTime
,
721 IDirectMusicPerformance8Impl_SetBumperLength
,
722 IDirectMusicPerformance8Impl_GetBumperLength
,
723 IDirectMusicPerformance8Impl_SendPMsg
,
724 IDirectMusicPerformance8Impl_MusicToReferenceTime
,
725 IDirectMusicPerformance8Impl_ReferenceToMusicTime
,
726 IDirectMusicPerformance8Impl_IsPlaying
,
727 IDirectMusicPerformance8Impl_GetTime
,
728 IDirectMusicPerformance8Impl_AllocPMsg
,
729 IDirectMusicPerformance8Impl_FreePMsg
,
730 IDirectMusicPerformance8Impl_GetGraph
,
731 IDirectMusicPerformance8Impl_SetGraph
,
732 IDirectMusicPerformance8Impl_SetNotificationHandle
,
733 IDirectMusicPerformance8Impl_GetNotificationPMsg
,
734 IDirectMusicPerformance8Impl_AddNotificationType
,
735 IDirectMusicPerformance8Impl_RemoveNotificationType
,
736 IDirectMusicPerformance8Impl_AddPort
,
737 IDirectMusicPerformance8Impl_RemovePort
,
738 IDirectMusicPerformance8Impl_AssignPChannelBlock
,
739 IDirectMusicPerformance8Impl_AssignPChannel
,
740 IDirectMusicPerformance8Impl_PChannelInfo
,
741 IDirectMusicPerformance8Impl_DownloadInstrument
,
742 IDirectMusicPerformance8Impl_Invalidate
,
743 IDirectMusicPerformance8Impl_GetParam
,
744 IDirectMusicPerformance8Impl_SetParam
,
745 IDirectMusicPerformance8Impl_GetGlobalParam
,
746 IDirectMusicPerformance8Impl_SetGlobalParam
,
747 IDirectMusicPerformance8Impl_GetLatencyTime
,
748 IDirectMusicPerformance8Impl_GetQueueTime
,
749 IDirectMusicPerformance8Impl_AdjustTime
,
750 IDirectMusicPerformance8Impl_CloseDown
,
751 IDirectMusicPerformance8Impl_GetResolvedTime
,
752 IDirectMusicPerformance8Impl_MIDIToMusic
,
753 IDirectMusicPerformance8Impl_MusicToMIDI
,
754 IDirectMusicPerformance8Impl_TimeToRhythm
,
755 IDirectMusicPerformance8Impl_RhythmToTime
,
756 IDirectMusicPerformance8ImplInitAudio
,
757 IDirectMusicPerformance8ImplPlaySegmentEx
,
758 IDirectMusicPerformance8ImplStopEx
,
759 IDirectMusicPerformance8ImplClonePMsg
,
760 IDirectMusicPerformance8ImplCreateAudioPath
,
761 IDirectMusicPerformance8ImplCreateStandardAudioPath
,
762 IDirectMusicPerformance8ImplSetDefaultAudioPath
,
763 IDirectMusicPerformance8ImplGetDefaultAudioPath
,
764 IDirectMusicPerformance8ImplGetParamEx
767 /* for ClassFactory */
768 HRESULT WINAPI
DMUSIC_CreateDirectMusicPerformance (LPCGUID lpcGUID
, LPDIRECTMUSICPERFORMANCE8
*ppDMPerf
, LPUNKNOWN pUnkOuter
)
770 IDirectMusicPerformance8Impl
*pPerf
;
772 TRACE("(%p,%p,%p)\n",lpcGUID
, ppDMPerf
, pUnkOuter
);
773 if (IsEqualIID (lpcGUID
, &IID_IDirectMusicPerformance
) ||
774 IsEqualIID (lpcGUID
, &IID_IDirectMusicPerformance8
)) {
775 pPerf
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicPerformance8Impl
));
778 *ppDMPerf
= (LPDIRECTMUSICPERFORMANCE8
)NULL
;
779 return E_OUTOFMEMORY
;
781 pPerf
->lpVtbl
= &DirectMusicPerformance8_Vtbl
;
783 pPerf
->pDirectMusic
= NULL
;
784 pPerf
->pDirectSound
= NULL
;
785 pPerf
->pDefaultPath
= NULL
;
787 *ppDMPerf
= (LPDIRECTMUSICPERFORMANCE8
) pPerf
;
790 WARN("No interface found\n");
792 return E_NOINTERFACE
;