1 /* IDirectMusicPerformance Implementation
3 * Copyright (C) 2003-2004 Rok Mandeljc
4 * Copyright (C) 2003-2004 Raphael Junqueira
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (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
14 * GNU Library General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "dmime_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmime
);
25 typedef struct DMUS_PMSGItem DMUS_PMSGItem
;
26 struct DMUS_PMSGItem
{
30 REFERENCE_TIME rtItemTime
;
36 #define DMUS_PMSGToItem(pMSG) ((DMUS_PMSGItem*) (((unsigned char*) pPMSG) - offsetof(DMUS_PMSGItem, pMsg)))
37 #define DMUS_ItemToPMSG(pItem) (&(pItem->pMsg))
38 #define DMUS_ItemRemoveFromQueue(This,pItem) \
40 if (pItem->prev) pItem->prev->next = pItem->next;\
41 if (pItem->next) pItem->next->prev = pItem->prev;\
42 if (This->head == pItem) This->head = pItem->next;\
43 if (This->imm_head == pItem) This->imm_head = pItem->next;\
44 pItem->bInUse = FALSE;\
47 #define PROCESSMSG_START (WM_APP + 0)
48 #define PROCESSMSG_EXIT (WM_APP + 1)
49 #define PROCESSMSG_REMOVE (WM_APP + 2)
50 #define PROCESSMSG_ADD (WM_APP + 4)
53 static DMUS_PMSGItem
* ProceedMsg(IDirectMusicPerformance8Impl
* This
, DMUS_PMSGItem
* cur
) {
54 if (cur
->pMsg
.dwType
== DMUS_PMSGT_NOTIFICATION
) {
55 SetEvent(This
->hNotification
);
57 DMUS_ItemRemoveFromQueue(This
, cur
);
58 switch (cur
->pMsg
.dwType
) {
60 case DMUS_PMSGT_TEMPO
:
63 FIXME("Unhandled PMsg Type: 0x%lx\n", cur
->pMsg
.dwType
);
69 static DWORD WINAPI
ProcessMsgThread(LPVOID lpParam
) {
70 IDirectMusicPerformance8Impl
* This
= (IDirectMusicPerformance8Impl
*) lpParam
;
71 DWORD timeOut
= INFINITE
;
74 REFERENCE_TIME rtLastTime
;
75 REFERENCE_TIME rtCurTime
;
76 DMUS_PMSGItem
* it
= NULL
;
77 DMUS_PMSGItem
* cur
= NULL
;
78 DMUS_PMSGItem
* it_next
= NULL
;
81 DWORD dwDec
= This
->rtLatencyTime
+ This
->dwBumperLength
;
83 if (timeOut
> 0) MsgWaitForMultipleObjects(0, NULL
, FALSE
, timeOut
, QS_POSTMESSAGE
|QS_SENDMESSAGE
|QS_TIMER
);
86 EnterCriticalSection(&This
->safe
);
87 rtLastTime
= rtCurTime
;
88 hr
= IDirectMusicPerformance8Impl_GetTime((IDirectMusicPerformance8
*) This
, &rtCurTime
, NULL
);
93 for (it
= This
->imm_head
; NULL
!= it
; ) {
95 cur
= ProceedMsg(This
, it
);
97 HeapFree(GetProcessHeap(), 0, cur
);
102 for (it
= This
->head
; NULL
!= it
&& it
->rtItemTime
< rtCurTime
+ dwDec
; ) {
104 cur
= ProceedMsg(This
, it
);
106 HeapFree(GetProcessHeap(), 0, cur
);
111 timeOut
= ( it
->rtItemTime
- rtCurTime
) + This
->rtLatencyTime
;
115 LeaveCriticalSection(&This
->safe
);
117 while (TRUE
== PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) {
118 /** if hwnd we suppose that is a windows event ... */
119 if (NULL
!= msg
.hwnd
) {
120 TranslateMessage(&msg
);
121 DispatchMessageA(&msg
);
123 switch (msg
.message
) {
125 case PROCESSMSG_EXIT
:
128 case PROCESSMSG_START
:
132 case PROCESSMSG_REMOVE
:
135 ERR("Unhandled message %u. Critical Path\n", msg
.message
);
141 /** here we should run a little of current AudioPath */
146 TRACE("(%p): Exiting\n", This
);
151 static BOOL
PostMessageToProcessMsgThread(IDirectMusicPerformance8Impl
* This
, UINT iMsg
) {
152 if (FALSE
== This
->procThreadTicStarted
&& PROCESSMSG_EXIT
!= iMsg
) {
153 This
->procThread
= CreateThread(NULL
, 0, ProcessMsgThread
, This
, 0, &This
->procThreadId
);
154 if (NULL
== This
->procThread
) return FALSE
;
155 SetThreadPriority(This
->procThread
, THREAD_PRIORITY_TIME_CRITICAL
);
156 This
->procThreadTicStarted
= TRUE
;
158 return PostThreadMessageA(This
->procThreadId
, iMsg
, 0, 0);
161 /* IDirectMusicPerformance8 IUnknown part: */
162 HRESULT WINAPI
IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface
, REFIID riid
, LPVOID
*ppobj
) {
163 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
164 TRACE("(%p, %s,%p)\n", This
, debugstr_dmguid(riid
), ppobj
);
166 if (IsEqualIID (riid
, &IID_IUnknown
) ||
167 IsEqualIID (riid
, &IID_IDirectMusicPerformance
) ||
168 IsEqualIID (riid
, &IID_IDirectMusicPerformance8
)) {
169 IDirectMusicPerformance8Impl_AddRef(iface
);
174 WARN("(%p, %s,%p): not found\n", This
, debugstr_dmguid(riid
), ppobj
);
175 return E_NOINTERFACE
;
178 ULONG WINAPI
IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface
) {
179 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
180 TRACE("(%p): AddRef from %ld\n", This
, This
->ref
);
181 return ++(This
->ref
);
184 ULONG WINAPI
IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface
) {
185 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
186 ULONG ref
= --This
->ref
;
187 TRACE("(%p): ReleaseRef to %ld\n", This
, This
->ref
);
189 DeleteCriticalSection(&This
->safe
);
190 HeapFree(GetProcessHeap(), 0, This
);
195 /* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
196 HRESULT WINAPI
IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusic
** ppDirectMusic
, LPDIRECTSOUND pDirectSound
, HWND hWnd
) {
197 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
199 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This
, ppDirectMusic
, pDirectSound
, hWnd
);
200 if (This
->pDirectMusic
|| This
->pDirectSound
)
201 return DMUS_E_ALREADY_INITED
;
204 hWnd
= GetForegroundWindow();
207 if (NULL
!= pDirectSound
) {
208 This
->pDirectSound
= (IDirectSound
*) pDirectSound
;
209 IDirectSound_AddRef((LPDIRECTSOUND
) This
->pDirectSound
);
211 DirectSoundCreate8(NULL
, (LPDIRECTSOUND8
*) &This
->pDirectSound
, NULL
);
215 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp
218 IDirectSound8_SetCooperativeLevel(This
->pDirectSound
, hWnd
, DSSCL_PRIORITY
);
220 /* how to get the ForeGround window handle ? */
221 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
223 if (!This
->pDirectSound
)
224 return DSERR_NODRIVER
;
227 if (NULL
!= ppDirectMusic
&& NULL
!= *ppDirectMusic
) {
228 /* app creates it's own dmusic object and gives it to performance */
229 This
->pDirectMusic
= (IDirectMusic8
*) *ppDirectMusic
;
230 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) This
->pDirectMusic
);
232 /* app allows the performance to initialise itfself and needs a pointer to object*/
233 CoCreateInstance (&CLSID_DirectMusic
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusic8
, (void**)&This
->pDirectMusic
);
235 *ppDirectMusic
= (LPDIRECTMUSIC
) This
->pDirectMusic
;
236 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) *ppDirectMusic
);
243 HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
) {
244 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
245 FIXME("(%p, %p, %ld, %lli, %p): stub\n", This
, pSegment
, dwFlags
, i64StartTime
, ppSegmentState
);
249 HRESULT WINAPI
IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegmentState
, MUSIC_TIME mtTime
, DWORD dwFlags
) {
250 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
251 FIXME("(%p, %p, %p, %ld, %ld): stub\n", This
, pSegment
, pSegmentState
, mtTime
, dwFlags
);
255 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegmentState
** ppSegmentState
, MUSIC_TIME mtTime
) {
256 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
257 FIXME("(%p,%p, %ld): stub\n", This
, ppSegmentState
, mtTime
);
261 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
) {
262 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
263 TRACE("(%p, %ld)\n", This
, dwMilliSeconds
);
264 This
->dwPrepareTime
= dwMilliSeconds
;
268 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
) {
269 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
270 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
271 if (NULL
== pdwMilliSeconds
) {
274 *pdwMilliSeconds
= This
->dwPrepareTime
;
278 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
) {
279 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
280 TRACE("(%p, %ld)\n", This
, dwMilliSeconds
);
281 This
->dwBumperLength
= dwMilliSeconds
;
285 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
) {
286 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
287 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
288 if (NULL
== pdwMilliSeconds
) {
291 *pdwMilliSeconds
= This
->dwBumperLength
;
295 HRESULT WINAPI
IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
) {
296 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
297 DMUS_PMSGItem
* pItem
= NULL
;
298 DMUS_PMSGItem
* it
= NULL
;
299 DMUS_PMSGItem
* prev_it
= NULL
;
300 DMUS_PMSGItem
** queue
= NULL
;
302 FIXME("(%p, %p): stub\n", This
, pPMSG
);
307 pItem
= DMUS_PMSGToItem(pPMSG
);
311 if (TRUE
== pItem
->bInUse
) {
312 return DMUS_E_ALREADY_SENT
;
315 /* TODO: Valid Flags */
316 /* TODO: DMUS_PMSGF_MUSICTIME */
317 pItem
->rtItemTime
= pPMSG
->rtTime
;
319 if (pPMSG
->dwFlags
& DMUS_PMSGF_TOOL_IMMEDIATE
) {
320 queue
= &This
->imm_head
;
325 EnterCriticalSection(&This
->safe
);
326 for (it
= *queue
; NULL
!= it
&& it
->rtItemTime
< pItem
->rtItemTime
; it
= it
->next
) {
329 if (NULL
== prev_it
) {
331 if (NULL
!= *queue
) pItem
->next
= (*queue
)->next
;
332 /*assert( NULL == pItem->next->prev );*/
333 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
336 pItem
->prev
= prev_it
;
337 pItem
->next
= prev_it
->next
;
338 prev_it
->next
= pItem
;
339 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
341 LeaveCriticalSection(&This
->safe
);
343 /** now in use, prevent from stupid Frees */
344 pItem
->bInUse
= TRUE
;
348 HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, REFERENCE_TIME
* prtTime
) {
349 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
350 FIXME("(%p, %ld, %p): stub\n", This
, mtTime
, prtTime
);
354 HRESULT WINAPI
IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, MUSIC_TIME
* pmtTime
) {
355 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
356 FIXME("(%p, %lli, %p): stub\n", This
, rtTime
, pmtTime
);
360 HRESULT WINAPI
IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegState
) {
361 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
362 FIXME("(%p, %p, %p): stub\n", This
, pSegment
, pSegState
);
366 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtNow
, MUSIC_TIME
* pmtNow
) {
367 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
369 REFERENCE_TIME rtCur
= 0;
371 /*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */
372 if (TRUE
== This
->procThreadTicStarted
) {
373 rtCur
= ((REFERENCE_TIME
) GetTickCount() * 10000) - This
->procThreadStartTime
;
375 /*return DMUS_E_NO_MASTER_CLOCK;*/
377 if (NULL
!= prtNow
) {
380 if (NULL
!= pmtNow
) {
381 hr
= IDirectMusicPerformance8_ReferenceToMusicTime(iface
, rtCur
, pmtNow
);
386 HRESULT WINAPI
IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, ULONG cb
, DMUS_PMSG
** ppPMSG
) {
387 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
388 DMUS_PMSGItem
* pItem
= NULL
;
390 FIXME("(%p, %ld, %p): stub\n", This
, cb
, ppPMSG
);
392 if (sizeof(DMUS_PMSG
) > cb
) {
395 if (NULL
== ppPMSG
) {
398 pItem
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, cb
- sizeof(DMUS_PMSG
) + sizeof(DMUS_PMSGItem
));
400 return E_OUTOFMEMORY
;
402 pItem
->pMsg
.dwSize
= cb
;
403 *ppPMSG
= DMUS_ItemToPMSG(pItem
);
407 HRESULT WINAPI
IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
) {
408 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
409 DMUS_PMSGItem
* pItem
= NULL
;
411 FIXME("(%p, %p): stub\n", This
, pPMSG
);
416 pItem
= DMUS_PMSGToItem(pPMSG
);
420 if (TRUE
== pItem
->bInUse
) {
421 /** prevent for freeing PMsg in queue (ie to be processed) */
422 return DMUS_E_CANNOT_FREE
;
424 /** now we can remove it safely */
425 EnterCriticalSection(&This
->safe
);
426 DMUS_ItemRemoveFromQueue( This
, pItem
);
427 LeaveCriticalSection(&This
->safe
);
429 /** TODO: see if we should Release the pItem->pMsg->punkUser and others Interfaces */
430 HeapFree(GetProcessHeap(), 0, pItem
);
434 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
** ppGraph
) {
435 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
436 FIXME("(%p, %p): to check\n", This
, ppGraph
);
437 if (NULL
!= This
->pToolGraph
) {
438 *ppGraph
= (LPDIRECTMUSICGRAPH
) This
->pToolGraph
;
439 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH
) *ppGraph
);
446 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
* pGraph
) {
447 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
449 FIXME("(%p, %p): to check\n", This
, pGraph
);
451 if (NULL
!= This
->pToolGraph
) {
452 /* Todo clean buffers and tools before */
453 IDirectMusicGraph_Release((LPDIRECTMUSICGRAPH
) This
->pToolGraph
);
455 This
->pToolGraph
= pGraph
;
456 if (NULL
!= This
->pToolGraph
) {
457 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH
) This
->pToolGraph
);
462 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface
, HANDLE hNotification
, REFERENCE_TIME rtMinimum
) {
463 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
464 FIXME("(%p, %p, %lli): stub\n", This
, hNotification
, rtMinimum
);
465 This
->hNotification
= hNotification
;
466 if (rtMinimum
) This
->rtMinimum
= rtMinimum
;
470 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_NOTIFICATION_PMSG
** ppNotificationPMsg
) {
471 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
474 FIXME("(%p, %p): stub\n", This
, ppNotificationPMsg
);
475 if (NULL
== ppNotificationPMsg
) {
485 HRESULT WINAPI
IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
) {
486 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
487 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
491 HRESULT WINAPI
IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
) {
492 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
493 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
497 HRESULT WINAPI
IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
) {
498 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
499 FIXME("(%p, %p): stub\n", This
, pPort
);
500 IDirectMusicPort_AddRef (pPort
);
504 HRESULT WINAPI
IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
) {
505 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
506 FIXME("(%p, %p): stub\n", This
, pPort
);
507 IDirectMusicPort_Release (pPort
);
511 HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwBlockNum
, IDirectMusicPort
* pPort
, DWORD dwGroup
) {
512 int i
, j
, range
/* min value in range */;
513 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
515 FIXME("(%p, %ld, %p, %ld): semi-stub\n", This
, dwBlockNum
, pPort
, dwGroup
-1);
516 range
= 16 * dwBlockNum
;
519 for (i
= range
; i
< range
+16; i
++) {
520 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
521 This
->PChannel
[i
].port
= pPort
;
522 This
->PChannel
[i
].group
= dwGroup
- 1; /* first index is always zero */
523 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
530 HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
* pPort
, DWORD dwGroup
, DWORD dwMChannel
) {
531 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
533 TRACE("(%p, %ld, %p, %ld, %ld)\n", This
, dwPChannel
, pPort
, dwGroup
, dwMChannel
);
534 This
->PChannel
[dwPChannel
].port
= pPort
;
535 This
->PChannel
[dwPChannel
].group
= dwGroup
;
536 This
->PChannel
[dwPChannel
].channel
= dwMChannel
;
541 HRESULT WINAPI
IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
) {
542 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
543 FIXME("(%p, %ld, %p, %p, %p): stub\n", This
, dwPChannel
, ppPort
, pdwGroup
, pdwMChannel
);
547 HRESULT WINAPI
IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicInstrument
* pInst
, DWORD dwPChannel
, IDirectMusicDownloadedInstrument
** ppDownInst
, DMUS_NOTERANGE
* pNoteRanges
, DWORD dwNumNoteRanges
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
) {
548 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
549 FIXME("(%p, %p, %ld, %p, %p, %ld, %p, %p, %p): stub\n", This
, pInst
, dwPChannel
, ppDownInst
, pNoteRanges
, dwNumNoteRanges
, ppPort
, pdwGroup
, pdwMChannel
);
553 HRESULT WINAPI
IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DWORD dwFlags
) {
554 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
555 FIXME("(%p, %ld, %ld): stub\n", This
, mtTime
, dwFlags
);
559 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
) {
560 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
561 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
565 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, void* pParam
) {
566 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
567 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pParam
);
571 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
) {
572 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
574 TRACE("(%p, %s, %p, %ld): stub\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
576 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
))
577 memcpy(pParam
, &This
->fAutoDownload
, sizeof(&This
->fAutoDownload
));
578 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
))
579 memcpy(pParam
, &This
->cMasterGrooveLevel
, sizeof(&This
->cMasterGrooveLevel
));
580 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
))
581 memcpy(pParam
, &This
->fMasterTempo
, sizeof(&This
->fMasterTempo
));
582 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
))
583 memcpy(pParam
, &This
->lMasterVolume
, sizeof(&This
->lMasterVolume
));
588 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
) {
589 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
591 TRACE("(%p, %s, %p, %ld)\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
593 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
)) {
594 memcpy(&This
->fAutoDownload
, pParam
, dwSize
);
595 TRACE("=> AutoDownload set to %d\n", This
->fAutoDownload
);
597 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
)) {
598 memcpy(&This
->cMasterGrooveLevel
, pParam
, dwSize
);
599 TRACE("=> MasterGrooveLevel set to %i\n", This
->cMasterGrooveLevel
);
601 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
)) {
602 memcpy(&This
->fMasterTempo
, pParam
, dwSize
);
603 TRACE("=> MasterTempo set to %f\n", This
->fMasterTempo
);
605 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
)) {
606 memcpy(&This
->lMasterVolume
, pParam
, dwSize
);
607 TRACE("=> MasterVolume set to %li\n", This
->lMasterVolume
);
613 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
) {
614 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
615 TRACE("(%p, %p): stub\n", This
, prtTime
);
616 *prtTime
= This
->rtLatencyTime
;
620 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
) {
621 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
622 FIXME("(%p, %p): stub\n", This
, prtTime
);
626 HRESULT WINAPI
IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtAmount
) {
627 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
628 FIXME("(%p, %lli): stub\n", This
, rtAmount
);
632 HRESULT WINAPI
IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface
) {
633 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
634 FIXME("(%p): stub\n", This
);
635 if (PostMessageToProcessMsgThread(This
, PROCESSMSG_EXIT
)) {
636 WaitForSingleObject(This
->procThread
, INFINITE
);
637 This
->procThreadTicStarted
= FALSE
;
638 CloseHandle(This
->procThread
);
640 if (NULL
!= This
->pDirectSound
) {
641 IDirectSound_Release((LPDIRECTSOUND
) This
->pDirectSound
);
642 This
->pDirectSound
= NULL
;
644 if (NULL
!= This
->pDirectMusic
) {
645 IDirectMusic8_Release((LPDIRECTMUSIC8
) This
->pDirectMusic
);
646 This
->pDirectMusic
= NULL
;
651 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, REFERENCE_TIME
* prtResolved
, DWORD dwTimeResolveFlags
) {
652 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
653 FIXME("(%p, %lli, %p, %ld): stub\n", This
, rtTime
, prtResolved
, dwTimeResolveFlags
);
657 HRESULT WINAPI
IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface
, BYTE bMIDIValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, WORD
* pwMusicValue
) {
658 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
659 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, bMIDIValue
, pChord
, bPlayMode
, bChordLevel
, pwMusicValue
);
663 HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMusicValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, BYTE
* pbMIDIValue
) {
664 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
665 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, wMusicValue
, pChord
, bPlayMode
, bChordLevel
, pbMIDIValue
);
669 HRESULT WINAPI
IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DMUS_TIMESIGNATURE
* pTimeSig
, WORD
* pwMeasure
, BYTE
* pbBeat
, BYTE
* pbGrid
, short* pnOffset
) {
670 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
671 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This
, mtTime
, pTimeSig
, pwMeasure
, pbBeat
, pbGrid
, pnOffset
);
675 HRESULT WINAPI
IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMeasure
, BYTE bBeat
, BYTE bGrid
, short nOffset
, DMUS_TIMESIGNATURE
* pTimeSig
, MUSIC_TIME
* pmtTime
) {
676 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
677 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This
, wMeasure
, bBeat
, bGrid
, nOffset
, pTimeSig
, pmtTime
);
681 /* IDirectMusicPerformance8 Interface part follow: */
682 HRESULT WINAPI
IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 iface
,
683 IDirectMusic
** ppDirectMusic
,
684 IDirectSound
** ppDirectSound
,
686 DWORD dwDefaultPathType
,
687 DWORD dwPChannelCount
,
689 DMUS_AUDIOPARAMS
* pParams
) {
691 IDirectSound
* dsound
= NULL
;
694 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
695 FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This
, ppDirectMusic
, ppDirectSound
, hWnd
, dwDefaultPathType
, dwPChannelCount
, dwFlags
, pParams
);
697 if (This
->pDirectMusic
|| This
->pDirectSound
)
698 return DMUS_E_ALREADY_INITED
;
700 if (NULL
!= ppDirectSound
&& NULL
!= *ppDirectSound
) {
701 dsound
= *ppDirectSound
;
703 hr
= DirectSoundCreate8 (NULL
, (LPDIRECTSOUND8
*) &dsound
, NULL
);
704 FIXME("return dsound(%p,%ld)\n", dsound
, hr
);
705 if (FAILED(hr
) || !dsound
)
706 return DSERR_NODRIVER
;
708 *ppDirectSound
= dsound
;
711 IDirectMusicPerformance8Impl_Init(iface
, ppDirectMusic
, dsound
, hWnd
);
713 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
714 if (NULL
== ppDirectSound
) {
715 IDirectSound_Release(This
->pDirectSound
);
718 /* as seen in msdn we need params init before audio path creation */
719 if (NULL
!= pParams
) {
720 memcpy(&This
->pParams
, pParams
, sizeof(DMUS_AUDIOPARAMS
));
723 * TODO, how can i fill the struct
724 * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp
726 memset(&This
->pParams
, 0, sizeof(DMUS_AUDIOPARAMS
));
727 This
->pParams
.dwSize
= sizeof(DMUS_AUDIOPARAMS
);
728 This
->pParams
.fInitNow
= FALSE
;
729 This
->pParams
.dwValidData
= DMUS_AUDIOPARAMS_FEATURES
| DMUS_AUDIOPARAMS_VOICES
| DMUS_AUDIOPARAMS_SAMPLERATE
| DMUS_AUDIOPARAMS_DEFAULTSYNTH
;
730 This
->pParams
.dwVoices
= 64;
731 This
->pParams
.dwSampleRate
= (DWORD
) 22.050;
732 This
->pParams
.dwFeatures
= dwFlags
;
733 This
->pParams
.clsidDefaultSynth
= CLSID_DirectMusicSynthSink
;
735 hr
= IDirectMusicPerformance8Impl_CreateStandardAudioPath(iface
, dwDefaultPathType
, dwPChannelCount
, FALSE
, (IDirectMusicAudioPath
**) &This
->pDefaultPath
);
737 PostMessageToProcessMsgThread(This
, PROCESSMSG_START
);
742 HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSource
, WCHAR
* pwzSegmentName
, IUnknown
* pTransition
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
, IUnknown
* pFrom
, IUnknown
* pAudioPath
) {
743 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
744 FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This
, pSource
, pwzSegmentName
, pTransition
, dwFlags
, i64StartTime
, ppSegmentState
, pFrom
, pAudioPath
);
748 HRESULT WINAPI
IDirectMusicPerformance8Impl_StopEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pObjectToStop
, __int64 i64StopTime
, DWORD dwFlags
) {
749 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
750 FIXME("(%p, %p, %lli, %ld): stub\n", This
, pObjectToStop
, i64StopTime
, dwFlags
);
754 HRESULT WINAPI
IDirectMusicPerformance8Impl_ClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pSourcePMSG
, DMUS_PMSG
** ppCopyPMSG
) {
755 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
756 FIXME("(%p, %p, %p): stub\n", This
, pSourcePMSG
, ppCopyPMSG
);
760 HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSourceConfig
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
) {
761 IDirectMusicAudioPathImpl
*default_path
;
762 IDirectMusicAudioPath
*pPath
;
764 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
765 FIXME("(%p, %p, %d, %p): stub\n", This
, pSourceConfig
, fActivate
, ppNewPath
);
767 if (NULL
== ppNewPath
) {
771 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath
, (LPVOID
*)&pPath
, NULL
);
772 default_path
= (IDirectMusicAudioPathImpl
*)((char*)(pPath
) - offsetof(IDirectMusicAudioPathImpl
,AudioPathVtbl
));
773 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
777 *ppNewPath
= (LPDIRECTMUSICAUDIOPATH
) pPath
;
779 return IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
783 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp
785 HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwType
, DWORD dwPChannelCount
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
) {
786 IDirectMusicAudioPathImpl
*default_path
;
787 IDirectMusicAudioPath
*pPath
;
790 LPDIRECTSOUNDBUFFER buffer
;
793 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
795 FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This
, dwType
, dwPChannelCount
, fActivate
, ppNewPath
);
797 if (NULL
== ppNewPath
) {
801 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath
, (LPVOID
*)&pPath
, NULL
);
802 default_path
= (IDirectMusicAudioPathImpl
*)((char*)(pPath
) - offsetof(IDirectMusicAudioPathImpl
,AudioPathVtbl
));
803 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
805 /* Secondary buffer description */
806 memset(&format
, 0, sizeof(format
));
807 format
.wFormatTag
= WAVE_FORMAT_PCM
;
808 format
.nChannels
= 1;
809 format
.nSamplesPerSec
= 44000;
810 format
.nAvgBytesPerSec
= 44000*2;
811 format
.nBlockAlign
= 2;
812 format
.wBitsPerSample
= 16;
815 memset(&desc
, 0, sizeof(desc
));
816 desc
.dwSize
= sizeof(desc
);
817 desc
.dwFlags
= DSBCAPS_CTRLFX
| DSBCAPS_CTRLPAN
| DSBCAPS_CTRLVOLUME
| DSBCAPS_GLOBALFOCUS
;
818 desc
.dwBufferBytes
= DSBSIZE_MIN
;
820 desc
.lpwfxFormat
= &format
;
821 desc
.guid3DAlgorithm
= GUID_NULL
;
824 case DMUS_APATH_DYNAMIC_3D
:
825 desc
.dwFlags
|= DSBCAPS_CTRL3D
| DSBCAPS_CTRLFREQUENCY
| DSBCAPS_MUTE3DATMAXDISTANCE
;
827 case DMUS_APATH_DYNAMIC_MONO
:
828 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
830 case DMUS_APATH_SHARED_STEREOPLUSREVERB
:
831 /* normally we havet to create 2 buffers (one for music other for reverb)
832 * in this case. See msdn
834 case DMUS_APATH_DYNAMIC_STEREO
:
835 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
836 format
.nChannels
= 2;
837 format
.nBlockAlign
*= 2;
838 format
.nAvgBytesPerSec
*=2;
841 HeapFree(GetProcessHeap(), 0, default_path
);
847 /* FIXME: Should we create one secondary buffer for each PChannel? */
848 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
850 HeapFree(GetProcessHeap(), 0, default_path
);
852 return DSERR_BUFFERLOST
;
854 default_path
->pDSBuffer
= buffer
;
856 /* Update description for creating primary buffer */
857 desc
.dwFlags
|= DSBCAPS_PRIMARYBUFFER
;
858 desc
.dwBufferBytes
= 0;
859 desc
.lpwfxFormat
= NULL
;
861 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
863 IDirectSoundBuffer_Release(default_path
->pDSBuffer
);
864 HeapFree(GetProcessHeap(), 0, default_path
);
866 return DSERR_BUFFERLOST
;
868 default_path
->pPrimary
= buffer
;
870 *ppNewPath
= (LPDIRECTMUSICAUDIOPATH
) pPath
;
872 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath
);
874 return IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
877 HRESULT WINAPI
IDirectMusicPerformance8Impl_SetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
* pAudioPath
) {
878 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
880 FIXME("(%p, %p): semi-stub\n", This
, pAudioPath
);
881 if (NULL
!= This
->pDefaultPath
) {
882 IDirectMusicAudioPath_Release((LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
);
883 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= NULL
;
884 This
->pDefaultPath
= NULL
;
886 This
->pDefaultPath
= pAudioPath
;
887 if (NULL
!= This
->pDefaultPath
) {
888 IDirectMusicAudioPath_AddRef((LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
);
889 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= (IDirectMusicPerformance8
*) This
;
895 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
** ppAudioPath
) {
896 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
898 FIXME("(%p, %p): semi-stub (%p)\n", This
, ppAudioPath
, This
->pDefaultPath
);
900 if (NULL
!= This
->pDefaultPath
) {
901 *ppAudioPath
= (LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
;
902 IDirectMusicAudioPath_AddRef(*ppAudioPath
);
909 HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParamEx (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwTrackID
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
) {
910 ICOM_THIS(IDirectMusicPerformance8Impl
,iface
);
912 FIXME("(%p, %s, %ld, %ld, %ld, %ld, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwTrackID
, dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
917 ICOM_VTABLE(IDirectMusicPerformance8
) DirectMusicPerformance8_Vtbl
= {
918 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
919 IDirectMusicPerformance8Impl_QueryInterface
,
920 IDirectMusicPerformance8Impl_AddRef
,
921 IDirectMusicPerformance8Impl_Release
,
922 IDirectMusicPerformance8Impl_Init
,
923 IDirectMusicPerformance8Impl_PlaySegment
,
924 IDirectMusicPerformance8Impl_Stop
,
925 IDirectMusicPerformance8Impl_GetSegmentState
,
926 IDirectMusicPerformance8Impl_SetPrepareTime
,
927 IDirectMusicPerformance8Impl_GetPrepareTime
,
928 IDirectMusicPerformance8Impl_SetBumperLength
,
929 IDirectMusicPerformance8Impl_GetBumperLength
,
930 IDirectMusicPerformance8Impl_SendPMsg
,
931 IDirectMusicPerformance8Impl_MusicToReferenceTime
,
932 IDirectMusicPerformance8Impl_ReferenceToMusicTime
,
933 IDirectMusicPerformance8Impl_IsPlaying
,
934 IDirectMusicPerformance8Impl_GetTime
,
935 IDirectMusicPerformance8Impl_AllocPMsg
,
936 IDirectMusicPerformance8Impl_FreePMsg
,
937 IDirectMusicPerformance8Impl_GetGraph
,
938 IDirectMusicPerformance8Impl_SetGraph
,
939 IDirectMusicPerformance8Impl_SetNotificationHandle
,
940 IDirectMusicPerformance8Impl_GetNotificationPMsg
,
941 IDirectMusicPerformance8Impl_AddNotificationType
,
942 IDirectMusicPerformance8Impl_RemoveNotificationType
,
943 IDirectMusicPerformance8Impl_AddPort
,
944 IDirectMusicPerformance8Impl_RemovePort
,
945 IDirectMusicPerformance8Impl_AssignPChannelBlock
,
946 IDirectMusicPerformance8Impl_AssignPChannel
,
947 IDirectMusicPerformance8Impl_PChannelInfo
,
948 IDirectMusicPerformance8Impl_DownloadInstrument
,
949 IDirectMusicPerformance8Impl_Invalidate
,
950 IDirectMusicPerformance8Impl_GetParam
,
951 IDirectMusicPerformance8Impl_SetParam
,
952 IDirectMusicPerformance8Impl_GetGlobalParam
,
953 IDirectMusicPerformance8Impl_SetGlobalParam
,
954 IDirectMusicPerformance8Impl_GetLatencyTime
,
955 IDirectMusicPerformance8Impl_GetQueueTime
,
956 IDirectMusicPerformance8Impl_AdjustTime
,
957 IDirectMusicPerformance8Impl_CloseDown
,
958 IDirectMusicPerformance8Impl_GetResolvedTime
,
959 IDirectMusicPerformance8Impl_MIDIToMusic
,
960 IDirectMusicPerformance8Impl_MusicToMIDI
,
961 IDirectMusicPerformance8Impl_TimeToRhythm
,
962 IDirectMusicPerformance8Impl_RhythmToTime
,
963 IDirectMusicPerformance8Impl_InitAudio
,
964 IDirectMusicPerformance8Impl_PlaySegmentEx
,
965 IDirectMusicPerformance8Impl_StopEx
,
966 IDirectMusicPerformance8Impl_ClonePMsg
,
967 IDirectMusicPerformance8Impl_CreateAudioPath
,
968 IDirectMusicPerformance8Impl_CreateStandardAudioPath
,
969 IDirectMusicPerformance8Impl_SetDefaultAudioPath
,
970 IDirectMusicPerformance8Impl_GetDefaultAudioPath
,
971 IDirectMusicPerformance8Impl_GetParamEx
974 /* for ClassFactory */
975 HRESULT WINAPI
DMUSIC_CreateDirectMusicPerformanceImpl (LPCGUID lpcGUID
, LPVOID
*ppobj
, LPUNKNOWN pUnkOuter
) {
976 IDirectMusicPerformance8Impl
*obj
;
978 TRACE("(%p,%p,%p)\n", lpcGUID
, ppobj
, pUnkOuter
);
980 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicPerformance8Impl
));
982 *ppobj
= (LPDIRECTMUSICPERFORMANCE8
)NULL
;
983 return E_OUTOFMEMORY
;
985 obj
->lpVtbl
= &DirectMusicPerformance8_Vtbl
;
986 obj
->ref
= 0; /* will be inited by QueryInterface */
987 obj
->pDirectMusic
= NULL
;
988 obj
->pDirectSound
= NULL
;
989 obj
->pDefaultPath
= NULL
;
990 InitializeCriticalSection(&obj
->safe
);
993 * @see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/latencyandbumpertime.asp
995 obj
->rtLatencyTime
= 100; /* 100ms TO FIX */
996 obj
->dwBumperLength
= 50; /* 50ms default */
997 obj
->dwPrepareTime
= 1000; /* 1000ms default */
998 return IDirectMusicPerformance8Impl_QueryInterface ((LPDIRECTMUSICPERFORMANCE8
)obj
, lpcGUID
, ppobj
);