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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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
= IDirectMusicPerformance8_GetTime((IDirectMusicPerformance8
*) This
, &rtCurTime
, NULL
);
93 for (it
= This
->imm_head
; NULL
!= it
; ) {
95 cur
= ProceedMsg(This
, it
);
96 HeapFree(GetProcessHeap(), 0, cur
);
100 for (it
= This
->head
; NULL
!= it
&& it
->rtItemTime
< rtCurTime
+ dwDec
; ) {
102 cur
= ProceedMsg(This
, it
);
103 HeapFree(GetProcessHeap(), 0, cur
);
107 timeOut
= ( it
->rtItemTime
- rtCurTime
) + This
->rtLatencyTime
;
111 LeaveCriticalSection(&This
->safe
);
113 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) {
114 /** if hwnd we suppose that is a windows event ... */
115 if (NULL
!= msg
.hwnd
) {
116 TranslateMessage(&msg
);
117 DispatchMessageA(&msg
);
119 switch (msg
.message
) {
121 case PROCESSMSG_EXIT
:
123 case PROCESSMSG_START
:
127 case PROCESSMSG_REMOVE
:
130 ERR("Unhandled message %u. Critical Path\n", msg
.message
);
136 /** here we should run a little of current AudioPath */
141 TRACE("(%p): Exiting\n", This
);
146 static BOOL
PostMessageToProcessMsgThread(IDirectMusicPerformance8Impl
* This
, UINT iMsg
) {
147 if (FALSE
== This
->procThreadTicStarted
&& PROCESSMSG_EXIT
!= iMsg
) {
149 This
->procThread
= CreateThread(NULL
, 0, ProcessMsgThread
, This
, 0, &This
->procThreadId
);
150 if (NULL
== This
->procThread
) return FALSE
;
151 SetThreadPriority(This
->procThread
, THREAD_PRIORITY_TIME_CRITICAL
);
152 This
->procThreadTicStarted
= TRUE
;
154 res
= PostThreadMessageA(This
->procThreadId
, iMsg
, 0, 0);
155 /* Let the thread creates its message queue (with MsgWaitForMultipleObjects call) by yielding and retrying */
156 if (!res
&& (GetLastError() == ERROR_INVALID_THREAD_ID
))
163 return PostThreadMessageA(This
->procThreadId
, iMsg
, 0, 0);
166 /* IDirectMusicPerformance8 IUnknown part: */
167 static HRESULT WINAPI
IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface
, REFIID riid
, LPVOID
*ppobj
) {
168 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
169 TRACE("(%p, %s,%p)\n", This
, debugstr_dmguid(riid
), ppobj
);
171 if (IsEqualIID (riid
, &IID_IUnknown
) ||
172 IsEqualIID (riid
, &IID_IDirectMusicPerformance
) ||
173 IsEqualIID (riid
, &IID_IDirectMusicPerformance8
)) {
174 IUnknown_AddRef(iface
);
179 WARN("(%p, %s,%p): not found\n", This
, debugstr_dmguid(riid
), ppobj
);
180 return E_NOINTERFACE
;
183 static ULONG WINAPI
IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface
) {
184 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
185 ULONG ref
= InterlockedIncrement(&This
->ref
);
187 TRACE("(%p): AddRef from %ld\n", This
, ref
- 1);
194 static ULONG WINAPI
IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface
) {
195 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
196 ULONG ref
= InterlockedDecrement(&This
->ref
);
197 TRACE("(%p): ReleaseRef to %ld\n", This
, ref
);
200 DeleteCriticalSection(&This
->safe
);
201 HeapFree(GetProcessHeap(), 0, This
);
204 DMIME_UnlockModule();
209 /* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
210 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusic
** ppDirectMusic
, LPDIRECTSOUND pDirectSound
, HWND hWnd
) {
211 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
213 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This
, ppDirectMusic
, pDirectSound
, hWnd
);
214 if (This
->pDirectMusic
|| This
->pDirectSound
)
215 return DMUS_E_ALREADY_INITED
;
218 hWnd
= GetForegroundWindow();
221 if (NULL
!= pDirectSound
) {
222 This
->pDirectSound
= (IDirectSound
*) pDirectSound
;
223 IDirectSound_AddRef((LPDIRECTSOUND
) This
->pDirectSound
);
226 hr
= DirectSoundCreate8(NULL
, (LPDIRECTSOUND8
*) &This
->pDirectSound
, NULL
);
227 if (!This
->pDirectSound
) return DSERR_NODRIVER
;
232 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp
235 IDirectSound8_SetCooperativeLevel(This
->pDirectSound
, hWnd
, DSSCL_PRIORITY
);
237 /* how to get the ForeGround window handle ? */
238 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
242 if (NULL
!= ppDirectMusic
&& NULL
!= *ppDirectMusic
) {
243 /* app creates it's own dmusic object and gives it to performance */
244 This
->pDirectMusic
= (IDirectMusic8
*) *ppDirectMusic
;
245 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) This
->pDirectMusic
);
247 /* app allows the performance to initialise itfself and needs a pointer to object*/
248 CoCreateInstance (&CLSID_DirectMusic
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusic8
, (void**)&This
->pDirectMusic
);
250 *ppDirectMusic
= (LPDIRECTMUSIC
) This
->pDirectMusic
;
251 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) *ppDirectMusic
);
258 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
) {
259 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
260 FIXME("(%p, %p, %ld, %lli, %p): stub\n", This
, pSegment
, dwFlags
, i64StartTime
, ppSegmentState
);
264 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegmentState
, MUSIC_TIME mtTime
, DWORD dwFlags
) {
265 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
266 FIXME("(%p, %p, %p, %ld, %ld): stub\n", This
, pSegment
, pSegmentState
, mtTime
, dwFlags
);
270 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegmentState
** ppSegmentState
, MUSIC_TIME mtTime
) {
271 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
272 FIXME("(%p,%p, %ld): stub\n", This
, ppSegmentState
, mtTime
);
276 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
) {
277 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
278 TRACE("(%p, %ld)\n", This
, dwMilliSeconds
);
279 This
->dwPrepareTime
= dwMilliSeconds
;
283 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
) {
284 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
285 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
286 if (NULL
== pdwMilliSeconds
) {
289 *pdwMilliSeconds
= This
->dwPrepareTime
;
293 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
) {
294 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
295 TRACE("(%p, %ld)\n", This
, dwMilliSeconds
);
296 This
->dwBumperLength
= dwMilliSeconds
;
300 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
) {
301 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
302 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
303 if (NULL
== pdwMilliSeconds
) {
306 *pdwMilliSeconds
= This
->dwBumperLength
;
310 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
) {
311 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
312 DMUS_PMSGItem
* pItem
= NULL
;
313 DMUS_PMSGItem
* it
= NULL
;
314 DMUS_PMSGItem
* prev_it
= NULL
;
315 DMUS_PMSGItem
** queue
= NULL
;
317 FIXME("(%p, %p): stub\n", This
, pPMSG
);
322 pItem
= DMUS_PMSGToItem(pPMSG
);
327 return DMUS_E_ALREADY_SENT
;
330 /* TODO: Valid Flags */
331 /* TODO: DMUS_PMSGF_MUSICTIME */
332 pItem
->rtItemTime
= pPMSG
->rtTime
;
334 if (pPMSG
->dwFlags
& DMUS_PMSGF_TOOL_IMMEDIATE
) {
335 queue
= &This
->imm_head
;
340 EnterCriticalSection(&This
->safe
);
341 for (it
= *queue
; NULL
!= it
&& it
->rtItemTime
< pItem
->rtItemTime
; it
= it
->next
) {
344 if (NULL
== prev_it
) {
346 if (NULL
!= *queue
) pItem
->next
= (*queue
)->next
;
347 /*assert( NULL == pItem->next->prev );*/
348 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
351 pItem
->prev
= prev_it
;
352 pItem
->next
= prev_it
->next
;
353 prev_it
->next
= pItem
;
354 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
356 LeaveCriticalSection(&This
->safe
);
358 /** now in use, prevent from stupid Frees */
359 pItem
->bInUse
= TRUE
;
363 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, REFERENCE_TIME
* prtTime
) {
364 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
365 FIXME("(%p, %ld, %p): stub\n", This
, mtTime
, prtTime
);
369 static HRESULT WINAPI
IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, MUSIC_TIME
* pmtTime
) {
370 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
371 FIXME("(%p, %lli, %p): stub\n", This
, rtTime
, pmtTime
);
375 static HRESULT WINAPI
IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegState
) {
376 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
377 FIXME("(%p, %p, %p): stub\n", This
, pSegment
, pSegState
);
381 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtNow
, MUSIC_TIME
* pmtNow
) {
382 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
384 REFERENCE_TIME rtCur
= 0;
386 /*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */
387 if (This
->procThreadTicStarted
) {
388 rtCur
= ((REFERENCE_TIME
) GetTickCount() * 10000) - This
->procThreadStartTime
;
390 /*return DMUS_E_NO_MASTER_CLOCK;*/
392 if (NULL
!= prtNow
) {
395 if (NULL
!= pmtNow
) {
396 hr
= IDirectMusicPerformance8_ReferenceToMusicTime(iface
, rtCur
, pmtNow
);
401 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, ULONG cb
, DMUS_PMSG
** ppPMSG
) {
402 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
403 DMUS_PMSGItem
* pItem
= NULL
;
405 FIXME("(%p, %ld, %p): stub\n", This
, cb
, ppPMSG
);
407 if (sizeof(DMUS_PMSG
) > cb
) {
410 if (NULL
== ppPMSG
) {
413 pItem
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, cb
- sizeof(DMUS_PMSG
) + sizeof(DMUS_PMSGItem
));
415 return E_OUTOFMEMORY
;
417 pItem
->pMsg
.dwSize
= cb
;
418 *ppPMSG
= DMUS_ItemToPMSG(pItem
);
422 static HRESULT WINAPI
IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
) {
423 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
424 DMUS_PMSGItem
* pItem
= NULL
;
426 FIXME("(%p, %p): stub\n", This
, pPMSG
);
431 pItem
= DMUS_PMSGToItem(pPMSG
);
436 /** prevent for freeing PMsg in queue (ie to be processed) */
437 return DMUS_E_CANNOT_FREE
;
439 /** now we can remove it safely */
440 EnterCriticalSection(&This
->safe
);
441 DMUS_ItemRemoveFromQueue( This
, pItem
);
442 LeaveCriticalSection(&This
->safe
);
444 /** TODO: see if we should Release the pItem->pMsg->punkUser and others Interfaces */
445 HeapFree(GetProcessHeap(), 0, pItem
);
449 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
** ppGraph
) {
450 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
451 FIXME("(%p, %p): to check\n", This
, ppGraph
);
452 if (NULL
!= This
->pToolGraph
) {
453 *ppGraph
= (LPDIRECTMUSICGRAPH
) This
->pToolGraph
;
454 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH
) *ppGraph
);
461 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
* pGraph
) {
462 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
464 FIXME("(%p, %p): to check\n", This
, pGraph
);
466 if (NULL
!= This
->pToolGraph
) {
467 /* Todo clean buffers and tools before */
468 IDirectMusicGraph_Release((LPDIRECTMUSICGRAPH
) This
->pToolGraph
);
470 This
->pToolGraph
= pGraph
;
471 if (NULL
!= This
->pToolGraph
) {
472 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH
) This
->pToolGraph
);
477 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface
, HANDLE hNotification
, REFERENCE_TIME rtMinimum
) {
478 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
479 FIXME("(%p, %p, %lli): stub\n", This
, hNotification
, rtMinimum
);
480 This
->hNotification
= hNotification
;
481 if (rtMinimum
) This
->rtMinimum
= rtMinimum
;
485 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_NOTIFICATION_PMSG
** ppNotificationPMsg
) {
486 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
489 FIXME("(%p, %p): stub\n", This
, ppNotificationPMsg
);
490 if (NULL
== ppNotificationPMsg
) {
500 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
) {
501 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
502 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
506 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
) {
507 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
508 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
512 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
) {
513 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
515 FIXME("(%p, %p): stub\n", This
, pPort
);
516 if (!This
->pDirectMusic
|| !This
->pDirectSound
) return DMUS_E_NOT_INIT
;
519 IDirectMusicPort
* pDefaultPort
= NULL
;
520 DMUS_PORTPARAMS params
;
522 hr
= IDirectMusic8_GetDefaultPort(This
->pDirectMusic
, &port_guid
);
523 if (FAILED(hr
)) return hr
;
524 ZeroMemory(¶ms
, sizeof(params
));
525 params
.dwSize
= sizeof(params
);
526 params
.dwValidParams
= DMUS_PORTPARAMS_CHANNELGROUPS
| DMUS_PORTPARAMS_SHARE
;
527 params
.dwChannelGroups
= 1;
528 params
.fShare
= TRUE
;
529 hr
= IDirectMusic8_CreatePort(This
->pDirectMusic
, &port_guid
, ¶ms
, &pDefaultPort
, NULL
);
530 if (FAILED(hr
)) return hr
;
531 hr
= IDirectMusicPort_Activate(pDefaultPort
, TRUE
);
532 if (FAILED(hr
)) { IDirectMusicPort_Release(pDefaultPort
); return hr
; }
534 for (i
= 0; i
< 16; ++i
) {
535 if (NULL
== This
->PChannel
[i
].port
) {
536 This
->PChannel
[i
].port
= pPort
;
537 This
->PChannel
[i
].group
= 0;
538 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
543 IDirectMusicPort_AddRef(pPort
);
546 * We should remember added Ports (for example using a list)
547 * and control if Port is registered for each api who use ports
552 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
) {
553 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
554 FIXME("(%p, %p): stub\n", This
, pPort
);
555 IDirectMusicPort_Release (pPort
);
559 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwBlockNum
, IDirectMusicPort
* pPort
, DWORD dwGroup
) {
560 int i
, j
, range
/* min value in range */;
561 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
563 FIXME("(%p, %ld, %p, %ld): semi-stub\n", This
, dwBlockNum
, pPort
, dwGroup
-1);
564 if (NULL
== pPort
) return E_POINTER
;
566 range
= 16 * dwBlockNum
;
568 for (i
= range
; i
< range
+16; i
++) {
569 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
570 This
->PChannel
[i
].port
= pPort
;
571 This
->PChannel
[i
].group
= dwGroup
- 1; /* first index is always zero */
572 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
575 /*if (dwGroup > 2) return S_FALSE;*/
580 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
* pPort
, DWORD dwGroup
, DWORD dwMChannel
) {
581 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
583 TRACE("(%p, %ld, %p, %ld, %ld)\n", This
, dwPChannel
, pPort
, dwGroup
, dwMChannel
);
584 if (NULL
== pPort
) return E_POINTER
;
585 This
->PChannel
[dwPChannel
].port
= pPort
;
586 This
->PChannel
[dwPChannel
].group
= dwGroup
;
587 This
->PChannel
[dwPChannel
].channel
= dwMChannel
;
592 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
) {
593 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
594 FIXME("(%p, %ld, %p, %p, %p): stub\n", This
, dwPChannel
, ppPort
, pdwGroup
, pdwMChannel
);
598 static HRESULT WINAPI
IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicInstrument
* pInst
, DWORD dwPChannel
, IDirectMusicDownloadedInstrument
** ppDownInst
, DMUS_NOTERANGE
* pNoteRanges
, DWORD dwNumNoteRanges
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
) {
599 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
600 FIXME("(%p, %p, %ld, %p, %p, %ld, %p, %p, %p): stub\n", This
, pInst
, dwPChannel
, ppDownInst
, pNoteRanges
, dwNumNoteRanges
, ppPort
, pdwGroup
, pdwMChannel
);
604 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DWORD dwFlags
) {
605 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
606 FIXME("(%p, %ld, %ld): stub\n", This
, mtTime
, dwFlags
);
610 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
) {
611 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
612 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
616 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, void* pParam
) {
617 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
618 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pParam
);
622 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
) {
623 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
625 TRACE("(%p, %s, %p, %ld): stub\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
627 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
))
628 memcpy(pParam
, &This
->fAutoDownload
, sizeof(&This
->fAutoDownload
));
629 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
))
630 memcpy(pParam
, &This
->cMasterGrooveLevel
, sizeof(&This
->cMasterGrooveLevel
));
631 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
))
632 memcpy(pParam
, &This
->fMasterTempo
, sizeof(&This
->fMasterTempo
));
633 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
))
634 memcpy(pParam
, &This
->lMasterVolume
, sizeof(&This
->lMasterVolume
));
639 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
) {
640 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
642 TRACE("(%p, %s, %p, %ld)\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
644 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
)) {
645 memcpy(&This
->fAutoDownload
, pParam
, dwSize
);
646 TRACE("=> AutoDownload set to %d\n", This
->fAutoDownload
);
648 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
)) {
649 memcpy(&This
->cMasterGrooveLevel
, pParam
, dwSize
);
650 TRACE("=> MasterGrooveLevel set to %i\n", This
->cMasterGrooveLevel
);
652 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
)) {
653 memcpy(&This
->fMasterTempo
, pParam
, dwSize
);
654 TRACE("=> MasterTempo set to %f\n", This
->fMasterTempo
);
656 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
)) {
657 memcpy(&This
->lMasterVolume
, pParam
, dwSize
);
658 TRACE("=> MasterVolume set to %li\n", This
->lMasterVolume
);
664 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
) {
665 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
666 TRACE("(%p, %p): stub\n", This
, prtTime
);
667 *prtTime
= This
->rtLatencyTime
;
671 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
) {
672 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
673 FIXME("(%p, %p): stub\n", This
, prtTime
);
677 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtAmount
) {
678 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
679 FIXME("(%p, %lli): stub\n", This
, rtAmount
);
683 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface
) {
684 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
685 FIXME("(%p): stub\n", This
);
686 if (PostMessageToProcessMsgThread(This
, PROCESSMSG_EXIT
)) {
687 WaitForSingleObject(This
->procThread
, INFINITE
);
688 This
->procThreadTicStarted
= FALSE
;
689 CloseHandle(This
->procThread
);
691 if (NULL
!= This
->pDirectSound
) {
692 IDirectSound_Release((LPDIRECTSOUND
) This
->pDirectSound
);
693 This
->pDirectSound
= NULL
;
695 if (NULL
!= This
->pDirectMusic
) {
696 IDirectMusic8_Release((LPDIRECTMUSIC8
) This
->pDirectMusic
);
697 This
->pDirectMusic
= NULL
;
702 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, REFERENCE_TIME
* prtResolved
, DWORD dwTimeResolveFlags
) {
703 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
704 FIXME("(%p, %lli, %p, %ld): stub\n", This
, rtTime
, prtResolved
, dwTimeResolveFlags
);
708 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface
, BYTE bMIDIValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, WORD
* pwMusicValue
) {
709 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
710 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, bMIDIValue
, pChord
, bPlayMode
, bChordLevel
, pwMusicValue
);
714 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMusicValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, BYTE
* pbMIDIValue
) {
715 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
716 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, wMusicValue
, pChord
, bPlayMode
, bChordLevel
, pbMIDIValue
);
720 static HRESULT WINAPI
IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DMUS_TIMESIGNATURE
* pTimeSig
, WORD
* pwMeasure
, BYTE
* pbBeat
, BYTE
* pbGrid
, short* pnOffset
) {
721 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
722 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This
, mtTime
, pTimeSig
, pwMeasure
, pbBeat
, pbGrid
, pnOffset
);
726 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMeasure
, BYTE bBeat
, BYTE bGrid
, short nOffset
, DMUS_TIMESIGNATURE
* pTimeSig
, MUSIC_TIME
* pmtTime
) {
727 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
728 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This
, wMeasure
, bBeat
, bGrid
, nOffset
, pTimeSig
, pmtTime
);
732 /* IDirectMusicPerformance8 Interface part follow: */
733 static HRESULT WINAPI
IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 iface
,
734 IDirectMusic
** ppDirectMusic
,
735 IDirectSound
** ppDirectSound
,
737 DWORD dwDefaultPathType
,
738 DWORD dwPChannelCount
,
740 DMUS_AUDIOPARAMS
* pParams
) {
742 IDirectSound
* dsound
= NULL
;
745 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
746 FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This
, ppDirectMusic
, ppDirectSound
, hWnd
, dwDefaultPathType
, dwPChannelCount
, dwFlags
, pParams
);
748 if (This
->pDirectMusic
|| This
->pDirectSound
)
749 return DMUS_E_ALREADY_INITED
;
751 if (NULL
!= ppDirectSound
&& NULL
!= *ppDirectSound
) {
752 dsound
= *ppDirectSound
;
754 hr
= DirectSoundCreate8 (NULL
, (LPDIRECTSOUND8
*) &dsound
, NULL
);
755 FIXME("return dsound(%p,%ld)\n", dsound
, hr
);
756 if (FAILED(hr
) || !dsound
)
757 return DSERR_NODRIVER
;
759 *ppDirectSound
= dsound
;
762 IDirectMusicPerformance8Impl_Init(iface
, ppDirectMusic
, dsound
, hWnd
);
764 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
765 if (NULL
== ppDirectSound
) {
766 IDirectSound_Release(This
->pDirectSound
);
769 /* as seen in msdn we need params init before audio path creation */
770 if (NULL
!= pParams
) {
771 memcpy(&This
->pParams
, pParams
, sizeof(DMUS_AUDIOPARAMS
));
774 * TODO, how can i fill the struct
775 * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp
777 memset(&This
->pParams
, 0, sizeof(DMUS_AUDIOPARAMS
));
778 This
->pParams
.dwSize
= sizeof(DMUS_AUDIOPARAMS
);
779 This
->pParams
.fInitNow
= FALSE
;
780 This
->pParams
.dwValidData
= DMUS_AUDIOPARAMS_FEATURES
| DMUS_AUDIOPARAMS_VOICES
| DMUS_AUDIOPARAMS_SAMPLERATE
| DMUS_AUDIOPARAMS_DEFAULTSYNTH
;
781 This
->pParams
.dwVoices
= 64;
782 This
->pParams
.dwSampleRate
= (DWORD
) 22.050;
783 This
->pParams
.dwFeatures
= dwFlags
;
784 This
->pParams
.clsidDefaultSynth
= CLSID_DirectMusicSynthSink
;
786 hr
= IDirectMusicPerformance8_CreateStandardAudioPath(iface
, dwDefaultPathType
, dwPChannelCount
, FALSE
, (IDirectMusicAudioPath
**) &This
->pDefaultPath
);
788 PostMessageToProcessMsgThread(This
, PROCESSMSG_START
);
793 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSource
, WCHAR
* pwzSegmentName
, IUnknown
* pTransition
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
, IUnknown
* pFrom
, IUnknown
* pAudioPath
) {
794 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
795 FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This
, pSource
, pwzSegmentName
, pTransition
, dwFlags
, i64StartTime
, ppSegmentState
, pFrom
, pAudioPath
);
799 static HRESULT WINAPI
IDirectMusicPerformance8Impl_StopEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pObjectToStop
, __int64 i64StopTime
, DWORD dwFlags
) {
800 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
801 FIXME("(%p, %p, %lli, %ld): stub\n", This
, pObjectToStop
, i64StopTime
, dwFlags
);
805 static HRESULT WINAPI
IDirectMusicPerformance8Impl_ClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pSourcePMSG
, DMUS_PMSG
** ppCopyPMSG
) {
806 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
807 FIXME("(%p, %p, %p): stub\n", This
, pSourcePMSG
, ppCopyPMSG
);
811 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSourceConfig
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
) {
812 IDirectMusicAudioPathImpl
*default_path
;
813 IDirectMusicAudioPath
*pPath
;
815 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
816 FIXME("(%p, %p, %d, %p): stub\n", This
, pSourceConfig
, fActivate
, ppNewPath
);
818 if (NULL
== ppNewPath
) {
822 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath
, (LPVOID
*)&pPath
, NULL
);
823 default_path
= (IDirectMusicAudioPathImpl
*)((char*)(pPath
) - offsetof(IDirectMusicAudioPathImpl
,AudioPathVtbl
));
824 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
828 *ppNewPath
= (LPDIRECTMUSICAUDIOPATH
) pPath
;
830 return IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
834 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp
836 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwType
, DWORD dwPChannelCount
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
) {
837 IDirectMusicAudioPathImpl
*default_path
;
838 IDirectMusicAudioPath
*pPath
;
841 LPDIRECTSOUNDBUFFER buffer
;
844 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
846 FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This
, dwType
, dwPChannelCount
, fActivate
, ppNewPath
);
848 if (NULL
== ppNewPath
) {
852 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath
, (LPVOID
*)&pPath
, NULL
);
853 default_path
= (IDirectMusicAudioPathImpl
*)((char*)(pPath
) - offsetof(IDirectMusicAudioPathImpl
,AudioPathVtbl
));
854 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
856 /* Secondary buffer description */
857 memset(&format
, 0, sizeof(format
));
858 format
.wFormatTag
= WAVE_FORMAT_PCM
;
859 format
.nChannels
= 1;
860 format
.nSamplesPerSec
= 44000;
861 format
.nAvgBytesPerSec
= 44000*2;
862 format
.nBlockAlign
= 2;
863 format
.wBitsPerSample
= 16;
866 memset(&desc
, 0, sizeof(desc
));
867 desc
.dwSize
= sizeof(desc
);
868 desc
.dwFlags
= DSBCAPS_CTRLFX
| DSBCAPS_CTRLPAN
| DSBCAPS_CTRLVOLUME
| DSBCAPS_GLOBALFOCUS
;
869 desc
.dwBufferBytes
= DSBSIZE_MIN
;
871 desc
.lpwfxFormat
= &format
;
872 desc
.guid3DAlgorithm
= GUID_NULL
;
875 case DMUS_APATH_DYNAMIC_3D
:
876 desc
.dwFlags
|= DSBCAPS_CTRL3D
| DSBCAPS_CTRLFREQUENCY
| DSBCAPS_MUTE3DATMAXDISTANCE
;
878 case DMUS_APATH_DYNAMIC_MONO
:
879 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
881 case DMUS_APATH_SHARED_STEREOPLUSREVERB
:
882 /* normally we havet to create 2 buffers (one for music other for reverb)
883 * in this case. See msdn
885 case DMUS_APATH_DYNAMIC_STEREO
:
886 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
887 format
.nChannels
= 2;
888 format
.nBlockAlign
*= 2;
889 format
.nAvgBytesPerSec
*=2;
892 HeapFree(GetProcessHeap(), 0, default_path
);
897 /* FIXME: Should we create one secondary buffer for each PChannel? */
898 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
900 HeapFree(GetProcessHeap(), 0, default_path
);
902 return DSERR_BUFFERLOST
;
904 default_path
->pDSBuffer
= buffer
;
906 /* Update description for creating primary buffer */
907 desc
.dwFlags
|= DSBCAPS_PRIMARYBUFFER
;
908 desc
.dwBufferBytes
= 0;
909 desc
.lpwfxFormat
= NULL
;
911 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
913 IDirectSoundBuffer_Release(default_path
->pDSBuffer
);
914 HeapFree(GetProcessHeap(), 0, default_path
);
916 return DSERR_BUFFERLOST
;
918 default_path
->pPrimary
= buffer
;
920 *ppNewPath
= (LPDIRECTMUSICAUDIOPATH
) pPath
;
922 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath
);
924 return IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
927 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
* pAudioPath
) {
928 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
930 FIXME("(%p, %p): semi-stub\n", This
, pAudioPath
);
931 if (NULL
!= This
->pDefaultPath
) {
932 IDirectMusicAudioPath_Release((LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
);
933 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= NULL
;
934 This
->pDefaultPath
= NULL
;
936 This
->pDefaultPath
= pAudioPath
;
937 if (NULL
!= This
->pDefaultPath
) {
938 IDirectMusicAudioPath_AddRef((LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
);
939 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= (IDirectMusicPerformance8
*) This
;
945 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
** ppAudioPath
) {
946 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
948 FIXME("(%p, %p): semi-stub (%p)\n", This
, ppAudioPath
, This
->pDefaultPath
);
950 if (NULL
!= This
->pDefaultPath
) {
951 *ppAudioPath
= (LPDIRECTMUSICAUDIOPATH
) This
->pDefaultPath
;
952 IDirectMusicAudioPath_AddRef(*ppAudioPath
);
959 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParamEx (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwTrackID
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
) {
960 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
962 FIXME("(%p, %s, %ld, %ld, %ld, %ld, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwTrackID
, dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
967 static const IDirectMusicPerformance8Vtbl DirectMusicPerformance8_Vtbl
= {
968 IDirectMusicPerformance8Impl_QueryInterface
,
969 IDirectMusicPerformance8Impl_AddRef
,
970 IDirectMusicPerformance8Impl_Release
,
971 IDirectMusicPerformance8Impl_Init
,
972 IDirectMusicPerformance8Impl_PlaySegment
,
973 IDirectMusicPerformance8Impl_Stop
,
974 IDirectMusicPerformance8Impl_GetSegmentState
,
975 IDirectMusicPerformance8Impl_SetPrepareTime
,
976 IDirectMusicPerformance8Impl_GetPrepareTime
,
977 IDirectMusicPerformance8Impl_SetBumperLength
,
978 IDirectMusicPerformance8Impl_GetBumperLength
,
979 IDirectMusicPerformance8Impl_SendPMsg
,
980 IDirectMusicPerformance8Impl_MusicToReferenceTime
,
981 IDirectMusicPerformance8Impl_ReferenceToMusicTime
,
982 IDirectMusicPerformance8Impl_IsPlaying
,
983 IDirectMusicPerformance8Impl_GetTime
,
984 IDirectMusicPerformance8Impl_AllocPMsg
,
985 IDirectMusicPerformance8Impl_FreePMsg
,
986 IDirectMusicPerformance8Impl_GetGraph
,
987 IDirectMusicPerformance8Impl_SetGraph
,
988 IDirectMusicPerformance8Impl_SetNotificationHandle
,
989 IDirectMusicPerformance8Impl_GetNotificationPMsg
,
990 IDirectMusicPerformance8Impl_AddNotificationType
,
991 IDirectMusicPerformance8Impl_RemoveNotificationType
,
992 IDirectMusicPerformance8Impl_AddPort
,
993 IDirectMusicPerformance8Impl_RemovePort
,
994 IDirectMusicPerformance8Impl_AssignPChannelBlock
,
995 IDirectMusicPerformance8Impl_AssignPChannel
,
996 IDirectMusicPerformance8Impl_PChannelInfo
,
997 IDirectMusicPerformance8Impl_DownloadInstrument
,
998 IDirectMusicPerformance8Impl_Invalidate
,
999 IDirectMusicPerformance8Impl_GetParam
,
1000 IDirectMusicPerformance8Impl_SetParam
,
1001 IDirectMusicPerformance8Impl_GetGlobalParam
,
1002 IDirectMusicPerformance8Impl_SetGlobalParam
,
1003 IDirectMusicPerformance8Impl_GetLatencyTime
,
1004 IDirectMusicPerformance8Impl_GetQueueTime
,
1005 IDirectMusicPerformance8Impl_AdjustTime
,
1006 IDirectMusicPerformance8Impl_CloseDown
,
1007 IDirectMusicPerformance8Impl_GetResolvedTime
,
1008 IDirectMusicPerformance8Impl_MIDIToMusic
,
1009 IDirectMusicPerformance8Impl_MusicToMIDI
,
1010 IDirectMusicPerformance8Impl_TimeToRhythm
,
1011 IDirectMusicPerformance8Impl_RhythmToTime
,
1012 IDirectMusicPerformance8Impl_InitAudio
,
1013 IDirectMusicPerformance8Impl_PlaySegmentEx
,
1014 IDirectMusicPerformance8Impl_StopEx
,
1015 IDirectMusicPerformance8Impl_ClonePMsg
,
1016 IDirectMusicPerformance8Impl_CreateAudioPath
,
1017 IDirectMusicPerformance8Impl_CreateStandardAudioPath
,
1018 IDirectMusicPerformance8Impl_SetDefaultAudioPath
,
1019 IDirectMusicPerformance8Impl_GetDefaultAudioPath
,
1020 IDirectMusicPerformance8Impl_GetParamEx
1023 /* for ClassFactory */
1024 HRESULT WINAPI
DMUSIC_CreateDirectMusicPerformanceImpl (LPCGUID lpcGUID
, LPVOID
*ppobj
, LPUNKNOWN pUnkOuter
) {
1025 IDirectMusicPerformance8Impl
*obj
;
1027 TRACE("(%p,%p,%p)\n", lpcGUID
, ppobj
, pUnkOuter
);
1029 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicPerformance8Impl
));
1031 *ppobj
= (LPDIRECTMUSICPERFORMANCE8
)NULL
;
1032 return E_OUTOFMEMORY
;
1034 obj
->lpVtbl
= &DirectMusicPerformance8_Vtbl
;
1035 obj
->ref
= 0; /* will be inited by QueryInterface */
1036 obj
->pDirectMusic
= NULL
;
1037 obj
->pDirectSound
= NULL
;
1038 obj
->pDefaultPath
= NULL
;
1039 InitializeCriticalSection(&obj
->safe
);
1042 * @see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/latencyandbumpertime.asp
1044 obj
->rtLatencyTime
= 100; /* 100ms TO FIX */
1045 obj
->dwBumperLength
= 50; /* 50ms default */
1046 obj
->dwPrepareTime
= 1000; /* 1000ms default */
1047 return IDirectMusicPerformance8Impl_QueryInterface ((LPDIRECTMUSICPERFORMANCE8
)obj
, lpcGUID
, ppobj
);