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
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License 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 IDirectMusicPerformance8Impl
{
26 IDirectMusicPerformance8 IDirectMusicPerformance8_iface
;
28 /* IDirectMusicPerformanceImpl fields */
29 IDirectMusic8
*pDirectMusic
;
30 IDirectSound
*pDirectSound
;
31 IDirectMusicGraph
*pToolGraph
;
32 DMUS_AUDIOPARAMS pParams
;
33 /* global parameters */
35 char cMasterGrooveLevel
;
38 /* performance channels */
39 DMUSIC_PRIVATE_PCHANNEL PChannel
[32];
40 /* IDirectMusicPerformance8Impl fields */
41 IDirectMusicAudioPath
*pDefaultPath
;
43 REFERENCE_TIME rtMinimum
;
44 REFERENCE_TIME rtLatencyTime
;
47 /** Message Processing */
50 REFERENCE_TIME procThreadStartTime
;
51 BOOL procThreadTicStarted
;
52 CRITICAL_SECTION safe
;
53 struct DMUS_PMSGItem
*head
;
54 struct DMUS_PMSGItem
*imm_head
;
55 } IDirectMusicPerformance8Impl
;
57 typedef struct DMUS_PMSGItem DMUS_PMSGItem
;
58 struct DMUS_PMSGItem
{
62 REFERENCE_TIME rtItemTime
;
68 #define DMUS_PMSGToItem(pMSG) ((DMUS_PMSGItem*) (((unsigned char*) pPMSG) - offsetof(DMUS_PMSGItem, pMsg)))
69 #define DMUS_ItemToPMSG(pItem) (&(pItem->pMsg))
70 #define DMUS_ItemRemoveFromQueue(This,pItem) \
72 if (pItem->prev) pItem->prev->next = pItem->next;\
73 if (pItem->next) pItem->next->prev = pItem->prev;\
74 if (This->head == pItem) This->head = pItem->next;\
75 if (This->imm_head == pItem) This->imm_head = pItem->next;\
76 pItem->bInUse = FALSE;\
79 #define PROCESSMSG_START (WM_APP + 0)
80 #define PROCESSMSG_EXIT (WM_APP + 1)
81 #define PROCESSMSG_REMOVE (WM_APP + 2)
82 #define PROCESSMSG_ADD (WM_APP + 4)
85 static DMUS_PMSGItem
* ProceedMsg(IDirectMusicPerformance8Impl
* This
, DMUS_PMSGItem
* cur
) {
86 if (cur
->pMsg
.dwType
== DMUS_PMSGT_NOTIFICATION
) {
87 SetEvent(This
->hNotification
);
89 DMUS_ItemRemoveFromQueue(This
, cur
);
90 switch (cur
->pMsg
.dwType
) {
92 case DMUS_PMSGT_TEMPO
:
95 FIXME("Unhandled PMsg Type: 0x%x\n", cur
->pMsg
.dwType
);
101 static DWORD WINAPI
ProcessMsgThread(LPVOID lpParam
) {
102 IDirectMusicPerformance8Impl
* This
= lpParam
;
103 DWORD timeOut
= INFINITE
;
106 REFERENCE_TIME rtCurTime
;
107 DMUS_PMSGItem
* it
= NULL
;
108 DMUS_PMSGItem
* cur
= NULL
;
109 DMUS_PMSGItem
* it_next
= NULL
;
112 DWORD dwDec
= This
->rtLatencyTime
+ This
->dwBumperLength
;
114 if (timeOut
> 0) MsgWaitForMultipleObjects(0, NULL
, FALSE
, timeOut
, QS_POSTMESSAGE
|QS_SENDMESSAGE
|QS_TIMER
);
117 EnterCriticalSection(&This
->safe
);
118 hr
= IDirectMusicPerformance8_GetTime(&This
->IDirectMusicPerformance8_iface
, &rtCurTime
, NULL
);
123 for (it
= This
->imm_head
; NULL
!= it
; ) {
125 cur
= ProceedMsg(This
, it
);
126 HeapFree(GetProcessHeap(), 0, cur
);
130 for (it
= This
->head
; NULL
!= it
&& it
->rtItemTime
< rtCurTime
+ dwDec
; ) {
132 cur
= ProceedMsg(This
, it
);
133 HeapFree(GetProcessHeap(), 0, cur
);
137 timeOut
= ( it
->rtItemTime
- rtCurTime
) + This
->rtLatencyTime
;
141 LeaveCriticalSection(&This
->safe
);
143 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) {
144 /** if hwnd we suppose that is a windows event ... */
145 if (NULL
!= msg
.hwnd
) {
146 TranslateMessage(&msg
);
147 DispatchMessageA(&msg
);
149 switch (msg
.message
) {
151 case PROCESSMSG_EXIT
:
153 case PROCESSMSG_START
:
157 case PROCESSMSG_REMOVE
:
160 ERR("Unhandled message %u. Critical Path\n", msg
.message
);
166 /** here we should run a little of current AudioPath */
171 TRACE("(%p): Exiting\n", This
);
176 static BOOL
PostMessageToProcessMsgThread(IDirectMusicPerformance8Impl
* This
, UINT iMsg
) {
177 if (FALSE
== This
->procThreadTicStarted
&& PROCESSMSG_EXIT
!= iMsg
) {
179 This
->procThread
= CreateThread(NULL
, 0, ProcessMsgThread
, This
, 0, &This
->procThreadId
);
180 if (NULL
== This
->procThread
) return FALSE
;
181 SetThreadPriority(This
->procThread
, THREAD_PRIORITY_TIME_CRITICAL
);
182 This
->procThreadTicStarted
= TRUE
;
184 res
= PostThreadMessageA(This
->procThreadId
, iMsg
, 0, 0);
185 /* Let the thread creates its message queue (with MsgWaitForMultipleObjects call) by yielding and retrying */
186 if (!res
&& (GetLastError() == ERROR_INVALID_THREAD_ID
))
193 return PostThreadMessageA(This
->procThreadId
, iMsg
, 0, 0);
196 static inline IDirectMusicPerformance8Impl
*impl_from_IDirectMusicPerformance8(IDirectMusicPerformance8
*iface
)
198 return CONTAINING_RECORD(iface
, IDirectMusicPerformance8Impl
, IDirectMusicPerformance8_iface
);
201 /* IDirectMusicPerformance8 IUnknown part: */
202 static HRESULT WINAPI
IDirectMusicPerformance8Impl_QueryInterface(IDirectMusicPerformance8
*iface
,
203 REFIID riid
, void **ppv
)
205 TRACE("(%p, %s,%p)\n", iface
, debugstr_dmguid(riid
), ppv
);
207 if (IsEqualIID (riid
, &IID_IUnknown
) ||
208 IsEqualIID (riid
, &IID_IDirectMusicPerformance
) ||
209 IsEqualIID (riid
, &IID_IDirectMusicPerformance2
) ||
210 IsEqualIID (riid
, &IID_IDirectMusicPerformance8
)) {
212 IUnknown_AddRef(iface
);
216 WARN("(%p, %s,%p): not found\n", iface
, debugstr_dmguid(riid
), ppv
);
217 return E_NOINTERFACE
;
220 static ULONG WINAPI
IDirectMusicPerformance8Impl_AddRef(IDirectMusicPerformance8
*iface
)
222 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
223 ULONG ref
= InterlockedIncrement(&This
->ref
);
225 TRACE("(%p): AddRef from %d\n", This
, ref
- 1);
232 static ULONG WINAPI
IDirectMusicPerformance8Impl_Release(IDirectMusicPerformance8
*iface
)
234 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
235 ULONG ref
= InterlockedDecrement(&This
->ref
);
237 TRACE("(%p): ReleaseRef to %d\n", This
, ref
);
240 This
->safe
.DebugInfo
->Spare
[0] = 0;
241 DeleteCriticalSection(&This
->safe
);
242 HeapFree(GetProcessHeap(), 0, This
);
245 DMIME_UnlockModule();
250 /* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
251 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Init(IDirectMusicPerformance8
*iface
,
252 IDirectMusic
**ppDirectMusic
, IDirectSound
*pDirectSound
, HWND hWnd
)
254 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
256 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This
, ppDirectMusic
, pDirectSound
, hWnd
);
257 if (This
->pDirectMusic
|| This
->pDirectSound
)
258 return DMUS_E_ALREADY_INITED
;
261 hWnd
= GetForegroundWindow();
264 if (NULL
!= pDirectSound
) {
265 This
->pDirectSound
= pDirectSound
;
266 IDirectSound_AddRef(This
->pDirectSound
);
268 DirectSoundCreate8(NULL
, (LPDIRECTSOUND8
*) &This
->pDirectSound
, NULL
);
269 if (!This
->pDirectSound
) return DSERR_NODRIVER
;
272 IDirectSound8_SetCooperativeLevel(This
->pDirectSound
, hWnd
, DSSCL_PRIORITY
);
274 /* how to get the ForeGround window handle ? */
275 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
279 if (NULL
!= ppDirectMusic
&& NULL
!= *ppDirectMusic
) {
280 /* app creates its own dmusic object and gives it to performance */
281 This
->pDirectMusic
= (IDirectMusic8
*) *ppDirectMusic
;
282 IDirectMusic8_AddRef(This
->pDirectMusic
);
285 /* App enables the performance to initialize itself and needs a pointer to object */
286 hr
= CoCreateInstance(&CLSID_DirectMusic
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusic8
, (void**)&This
->pDirectMusic
);
290 *ppDirectMusic
= (LPDIRECTMUSIC
)This
->pDirectMusic
;
291 IDirectMusic8_AddRef((LPDIRECTMUSIC8
)*ppDirectMusic
);
298 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegment(IDirectMusicPerformance8
*iface
,
299 IDirectMusicSegment
*pSegment
, DWORD dwFlags
, __int64 i64StartTime
,
300 IDirectMusicSegmentState
**ppSegmentState
)
302 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
304 FIXME("(%p, %p, %d, 0x%s, %p): stub\n", This
, pSegment
, dwFlags
,
305 wine_dbgstr_longlong(i64StartTime
), ppSegmentState
);
307 return create_dmsegmentstate(&IID_IDirectMusicSegmentState
,(void**)ppSegmentState
);
311 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Stop(IDirectMusicPerformance8
*iface
,
312 IDirectMusicSegment
*pSegment
, IDirectMusicSegmentState
*pSegmentState
, MUSIC_TIME mtTime
,
315 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
317 FIXME("(%p, %p, %p, %d, %d): stub\n", This
, pSegment
, pSegmentState
, mtTime
, dwFlags
);
321 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetSegmentState(IDirectMusicPerformance8
*iface
,
322 IDirectMusicSegmentState
**ppSegmentState
, MUSIC_TIME mtTime
)
324 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
326 FIXME("(%p,%p, %d): stub\n", This
, ppSegmentState
, mtTime
);
330 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetPrepareTime(IDirectMusicPerformance8
*iface
,
331 DWORD dwMilliSeconds
)
333 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
335 TRACE("(%p, %d)\n", This
, dwMilliSeconds
);
336 This
->dwPrepareTime
= dwMilliSeconds
;
340 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetPrepareTime(IDirectMusicPerformance8
*iface
,
341 DWORD
*pdwMilliSeconds
)
343 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
345 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
346 if (NULL
== pdwMilliSeconds
) {
349 *pdwMilliSeconds
= This
->dwPrepareTime
;
353 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetBumperLength(IDirectMusicPerformance8
*iface
,
354 DWORD dwMilliSeconds
)
356 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
358 TRACE("(%p, %d)\n", This
, dwMilliSeconds
);
359 This
->dwBumperLength
= dwMilliSeconds
;
363 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetBumperLength(IDirectMusicPerformance8
*iface
,
364 DWORD
*pdwMilliSeconds
)
366 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
368 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
369 if (NULL
== pdwMilliSeconds
) {
372 *pdwMilliSeconds
= This
->dwBumperLength
;
376 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SendPMsg(IDirectMusicPerformance8
*iface
,
379 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
380 DMUS_PMSGItem
* pItem
= NULL
;
381 DMUS_PMSGItem
* it
= NULL
;
382 DMUS_PMSGItem
* prev_it
= NULL
;
383 DMUS_PMSGItem
** queue
= NULL
;
385 FIXME("(%p, %p): stub\n", This
, pPMSG
);
390 pItem
= DMUS_PMSGToItem(pPMSG
);
392 return DMUS_E_ALREADY_SENT
;
395 /* TODO: Valid Flags */
396 /* TODO: DMUS_PMSGF_MUSICTIME */
397 pItem
->rtItemTime
= pPMSG
->rtTime
;
399 if (pPMSG
->dwFlags
& DMUS_PMSGF_TOOL_IMMEDIATE
) {
400 queue
= &This
->imm_head
;
405 EnterCriticalSection(&This
->safe
);
406 for (it
= *queue
; NULL
!= it
&& it
->rtItemTime
< pItem
->rtItemTime
; it
= it
->next
) {
409 if (NULL
== prev_it
) {
411 if (NULL
!= *queue
) pItem
->next
= (*queue
)->next
;
412 /*assert( NULL == pItem->next->prev );*/
413 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
416 pItem
->prev
= prev_it
;
417 pItem
->next
= prev_it
->next
;
418 prev_it
->next
= pItem
;
419 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
421 LeaveCriticalSection(&This
->safe
);
423 /** now in use, prevent from stupid Frees */
424 pItem
->bInUse
= TRUE
;
428 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToReferenceTime(IDirectMusicPerformance8
*iface
,
429 MUSIC_TIME mtTime
, REFERENCE_TIME
*prtTime
)
431 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
433 FIXME("(%p, %d, %p): stub\n", This
, mtTime
, prtTime
);
437 static HRESULT WINAPI
IDirectMusicPerformance8Impl_ReferenceToMusicTime(IDirectMusicPerformance8
*iface
,
438 REFERENCE_TIME rtTime
, MUSIC_TIME
*pmtTime
)
440 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
442 FIXME("(%p, 0x%s, %p): stub\n", This
, wine_dbgstr_longlong(rtTime
), pmtTime
);
446 static HRESULT WINAPI
IDirectMusicPerformance8Impl_IsPlaying(IDirectMusicPerformance8
*iface
,
447 IDirectMusicSegment
*pSegment
, IDirectMusicSegmentState
*pSegState
)
449 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
451 FIXME("(%p, %p, %p): stub\n", This
, pSegment
, pSegState
);
455 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetTime(IDirectMusicPerformance8
*iface
,
456 REFERENCE_TIME
*prtNow
, MUSIC_TIME
*pmtNow
)
458 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
460 REFERENCE_TIME rtCur
= 0;
462 /*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */
463 if (This
->procThreadTicStarted
) {
464 rtCur
= ((REFERENCE_TIME
) GetTickCount() * 10000) - This
->procThreadStartTime
;
466 /*return DMUS_E_NO_MASTER_CLOCK;*/
468 if (NULL
!= prtNow
) {
471 if (NULL
!= pmtNow
) {
472 hr
= IDirectMusicPerformance8_ReferenceToMusicTime(iface
, rtCur
, pmtNow
);
477 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AllocPMsg(IDirectMusicPerformance8
*iface
,
478 ULONG cb
, DMUS_PMSG
**ppPMSG
)
480 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
481 DMUS_PMSGItem
* pItem
= NULL
;
483 FIXME("(%p, %d, %p): stub\n", This
, cb
, ppPMSG
);
485 if (sizeof(DMUS_PMSG
) > cb
) {
488 if (NULL
== ppPMSG
) {
491 pItem
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, cb
- sizeof(DMUS_PMSG
) + sizeof(DMUS_PMSGItem
));
493 return E_OUTOFMEMORY
;
495 pItem
->pMsg
.dwSize
= cb
;
496 *ppPMSG
= DMUS_ItemToPMSG(pItem
);
500 static HRESULT WINAPI
IDirectMusicPerformance8Impl_FreePMsg(IDirectMusicPerformance8
*iface
,
503 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
504 DMUS_PMSGItem
* pItem
= NULL
;
506 FIXME("(%p, %p): stub\n", This
, pPMSG
);
511 pItem
= DMUS_PMSGToItem(pPMSG
);
513 /** prevent for freeing PMsg in queue (ie to be processed) */
514 return DMUS_E_CANNOT_FREE
;
516 /** now we can remove it safely */
517 EnterCriticalSection(&This
->safe
);
518 DMUS_ItemRemoveFromQueue( This
, pItem
);
519 LeaveCriticalSection(&This
->safe
);
521 /** TODO: see if we should Release the pItem->pMsg->punkUser and others Interfaces */
522 HeapFree(GetProcessHeap(), 0, pItem
);
526 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGraph(IDirectMusicPerformance8
*iface
,
527 IDirectMusicGraph
**ppGraph
)
529 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
531 FIXME("(%p, %p): to check\n", This
, ppGraph
);
532 if (NULL
!= This
->pToolGraph
) {
533 *ppGraph
= This
->pToolGraph
;
534 IDirectMusicGraph_AddRef(*ppGraph
);
541 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGraph(IDirectMusicPerformance8
*iface
,
542 IDirectMusicGraph
*pGraph
)
544 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
546 FIXME("(%p, %p): to check\n", This
, pGraph
);
548 if (NULL
!= This
->pToolGraph
) {
549 /* Todo clean buffers and tools before */
550 IDirectMusicGraph_Release(This
->pToolGraph
);
552 This
->pToolGraph
= pGraph
;
553 if (NULL
!= This
->pToolGraph
) {
554 IDirectMusicGraph_AddRef(This
->pToolGraph
);
559 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetNotificationHandle(IDirectMusicPerformance8
*iface
,
560 HANDLE hNotification
, REFERENCE_TIME rtMinimum
)
562 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
564 FIXME("(%p, %p, 0x%s): stub\n", This
, hNotification
, wine_dbgstr_longlong(rtMinimum
));
565 This
->hNotification
= hNotification
;
566 if (rtMinimum
) This
->rtMinimum
= rtMinimum
;
570 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetNotificationPMsg(IDirectMusicPerformance8
*iface
,
571 DMUS_NOTIFICATION_PMSG
**ppNotificationPMsg
)
573 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
575 FIXME("(%p, %p): stub\n", This
, ppNotificationPMsg
);
576 if (NULL
== ppNotificationPMsg
) {
586 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AddNotificationType(IDirectMusicPerformance8
*iface
,
587 REFGUID rguidNotificationType
)
589 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
591 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
595 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RemoveNotificationType(IDirectMusicPerformance8
*iface
,
596 REFGUID rguidNotificationType
)
598 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
600 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
604 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AddPort(IDirectMusicPerformance8
*iface
,
605 IDirectMusicPort
*pPort
)
607 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
610 FIXME("(%p, %p): stub\n", This
, pPort
);
611 if (!This
->pDirectMusic
|| !This
->pDirectSound
) return DMUS_E_NOT_INIT
;
614 IDirectMusicPort
* pDefaultPort
= NULL
;
615 DMUS_PORTPARAMS params
;
617 hr
= IDirectMusic8_GetDefaultPort(This
->pDirectMusic
, &port_guid
);
618 if (FAILED(hr
)) return hr
;
619 ZeroMemory(¶ms
, sizeof(params
));
620 params
.dwSize
= sizeof(params
);
621 params
.dwValidParams
= DMUS_PORTPARAMS_CHANNELGROUPS
| DMUS_PORTPARAMS_SHARE
;
622 params
.dwChannelGroups
= 1;
623 params
.fShare
= TRUE
;
624 hr
= IDirectMusic8_CreatePort(This
->pDirectMusic
, &port_guid
, ¶ms
, &pDefaultPort
, NULL
);
625 if (FAILED(hr
)) return hr
;
626 hr
= IDirectMusicPort_Activate(pDefaultPort
, TRUE
);
627 if (FAILED(hr
)) { IDirectMusicPort_Release(pDefaultPort
); return hr
; }
629 for (i
= 0; i
< 16; ++i
) {
630 if (NULL
== This
->PChannel
[i
].port
) {
631 This
->PChannel
[i
].port
= pPort
;
632 This
->PChannel
[i
].group
= 0;
633 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
638 IDirectMusicPort_AddRef(pPort
);
641 * We should remember added Ports (for example using a list)
642 * and control if Port is registered for each api who use ports
647 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RemovePort(IDirectMusicPerformance8
*iface
,
648 IDirectMusicPort
*pPort
)
650 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
652 FIXME("(%p, %p): stub\n", This
, pPort
);
653 IDirectMusicPort_Release (pPort
);
657 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannelBlock(IDirectMusicPerformance8
*iface
,
658 DWORD dwBlockNum
, IDirectMusicPort
*pPort
, DWORD dwGroup
)
660 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
661 int i
, j
, range
/* min value in range */;
663 FIXME("(%p, %d, %p, %d): semi-stub\n", This
, dwBlockNum
, pPort
, dwGroup
-1);
664 if (NULL
== pPort
) return E_POINTER
;
666 range
= 16 * dwBlockNum
;
668 for (i
= range
; i
< range
+16; i
++) {
669 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
670 This
->PChannel
[i
].port
= pPort
;
671 This
->PChannel
[i
].group
= dwGroup
- 1; /* first index is always zero */
672 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
675 /*if (dwGroup > 2) return S_FALSE;*/
680 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannel(IDirectMusicPerformance8
*iface
,
681 DWORD PChannel
, IDirectMusicPort
*port
, DWORD group
, DWORD MChannel
)
683 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
685 TRACE("(%p)->(%d, %p, %d, %d)\n", This
, PChannel
, port
, group
, MChannel
);
690 This
->PChannel
[PChannel
].port
= port
;
691 This
->PChannel
[PChannel
].group
= group
;
692 This
->PChannel
[PChannel
].channel
= MChannel
;
697 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PChannelInfo(IDirectMusicPerformance8
*iface
,
698 DWORD PChannel
, IDirectMusicPort
**port
, DWORD
*group
, DWORD
*MChannel
)
700 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
701 DMUS_PORTPARAMS8 port_params
;
704 FIXME("(%p)->(%d, %p, %p, %p): stub\n", This
, PChannel
, port
, group
, MChannel
);
706 port_params
.dwSize
= sizeof(DMUS_PORTPARAMS8
);
707 port_params
.dwValidParams
= 0;
708 IDirectMusic8_GetDefaultPort(This
->pDirectMusic
, &default_port
);
709 IDirectMusic8_CreatePort(This
->pDirectMusic
, &default_port
, &port_params
, port
, NULL
);
714 static HRESULT WINAPI
IDirectMusicPerformance8Impl_DownloadInstrument(IDirectMusicPerformance8
*iface
,
715 IDirectMusicInstrument
*pInst
, DWORD dwPChannel
,
716 IDirectMusicDownloadedInstrument
**ppDownInst
, DMUS_NOTERANGE
*pNoteRanges
,
717 DWORD dwNumNoteRanges
, IDirectMusicPort
**ppPort
, DWORD
*pdwGroup
, DWORD
*pdwMChannel
)
719 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
721 FIXME("(%p, %p, %d, %p, %p, %d, %p, %p, %p): stub\n", This
, pInst
, dwPChannel
, ppDownInst
, pNoteRanges
, dwNumNoteRanges
, ppPort
, pdwGroup
, pdwMChannel
);
725 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Invalidate(IDirectMusicPerformance8
*iface
,
726 MUSIC_TIME mtTime
, DWORD dwFlags
)
728 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
730 FIXME("(%p, %d, %d): stub\n", This
, mtTime
, dwFlags
);
734 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParam(IDirectMusicPerformance8
*iface
,
735 REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
,
736 MUSIC_TIME
*pmtNext
, void *pParam
)
738 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
740 FIXME("(%p, %s, %d, %d, %d, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
744 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetParam(IDirectMusicPerformance8
*iface
,
745 REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, void *pParam
)
747 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
749 FIXME("(%p, %s, %d, %d, %d, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pParam
);
753 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGlobalParam(IDirectMusicPerformance8
*iface
,
754 REFGUID rguidType
, void *pParam
, DWORD dwSize
)
756 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
758 TRACE("(%p, %s, %p, %d): stub\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
760 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
))
761 memcpy(pParam
, &This
->fAutoDownload
, sizeof(This
->fAutoDownload
));
762 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
))
763 memcpy(pParam
, &This
->cMasterGrooveLevel
, sizeof(This
->cMasterGrooveLevel
));
764 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
))
765 memcpy(pParam
, &This
->fMasterTempo
, sizeof(This
->fMasterTempo
));
766 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
))
767 memcpy(pParam
, &This
->lMasterVolume
, sizeof(This
->lMasterVolume
));
772 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGlobalParam(IDirectMusicPerformance8
*iface
,
773 REFGUID rguidType
, void *pParam
, DWORD dwSize
)
775 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
777 TRACE("(%p, %s, %p, %d)\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
779 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
)) {
780 memcpy(&This
->fAutoDownload
, pParam
, dwSize
);
781 TRACE("=> AutoDownload set to %d\n", This
->fAutoDownload
);
783 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
)) {
784 memcpy(&This
->cMasterGrooveLevel
, pParam
, dwSize
);
785 TRACE("=> MasterGrooveLevel set to %i\n", This
->cMasterGrooveLevel
);
787 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
)) {
788 memcpy(&This
->fMasterTempo
, pParam
, dwSize
);
789 TRACE("=> MasterTempo set to %f\n", This
->fMasterTempo
);
791 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
)) {
792 memcpy(&This
->lMasterVolume
, pParam
, dwSize
);
793 TRACE("=> MasterVolume set to %li\n", This
->lMasterVolume
);
799 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetLatencyTime(IDirectMusicPerformance8
*iface
,
800 REFERENCE_TIME
*prtTime
)
802 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
804 TRACE("(%p, %p): stub\n", This
, prtTime
);
805 *prtTime
= This
->rtLatencyTime
;
809 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetQueueTime(IDirectMusicPerformance8
*iface
,
810 REFERENCE_TIME
*prtTime
)
813 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
815 FIXME("(%p, %p): stub\n", This
, prtTime
);
819 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AdjustTime(IDirectMusicPerformance8
*iface
,
820 REFERENCE_TIME rtAmount
)
822 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
824 FIXME("(%p, 0x%s): stub\n", This
, wine_dbgstr_longlong(rtAmount
));
828 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CloseDown(IDirectMusicPerformance8
*iface
)
830 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
832 FIXME("(%p): stub\n", This
);
833 if (PostMessageToProcessMsgThread(This
, PROCESSMSG_EXIT
)) {
834 WaitForSingleObject(This
->procThread
, INFINITE
);
835 This
->procThreadTicStarted
= FALSE
;
836 CloseHandle(This
->procThread
);
838 if (NULL
!= This
->pDirectSound
) {
839 IDirectSound_Release(This
->pDirectSound
);
840 This
->pDirectSound
= NULL
;
842 if (NULL
!= This
->pDirectMusic
) {
843 IDirectMusic8_Release(This
->pDirectMusic
);
844 This
->pDirectMusic
= NULL
;
849 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetResolvedTime(IDirectMusicPerformance8
*iface
,
850 REFERENCE_TIME rtTime
, REFERENCE_TIME
*prtResolved
, DWORD dwTimeResolveFlags
)
852 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
854 FIXME("(%p, 0x%s, %p, %d): stub\n", This
, wine_dbgstr_longlong(rtTime
),
855 prtResolved
, dwTimeResolveFlags
);
859 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MIDIToMusic(IDirectMusicPerformance8
*iface
,
860 BYTE bMIDIValue
, DMUS_CHORD_KEY
*pChord
, BYTE bPlayMode
, BYTE bChordLevel
,
863 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
865 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, bMIDIValue
, pChord
, bPlayMode
, bChordLevel
, pwMusicValue
);
869 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToMIDI(IDirectMusicPerformance8
*iface
,
870 WORD wMusicValue
, DMUS_CHORD_KEY
*pChord
, BYTE bPlayMode
, BYTE bChordLevel
,
873 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
875 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, wMusicValue
, pChord
, bPlayMode
, bChordLevel
, pbMIDIValue
);
879 static HRESULT WINAPI
IDirectMusicPerformance8Impl_TimeToRhythm(IDirectMusicPerformance8
*iface
,
880 MUSIC_TIME mtTime
, DMUS_TIMESIGNATURE
*pTimeSig
, WORD
*pwMeasure
, BYTE
*pbBeat
,
881 BYTE
*pbGrid
, short *pnOffset
)
883 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
885 FIXME("(%p, %d, %p, %p, %p, %p, %p): stub\n", This
, mtTime
, pTimeSig
, pwMeasure
, pbBeat
, pbGrid
, pnOffset
);
889 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RhythmToTime(IDirectMusicPerformance8
*iface
,
890 WORD wMeasure
, BYTE bBeat
, BYTE bGrid
, short nOffset
, DMUS_TIMESIGNATURE
*pTimeSig
,
893 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
895 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This
, wMeasure
, bBeat
, bGrid
, nOffset
, pTimeSig
, pmtTime
);
899 /* IDirectMusicPerformance8 Interface part follow: */
900 static HRESULT WINAPI
IDirectMusicPerformance8Impl_InitAudio(IDirectMusicPerformance8
*iface
,
901 IDirectMusic
**ppDirectMusic
, IDirectSound
**ppDirectSound
, HWND hWnd
,
902 DWORD dwDefaultPathType
, DWORD dwPChannelCount
, DWORD dwFlags
, DMUS_AUDIOPARAMS
* pParams
)
904 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
905 IDirectSound
* dsound
= NULL
;
908 FIXME("(%p, %p, %p, %p, %x, %u, %x, %p): to check\n", This
, ppDirectMusic
, ppDirectSound
, hWnd
, dwDefaultPathType
, dwPChannelCount
, dwFlags
, pParams
);
910 if (This
->pDirectMusic
|| This
->pDirectSound
)
911 return DMUS_E_ALREADY_INITED
;
913 if (NULL
!= ppDirectSound
&& NULL
!= *ppDirectSound
) {
914 dsound
= *ppDirectSound
;
916 hr
= DirectSoundCreate8 (NULL
, (LPDIRECTSOUND8
*) &dsound
, NULL
);
917 FIXME("return dsound(%p,%d)\n", dsound
, hr
);
918 if (FAILED(hr
) || !dsound
)
919 return DSERR_NODRIVER
;
921 *ppDirectSound
= dsound
;
924 IDirectMusicPerformance8Impl_Init(iface
, ppDirectMusic
, dsound
, hWnd
);
926 /* Init increases the ref count of the dsound object. Decrement it if the app doesn't want a pointer to the object. */
927 if (NULL
== ppDirectSound
) {
928 IDirectSound_Release(This
->pDirectSound
);
931 /* as seen in msdn we need params init before audio path creation */
932 if (NULL
!= pParams
) {
933 This
->pParams
= *pParams
;
935 /* TODO, how can i fill the struct as seen on msdn */
936 memset(&This
->pParams
, 0, sizeof(DMUS_AUDIOPARAMS
));
937 This
->pParams
.dwSize
= sizeof(DMUS_AUDIOPARAMS
);
938 This
->pParams
.fInitNow
= FALSE
;
939 This
->pParams
.dwValidData
= DMUS_AUDIOPARAMS_FEATURES
| DMUS_AUDIOPARAMS_VOICES
| DMUS_AUDIOPARAMS_SAMPLERATE
| DMUS_AUDIOPARAMS_DEFAULTSYNTH
;
940 This
->pParams
.dwVoices
= 64;
941 This
->pParams
.dwSampleRate
= (DWORD
) 22.050;
942 This
->pParams
.dwFeatures
= dwFlags
;
943 This
->pParams
.clsidDefaultSynth
= CLSID_DirectMusicSynthSink
;
945 if(dwDefaultPathType
!= 0)
946 hr
= IDirectMusicPerformance8_CreateStandardAudioPath(iface
, dwDefaultPathType
, dwPChannelCount
, FALSE
, &This
->pDefaultPath
);
948 PostMessageToProcessMsgThread(This
, PROCESSMSG_START
);
953 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegmentEx(IDirectMusicPerformance8
*iface
,
954 IUnknown
*pSource
, WCHAR
*pwzSegmentName
, IUnknown
*pTransition
, DWORD dwFlags
,
955 __int64 i64StartTime
, IDirectMusicSegmentState
**ppSegmentState
, IUnknown
*pFrom
,
956 IUnknown
*pAudioPath
)
958 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
960 FIXME("(%p, %p, %p, %p, %d, 0x%s, %p, %p, %p): stub\n", This
, pSource
, pwzSegmentName
,
961 pTransition
, dwFlags
, wine_dbgstr_longlong(i64StartTime
), ppSegmentState
, pFrom
, pAudioPath
);
963 return create_dmsegmentstate(&IID_IDirectMusicSegmentState
,(void**)ppSegmentState
);
967 static HRESULT WINAPI
IDirectMusicPerformance8Impl_StopEx(IDirectMusicPerformance8
*iface
,
968 IUnknown
*pObjectToStop
, __int64 i64StopTime
, DWORD dwFlags
)
970 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
972 FIXME("(%p, %p, 0x%s, %d): stub\n", This
, pObjectToStop
,
973 wine_dbgstr_longlong(i64StopTime
), dwFlags
);
977 static HRESULT WINAPI
IDirectMusicPerformance8Impl_ClonePMsg(IDirectMusicPerformance8
*iface
,
978 DMUS_PMSG
*pSourcePMSG
, DMUS_PMSG
**ppCopyPMSG
)
980 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
982 FIXME("(%p, %p, %p): stub\n", This
, pSourcePMSG
, ppCopyPMSG
);
986 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateAudioPath(IDirectMusicPerformance8
*iface
,
987 IUnknown
*pSourceConfig
, BOOL fActivate
, IDirectMusicAudioPath
**ppNewPath
)
989 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
990 IDirectMusicAudioPath
*pPath
;
992 FIXME("(%p, %p, %d, %p): stub\n", This
, pSourceConfig
, fActivate
, ppNewPath
);
994 if (NULL
== ppNewPath
) {
998 create_dmaudiopath(&IID_IDirectMusicAudioPath
, (void**)&pPath
);
999 set_audiopath_perf_pointer(pPath
, iface
);
1005 return IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
1008 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateStandardAudioPath(IDirectMusicPerformance8
*iface
,
1009 DWORD dwType
, DWORD dwPChannelCount
, BOOL fActivate
, IDirectMusicAudioPath
**ppNewPath
)
1011 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
1012 IDirectMusicAudioPath
*pPath
;
1014 WAVEFORMATEX format
;
1015 IDirectSoundBuffer
*buffer
, *primary_buffer
;
1018 FIXME("(%p)->(%d, %d, %d, %p): semi-stub\n", This
, dwType
, dwPChannelCount
, fActivate
, ppNewPath
);
1020 if (NULL
== ppNewPath
) {
1026 /* Secondary buffer description */
1027 memset(&format
, 0, sizeof(format
));
1028 format
.wFormatTag
= WAVE_FORMAT_PCM
;
1029 format
.nChannels
= 1;
1030 format
.nSamplesPerSec
= 44000;
1031 format
.nAvgBytesPerSec
= 44000*2;
1032 format
.nBlockAlign
= 2;
1033 format
.wBitsPerSample
= 16;
1036 memset(&desc
, 0, sizeof(desc
));
1037 desc
.dwSize
= sizeof(desc
);
1038 desc
.dwFlags
= DSBCAPS_CTRLFX
| DSBCAPS_CTRLPAN
| DSBCAPS_CTRLVOLUME
| DSBCAPS_GLOBALFOCUS
;
1039 desc
.dwBufferBytes
= DSBSIZE_MIN
;
1040 desc
.dwReserved
= 0;
1041 desc
.lpwfxFormat
= &format
;
1042 desc
.guid3DAlgorithm
= GUID_NULL
;
1045 case DMUS_APATH_DYNAMIC_3D
:
1046 desc
.dwFlags
|= DSBCAPS_CTRL3D
| DSBCAPS_CTRLFREQUENCY
| DSBCAPS_MUTE3DATMAXDISTANCE
;
1048 case DMUS_APATH_DYNAMIC_MONO
:
1049 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
1051 case DMUS_APATH_SHARED_STEREOPLUSREVERB
:
1052 /* normally we have to create 2 buffers (one for music other for reverb)
1053 * in this case. See msdn
1055 case DMUS_APATH_DYNAMIC_STEREO
:
1056 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
1057 format
.nChannels
= 2;
1058 format
.nBlockAlign
*= 2;
1059 format
.nAvgBytesPerSec
*=2;
1062 return E_INVALIDARG
;
1065 /* FIXME: Should we create one secondary buffer for each PChannel? */
1066 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
1068 return DSERR_BUFFERLOST
;
1070 /* Update description for creating primary buffer */
1071 desc
.dwFlags
|= DSBCAPS_PRIMARYBUFFER
;
1072 desc
.dwBufferBytes
= 0;
1073 desc
.lpwfxFormat
= NULL
;
1075 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &primary_buffer
, NULL
);
1077 IDirectSoundBuffer_Release(buffer
);
1078 return DSERR_BUFFERLOST
;
1081 create_dmaudiopath(&IID_IDirectMusicAudioPath
, (void**)&pPath
);
1082 set_audiopath_perf_pointer(pPath
, iface
);
1083 set_audiopath_dsound_buffer(pPath
, buffer
);
1084 set_audiopath_primary_dsound_buffer(pPath
, primary_buffer
);
1088 TRACE(" returning IDirectMusicAudioPath interface at %p.\n", *ppNewPath
);
1090 return IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
1093 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetDefaultAudioPath(IDirectMusicPerformance8
*iface
,
1094 IDirectMusicAudioPath
*pAudioPath
)
1096 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
1098 FIXME("(%p, %p): semi-stub\n", This
, pAudioPath
);
1100 if (This
->pDefaultPath
) {
1101 IDirectMusicAudioPath_Release(This
->pDefaultPath
);
1102 This
->pDefaultPath
= NULL
;
1104 This
->pDefaultPath
= pAudioPath
;
1105 if (This
->pDefaultPath
) {
1106 IDirectMusicAudioPath_AddRef(This
->pDefaultPath
);
1107 set_audiopath_perf_pointer(This
->pDefaultPath
, iface
);
1113 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetDefaultAudioPath(IDirectMusicPerformance8
*iface
,
1114 IDirectMusicAudioPath
**ppAudioPath
)
1116 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
1118 FIXME("(%p, %p): semi-stub (%p)\n", This
, ppAudioPath
, This
->pDefaultPath
);
1120 if (NULL
!= This
->pDefaultPath
) {
1121 *ppAudioPath
= This
->pDefaultPath
;
1122 IDirectMusicAudioPath_AddRef(*ppAudioPath
);
1124 *ppAudioPath
= NULL
;
1129 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParamEx(IDirectMusicPerformance8
*iface
,
1130 REFGUID rguidType
, DWORD dwTrackID
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
,
1131 MUSIC_TIME
*pmtNext
, void *pParam
)
1133 IDirectMusicPerformance8Impl
*This
= impl_from_IDirectMusicPerformance8(iface
);
1135 FIXME("(%p, %s, %d, %d, %d, %d, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwTrackID
, dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
1140 static const IDirectMusicPerformance8Vtbl DirectMusicPerformance8_Vtbl
= {
1141 IDirectMusicPerformance8Impl_QueryInterface
,
1142 IDirectMusicPerformance8Impl_AddRef
,
1143 IDirectMusicPerformance8Impl_Release
,
1144 IDirectMusicPerformance8Impl_Init
,
1145 IDirectMusicPerformance8Impl_PlaySegment
,
1146 IDirectMusicPerformance8Impl_Stop
,
1147 IDirectMusicPerformance8Impl_GetSegmentState
,
1148 IDirectMusicPerformance8Impl_SetPrepareTime
,
1149 IDirectMusicPerformance8Impl_GetPrepareTime
,
1150 IDirectMusicPerformance8Impl_SetBumperLength
,
1151 IDirectMusicPerformance8Impl_GetBumperLength
,
1152 IDirectMusicPerformance8Impl_SendPMsg
,
1153 IDirectMusicPerformance8Impl_MusicToReferenceTime
,
1154 IDirectMusicPerformance8Impl_ReferenceToMusicTime
,
1155 IDirectMusicPerformance8Impl_IsPlaying
,
1156 IDirectMusicPerformance8Impl_GetTime
,
1157 IDirectMusicPerformance8Impl_AllocPMsg
,
1158 IDirectMusicPerformance8Impl_FreePMsg
,
1159 IDirectMusicPerformance8Impl_GetGraph
,
1160 IDirectMusicPerformance8Impl_SetGraph
,
1161 IDirectMusicPerformance8Impl_SetNotificationHandle
,
1162 IDirectMusicPerformance8Impl_GetNotificationPMsg
,
1163 IDirectMusicPerformance8Impl_AddNotificationType
,
1164 IDirectMusicPerformance8Impl_RemoveNotificationType
,
1165 IDirectMusicPerformance8Impl_AddPort
,
1166 IDirectMusicPerformance8Impl_RemovePort
,
1167 IDirectMusicPerformance8Impl_AssignPChannelBlock
,
1168 IDirectMusicPerformance8Impl_AssignPChannel
,
1169 IDirectMusicPerformance8Impl_PChannelInfo
,
1170 IDirectMusicPerformance8Impl_DownloadInstrument
,
1171 IDirectMusicPerformance8Impl_Invalidate
,
1172 IDirectMusicPerformance8Impl_GetParam
,
1173 IDirectMusicPerformance8Impl_SetParam
,
1174 IDirectMusicPerformance8Impl_GetGlobalParam
,
1175 IDirectMusicPerformance8Impl_SetGlobalParam
,
1176 IDirectMusicPerformance8Impl_GetLatencyTime
,
1177 IDirectMusicPerformance8Impl_GetQueueTime
,
1178 IDirectMusicPerformance8Impl_AdjustTime
,
1179 IDirectMusicPerformance8Impl_CloseDown
,
1180 IDirectMusicPerformance8Impl_GetResolvedTime
,
1181 IDirectMusicPerformance8Impl_MIDIToMusic
,
1182 IDirectMusicPerformance8Impl_MusicToMIDI
,
1183 IDirectMusicPerformance8Impl_TimeToRhythm
,
1184 IDirectMusicPerformance8Impl_RhythmToTime
,
1185 IDirectMusicPerformance8Impl_InitAudio
,
1186 IDirectMusicPerformance8Impl_PlaySegmentEx
,
1187 IDirectMusicPerformance8Impl_StopEx
,
1188 IDirectMusicPerformance8Impl_ClonePMsg
,
1189 IDirectMusicPerformance8Impl_CreateAudioPath
,
1190 IDirectMusicPerformance8Impl_CreateStandardAudioPath
,
1191 IDirectMusicPerformance8Impl_SetDefaultAudioPath
,
1192 IDirectMusicPerformance8Impl_GetDefaultAudioPath
,
1193 IDirectMusicPerformance8Impl_GetParamEx
1196 /* for ClassFactory */
1197 HRESULT WINAPI
create_dmperformance(REFIID lpcGUID
, void **ppobj
)
1199 IDirectMusicPerformance8Impl
*obj
;
1201 TRACE("(%p,%p)\n", lpcGUID
, ppobj
);
1203 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicPerformance8Impl
));
1206 return E_OUTOFMEMORY
;
1208 obj
->IDirectMusicPerformance8_iface
.lpVtbl
= &DirectMusicPerformance8_Vtbl
;
1209 obj
->ref
= 0; /* will be inited by QueryInterface */
1210 obj
->pDirectMusic
= NULL
;
1211 obj
->pDirectSound
= NULL
;
1212 obj
->pDefaultPath
= NULL
;
1213 InitializeCriticalSection(&obj
->safe
);
1214 obj
->safe
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IDirectMusicPerformance8Impl*->safe");
1216 obj
->rtLatencyTime
= 100; /* 100 ms TO FIX */
1217 obj
->dwBumperLength
= 50; /* 50 ms default */
1218 obj
->dwPrepareTime
= 1000; /* 1000 ms default */
1219 return IDirectMusicPerformance8Impl_QueryInterface(&obj
->IDirectMusicPerformance8_iface
,