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 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%x\n", cur
->pMsg
.dwType
);
69 static DWORD WINAPI
ProcessMsgThread(LPVOID lpParam
) {
70 IDirectMusicPerformance8Impl
* This
= lpParam
;
71 DWORD timeOut
= INFINITE
;
74 REFERENCE_TIME rtCurTime
;
75 DMUS_PMSGItem
* it
= NULL
;
76 DMUS_PMSGItem
* cur
= NULL
;
77 DMUS_PMSGItem
* it_next
= NULL
;
80 DWORD dwDec
= This
->rtLatencyTime
+ This
->dwBumperLength
;
82 if (timeOut
> 0) MsgWaitForMultipleObjects(0, NULL
, FALSE
, timeOut
, QS_POSTMESSAGE
|QS_SENDMESSAGE
|QS_TIMER
);
85 EnterCriticalSection(&This
->safe
);
86 hr
= IDirectMusicPerformance8_GetTime((IDirectMusicPerformance8
*) This
, &rtCurTime
, NULL
);
91 for (it
= This
->imm_head
; NULL
!= it
; ) {
93 cur
= ProceedMsg(This
, it
);
94 HeapFree(GetProcessHeap(), 0, cur
);
98 for (it
= This
->head
; NULL
!= it
&& it
->rtItemTime
< rtCurTime
+ dwDec
; ) {
100 cur
= ProceedMsg(This
, it
);
101 HeapFree(GetProcessHeap(), 0, cur
);
105 timeOut
= ( it
->rtItemTime
- rtCurTime
) + This
->rtLatencyTime
;
109 LeaveCriticalSection(&This
->safe
);
111 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) {
112 /** if hwnd we suppose that is a windows event ... */
113 if (NULL
!= msg
.hwnd
) {
114 TranslateMessage(&msg
);
115 DispatchMessageA(&msg
);
117 switch (msg
.message
) {
119 case PROCESSMSG_EXIT
:
121 case PROCESSMSG_START
:
125 case PROCESSMSG_REMOVE
:
128 ERR("Unhandled message %u. Critical Path\n", msg
.message
);
134 /** here we should run a little of current AudioPath */
139 TRACE("(%p): Exiting\n", This
);
144 static BOOL
PostMessageToProcessMsgThread(IDirectMusicPerformance8Impl
* This
, UINT iMsg
) {
145 if (FALSE
== This
->procThreadTicStarted
&& PROCESSMSG_EXIT
!= iMsg
) {
147 This
->procThread
= CreateThread(NULL
, 0, ProcessMsgThread
, This
, 0, &This
->procThreadId
);
148 if (NULL
== This
->procThread
) return FALSE
;
149 SetThreadPriority(This
->procThread
, THREAD_PRIORITY_TIME_CRITICAL
);
150 This
->procThreadTicStarted
= TRUE
;
152 res
= PostThreadMessageA(This
->procThreadId
, iMsg
, 0, 0);
153 /* Let the thread creates its message queue (with MsgWaitForMultipleObjects call) by yielding and retrying */
154 if (!res
&& (GetLastError() == ERROR_INVALID_THREAD_ID
))
161 return PostThreadMessageA(This
->procThreadId
, iMsg
, 0, 0);
164 /* IDirectMusicPerformance8 IUnknown part: */
165 static HRESULT WINAPI
IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface
, REFIID riid
, LPVOID
*ppobj
) {
166 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
167 TRACE("(%p, %s,%p)\n", This
, debugstr_dmguid(riid
), ppobj
);
169 if (IsEqualIID (riid
, &IID_IUnknown
) ||
170 IsEqualIID (riid
, &IID_IDirectMusicPerformance
) ||
171 IsEqualIID (riid
, &IID_IDirectMusicPerformance2
) ||
172 IsEqualIID (riid
, &IID_IDirectMusicPerformance8
)) {
173 IUnknown_AddRef(iface
);
178 WARN("(%p, %s,%p): not found\n", This
, debugstr_dmguid(riid
), ppobj
);
179 return E_NOINTERFACE
;
182 static ULONG WINAPI
IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface
) {
183 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
184 ULONG ref
= InterlockedIncrement(&This
->ref
);
186 TRACE("(%p): AddRef from %d\n", This
, ref
- 1);
193 static ULONG WINAPI
IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface
) {
194 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
195 ULONG ref
= InterlockedDecrement(&This
->ref
);
196 TRACE("(%p): ReleaseRef to %d\n", This
, ref
);
199 This
->safe
.DebugInfo
->Spare
[0] = 0;
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
= pDirectSound
;
223 IDirectSound_AddRef(This
->pDirectSound
);
225 DirectSoundCreate8(NULL
, (LPDIRECTSOUND8
*) &This
->pDirectSound
, NULL
);
226 if (!This
->pDirectSound
) return DSERR_NODRIVER
;
229 IDirectSound8_SetCooperativeLevel(This
->pDirectSound
, hWnd
, DSSCL_PRIORITY
);
231 /* how to get the ForeGround window handle ? */
232 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
236 if (NULL
!= ppDirectMusic
&& NULL
!= *ppDirectMusic
) {
237 /* app creates it's own dmusic object and gives it to performance */
238 This
->pDirectMusic
= (IDirectMusic8
*) *ppDirectMusic
;
239 IDirectMusic8_AddRef(This
->pDirectMusic
);
241 /* app allows the performance to initialise itself and needs a pointer to object*/
242 CoCreateInstance (&CLSID_DirectMusic
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusic8
, (void**)&This
->pDirectMusic
);
244 *ppDirectMusic
= (LPDIRECTMUSIC
) This
->pDirectMusic
;
245 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) *ppDirectMusic
);
252 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
) {
253 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
254 FIXME("(%p, %p, %d, 0x%s, %p): stub\n", This
, pSegment
, dwFlags
,
255 wine_dbgstr_longlong(i64StartTime
), ppSegmentState
);
257 return DMUSIC_CreateDirectMusicSegmentStateImpl(&IID_IDirectMusicSegmentState
, (LPVOID
*)ppSegmentState
, NULL
);
261 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegmentState
, MUSIC_TIME mtTime
, DWORD dwFlags
) {
262 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
263 FIXME("(%p, %p, %p, %d, %d): stub\n", This
, pSegment
, pSegmentState
, mtTime
, dwFlags
);
267 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegmentState
** ppSegmentState
, MUSIC_TIME mtTime
) {
268 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
269 FIXME("(%p,%p, %d): stub\n", This
, ppSegmentState
, mtTime
);
273 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
) {
274 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
275 TRACE("(%p, %d)\n", This
, dwMilliSeconds
);
276 This
->dwPrepareTime
= dwMilliSeconds
;
280 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
) {
281 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
282 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
283 if (NULL
== pdwMilliSeconds
) {
286 *pdwMilliSeconds
= This
->dwPrepareTime
;
290 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
) {
291 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
292 TRACE("(%p, %d)\n", This
, dwMilliSeconds
);
293 This
->dwBumperLength
= dwMilliSeconds
;
297 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
) {
298 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
299 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
300 if (NULL
== pdwMilliSeconds
) {
303 *pdwMilliSeconds
= This
->dwBumperLength
;
307 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
) {
308 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
309 DMUS_PMSGItem
* pItem
= NULL
;
310 DMUS_PMSGItem
* it
= NULL
;
311 DMUS_PMSGItem
* prev_it
= NULL
;
312 DMUS_PMSGItem
** queue
= NULL
;
314 FIXME("(%p, %p): stub\n", This
, pPMSG
);
319 pItem
= DMUS_PMSGToItem(pPMSG
);
324 return DMUS_E_ALREADY_SENT
;
327 /* TODO: Valid Flags */
328 /* TODO: DMUS_PMSGF_MUSICTIME */
329 pItem
->rtItemTime
= pPMSG
->rtTime
;
331 if (pPMSG
->dwFlags
& DMUS_PMSGF_TOOL_IMMEDIATE
) {
332 queue
= &This
->imm_head
;
337 EnterCriticalSection(&This
->safe
);
338 for (it
= *queue
; NULL
!= it
&& it
->rtItemTime
< pItem
->rtItemTime
; it
= it
->next
) {
341 if (NULL
== prev_it
) {
343 if (NULL
!= *queue
) pItem
->next
= (*queue
)->next
;
344 /*assert( NULL == pItem->next->prev );*/
345 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
348 pItem
->prev
= prev_it
;
349 pItem
->next
= prev_it
->next
;
350 prev_it
->next
= pItem
;
351 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
353 LeaveCriticalSection(&This
->safe
);
355 /** now in use, prevent from stupid Frees */
356 pItem
->bInUse
= TRUE
;
360 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, REFERENCE_TIME
* prtTime
) {
361 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
362 FIXME("(%p, %d, %p): stub\n", This
, mtTime
, prtTime
);
366 static HRESULT WINAPI
IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, MUSIC_TIME
* pmtTime
) {
367 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
368 FIXME("(%p, 0x%s, %p): stub\n", This
, wine_dbgstr_longlong(rtTime
), pmtTime
);
372 static HRESULT WINAPI
IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegState
) {
373 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
374 FIXME("(%p, %p, %p): stub\n", This
, pSegment
, pSegState
);
378 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtNow
, MUSIC_TIME
* pmtNow
) {
379 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
381 REFERENCE_TIME rtCur
= 0;
383 /*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */
384 if (This
->procThreadTicStarted
) {
385 rtCur
= ((REFERENCE_TIME
) GetTickCount() * 10000) - This
->procThreadStartTime
;
387 /*return DMUS_E_NO_MASTER_CLOCK;*/
389 if (NULL
!= prtNow
) {
392 if (NULL
!= pmtNow
) {
393 hr
= IDirectMusicPerformance8_ReferenceToMusicTime(iface
, rtCur
, pmtNow
);
398 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, ULONG cb
, DMUS_PMSG
** ppPMSG
) {
399 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
400 DMUS_PMSGItem
* pItem
= NULL
;
402 FIXME("(%p, %d, %p): stub\n", This
, cb
, ppPMSG
);
404 if (sizeof(DMUS_PMSG
) > cb
) {
407 if (NULL
== ppPMSG
) {
410 pItem
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, cb
- sizeof(DMUS_PMSG
) + sizeof(DMUS_PMSGItem
));
412 return E_OUTOFMEMORY
;
414 pItem
->pMsg
.dwSize
= cb
;
415 *ppPMSG
= DMUS_ItemToPMSG(pItem
);
419 static HRESULT WINAPI
IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
) {
420 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
421 DMUS_PMSGItem
* pItem
= NULL
;
423 FIXME("(%p, %p): stub\n", This
, pPMSG
);
428 pItem
= DMUS_PMSGToItem(pPMSG
);
433 /** prevent for freeing PMsg in queue (ie to be processed) */
434 return DMUS_E_CANNOT_FREE
;
436 /** now we can remove it safely */
437 EnterCriticalSection(&This
->safe
);
438 DMUS_ItemRemoveFromQueue( This
, pItem
);
439 LeaveCriticalSection(&This
->safe
);
441 /** TODO: see if we should Release the pItem->pMsg->punkUser and others Interfaces */
442 HeapFree(GetProcessHeap(), 0, pItem
);
446 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
** ppGraph
) {
447 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
448 FIXME("(%p, %p): to check\n", This
, ppGraph
);
449 if (NULL
!= This
->pToolGraph
) {
450 *ppGraph
= This
->pToolGraph
;
451 IDirectMusicGraph_AddRef(*ppGraph
);
458 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
* pGraph
) {
459 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
461 FIXME("(%p, %p): to check\n", This
, pGraph
);
463 if (NULL
!= This
->pToolGraph
) {
464 /* Todo clean buffers and tools before */
465 IDirectMusicGraph_Release(This
->pToolGraph
);
467 This
->pToolGraph
= pGraph
;
468 if (NULL
!= This
->pToolGraph
) {
469 IDirectMusicGraph_AddRef(This
->pToolGraph
);
474 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface
, HANDLE hNotification
, REFERENCE_TIME rtMinimum
) {
475 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
476 FIXME("(%p, %p, 0x%s): stub\n", This
, hNotification
, wine_dbgstr_longlong(rtMinimum
));
477 This
->hNotification
= hNotification
;
478 if (rtMinimum
) This
->rtMinimum
= rtMinimum
;
482 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_NOTIFICATION_PMSG
** ppNotificationPMsg
) {
483 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
486 FIXME("(%p, %p): stub\n", This
, ppNotificationPMsg
);
487 if (NULL
== ppNotificationPMsg
) {
497 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
) {
498 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
499 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
503 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
) {
504 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
505 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
509 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
) {
510 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
512 FIXME("(%p, %p): stub\n", This
, pPort
);
513 if (!This
->pDirectMusic
|| !This
->pDirectSound
) return DMUS_E_NOT_INIT
;
516 IDirectMusicPort
* pDefaultPort
= NULL
;
517 DMUS_PORTPARAMS params
;
519 hr
= IDirectMusic8_GetDefaultPort(This
->pDirectMusic
, &port_guid
);
520 if (FAILED(hr
)) return hr
;
521 ZeroMemory(¶ms
, sizeof(params
));
522 params
.dwSize
= sizeof(params
);
523 params
.dwValidParams
= DMUS_PORTPARAMS_CHANNELGROUPS
| DMUS_PORTPARAMS_SHARE
;
524 params
.dwChannelGroups
= 1;
525 params
.fShare
= TRUE
;
526 hr
= IDirectMusic8_CreatePort(This
->pDirectMusic
, &port_guid
, ¶ms
, &pDefaultPort
, NULL
);
527 if (FAILED(hr
)) return hr
;
528 hr
= IDirectMusicPort_Activate(pDefaultPort
, TRUE
);
529 if (FAILED(hr
)) { IDirectMusicPort_Release(pDefaultPort
); return hr
; }
531 for (i
= 0; i
< 16; ++i
) {
532 if (NULL
== This
->PChannel
[i
].port
) {
533 This
->PChannel
[i
].port
= pPort
;
534 This
->PChannel
[i
].group
= 0;
535 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
540 IDirectMusicPort_AddRef(pPort
);
543 * We should remember added Ports (for example using a list)
544 * and control if Port is registered for each api who use ports
549 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
) {
550 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
551 FIXME("(%p, %p): stub\n", This
, pPort
);
552 IDirectMusicPort_Release (pPort
);
556 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwBlockNum
, IDirectMusicPort
* pPort
, DWORD dwGroup
) {
557 int i
, j
, range
/* min value in range */;
558 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
560 FIXME("(%p, %d, %p, %d): semi-stub\n", This
, dwBlockNum
, pPort
, dwGroup
-1);
561 if (NULL
== pPort
) return E_POINTER
;
563 range
= 16 * dwBlockNum
;
565 for (i
= range
; i
< range
+16; i
++) {
566 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
567 This
->PChannel
[i
].port
= pPort
;
568 This
->PChannel
[i
].group
= dwGroup
- 1; /* first index is always zero */
569 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
572 /*if (dwGroup > 2) return S_FALSE;*/
577 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
* pPort
, DWORD dwGroup
, DWORD dwMChannel
) {
578 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
580 TRACE("(%p, %d, %p, %d, %d)\n", This
, dwPChannel
, pPort
, dwGroup
, dwMChannel
);
581 if (NULL
== pPort
) return E_POINTER
;
582 This
->PChannel
[dwPChannel
].port
= pPort
;
583 This
->PChannel
[dwPChannel
].group
= dwGroup
;
584 This
->PChannel
[dwPChannel
].channel
= dwMChannel
;
589 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
) {
590 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
591 FIXME("(%p, %d, %p, %p, %p): stub\n", This
, dwPChannel
, ppPort
, pdwGroup
, pdwMChannel
);
595 static HRESULT WINAPI
IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicInstrument
* pInst
, DWORD dwPChannel
, IDirectMusicDownloadedInstrument
** ppDownInst
, DMUS_NOTERANGE
* pNoteRanges
, DWORD dwNumNoteRanges
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
) {
596 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
597 FIXME("(%p, %p, %d, %p, %p, %d, %p, %p, %p): stub\n", This
, pInst
, dwPChannel
, ppDownInst
, pNoteRanges
, dwNumNoteRanges
, ppPort
, pdwGroup
, pdwMChannel
);
601 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DWORD dwFlags
) {
602 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
603 FIXME("(%p, %d, %d): stub\n", This
, mtTime
, dwFlags
);
607 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
) {
608 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
609 FIXME("(%p, %s, %d, %d, %d, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
613 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, void* pParam
) {
614 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
615 FIXME("(%p, %s, %d, %d, %d, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pParam
);
619 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
) {
620 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
622 TRACE("(%p, %s, %p, %d): stub\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
624 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
))
625 memcpy(pParam
, &This
->fAutoDownload
, sizeof(This
->fAutoDownload
));
626 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
))
627 memcpy(pParam
, &This
->cMasterGrooveLevel
, sizeof(This
->cMasterGrooveLevel
));
628 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
))
629 memcpy(pParam
, &This
->fMasterTempo
, sizeof(This
->fMasterTempo
));
630 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
))
631 memcpy(pParam
, &This
->lMasterVolume
, sizeof(This
->lMasterVolume
));
636 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
) {
637 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
639 TRACE("(%p, %s, %p, %d)\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
641 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
)) {
642 memcpy(&This
->fAutoDownload
, pParam
, dwSize
);
643 TRACE("=> AutoDownload set to %d\n", This
->fAutoDownload
);
645 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
)) {
646 memcpy(&This
->cMasterGrooveLevel
, pParam
, dwSize
);
647 TRACE("=> MasterGrooveLevel set to %i\n", This
->cMasterGrooveLevel
);
649 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
)) {
650 memcpy(&This
->fMasterTempo
, pParam
, dwSize
);
651 TRACE("=> MasterTempo set to %f\n", This
->fMasterTempo
);
653 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
)) {
654 memcpy(&This
->lMasterVolume
, pParam
, dwSize
);
655 TRACE("=> MasterVolume set to %li\n", This
->lMasterVolume
);
661 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
) {
662 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
663 TRACE("(%p, %p): stub\n", This
, prtTime
);
664 *prtTime
= This
->rtLatencyTime
;
668 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
) {
669 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
670 FIXME("(%p, %p): stub\n", This
, prtTime
);
674 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtAmount
) {
675 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
676 FIXME("(%p, 0x%s): stub\n", This
, wine_dbgstr_longlong(rtAmount
));
680 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface
) {
681 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
682 FIXME("(%p): stub\n", This
);
683 if (PostMessageToProcessMsgThread(This
, PROCESSMSG_EXIT
)) {
684 WaitForSingleObject(This
->procThread
, INFINITE
);
685 This
->procThreadTicStarted
= FALSE
;
686 CloseHandle(This
->procThread
);
688 if (NULL
!= This
->pDirectSound
) {
689 IDirectSound_Release(This
->pDirectSound
);
690 This
->pDirectSound
= NULL
;
692 if (NULL
!= This
->pDirectMusic
) {
693 IDirectMusic8_Release(This
->pDirectMusic
);
694 This
->pDirectMusic
= NULL
;
699 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, REFERENCE_TIME
* prtResolved
, DWORD dwTimeResolveFlags
) {
700 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
701 FIXME("(%p, 0x%s, %p, %d): stub\n", This
, wine_dbgstr_longlong(rtTime
),
702 prtResolved
, dwTimeResolveFlags
);
706 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface
, BYTE bMIDIValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, WORD
* pwMusicValue
) {
707 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
708 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, bMIDIValue
, pChord
, bPlayMode
, bChordLevel
, pwMusicValue
);
712 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMusicValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, BYTE
* pbMIDIValue
) {
713 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
714 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, wMusicValue
, pChord
, bPlayMode
, bChordLevel
, pbMIDIValue
);
718 static HRESULT WINAPI
IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DMUS_TIMESIGNATURE
* pTimeSig
, WORD
* pwMeasure
, BYTE
* pbBeat
, BYTE
* pbGrid
, short* pnOffset
) {
719 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
720 FIXME("(%p, %d, %p, %p, %p, %p, %p): stub\n", This
, mtTime
, pTimeSig
, pwMeasure
, pbBeat
, pbGrid
, pnOffset
);
724 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMeasure
, BYTE bBeat
, BYTE bGrid
, short nOffset
, DMUS_TIMESIGNATURE
* pTimeSig
, MUSIC_TIME
* pmtTime
) {
725 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
726 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This
, wMeasure
, bBeat
, bGrid
, nOffset
, pTimeSig
, pmtTime
);
730 /* IDirectMusicPerformance8 Interface part follow: */
731 static HRESULT WINAPI
IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 iface
,
732 IDirectMusic
** ppDirectMusic
,
733 IDirectSound
** ppDirectSound
,
735 DWORD dwDefaultPathType
,
736 DWORD dwPChannelCount
,
738 DMUS_AUDIOPARAMS
* pParams
) {
740 IDirectSound
* dsound
= NULL
;
743 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
744 FIXME("(%p, %p, %p, %p, %x, %u, %x, %p): to check\n", This
, ppDirectMusic
, ppDirectSound
, hWnd
, dwDefaultPathType
, dwPChannelCount
, dwFlags
, pParams
);
746 if (This
->pDirectMusic
|| This
->pDirectSound
)
747 return DMUS_E_ALREADY_INITED
;
749 if (NULL
!= ppDirectSound
&& NULL
!= *ppDirectSound
) {
750 dsound
= *ppDirectSound
;
752 hr
= DirectSoundCreate8 (NULL
, (LPDIRECTSOUND8
*) &dsound
, NULL
);
753 FIXME("return dsound(%p,%d)\n", dsound
, hr
);
754 if (FAILED(hr
) || !dsound
)
755 return DSERR_NODRIVER
;
757 *ppDirectSound
= dsound
;
760 IDirectMusicPerformance8Impl_Init(iface
, ppDirectMusic
, dsound
, hWnd
);
762 /* Init increases the ref count of the dsound object. Decrement it if the app doesn't want a pointer to the object. */
763 if (NULL
== ppDirectSound
) {
764 IDirectSound_Release(This
->pDirectSound
);
767 /* as seen in msdn we need params init before audio path creation */
768 if (NULL
!= pParams
) {
769 This
->pParams
= *pParams
;
771 /* TODO, how can i fill the struct as seen on msdn */
772 memset(&This
->pParams
, 0, sizeof(DMUS_AUDIOPARAMS
));
773 This
->pParams
.dwSize
= sizeof(DMUS_AUDIOPARAMS
);
774 This
->pParams
.fInitNow
= FALSE
;
775 This
->pParams
.dwValidData
= DMUS_AUDIOPARAMS_FEATURES
| DMUS_AUDIOPARAMS_VOICES
| DMUS_AUDIOPARAMS_SAMPLERATE
| DMUS_AUDIOPARAMS_DEFAULTSYNTH
;
776 This
->pParams
.dwVoices
= 64;
777 This
->pParams
.dwSampleRate
= (DWORD
) 22.050;
778 This
->pParams
.dwFeatures
= dwFlags
;
779 This
->pParams
.clsidDefaultSynth
= CLSID_DirectMusicSynthSink
;
781 hr
= IDirectMusicPerformance8_CreateStandardAudioPath(iface
, dwDefaultPathType
, dwPChannelCount
, FALSE
, &This
->pDefaultPath
);
783 PostMessageToProcessMsgThread(This
, PROCESSMSG_START
);
788 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSource
, WCHAR
* pwzSegmentName
, IUnknown
* pTransition
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
, IUnknown
* pFrom
, IUnknown
* pAudioPath
) {
789 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
790 FIXME("(%p, %p, %p, %p, %d, 0x%s, %p, %p, %p): stub\n", This
, pSource
, pwzSegmentName
,
791 pTransition
, dwFlags
, wine_dbgstr_longlong(i64StartTime
), ppSegmentState
, pFrom
, pAudioPath
);
793 return DMUSIC_CreateDirectMusicSegmentStateImpl(&IID_IDirectMusicSegmentState
, (LPVOID
*)ppSegmentState
, NULL
);
797 static HRESULT WINAPI
IDirectMusicPerformance8Impl_StopEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pObjectToStop
, __int64 i64StopTime
, DWORD dwFlags
) {
798 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
799 FIXME("(%p, %p, 0x%s, %d): stub\n", This
, pObjectToStop
,
800 wine_dbgstr_longlong(i64StopTime
), dwFlags
);
804 static HRESULT WINAPI
IDirectMusicPerformance8Impl_ClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pSourcePMSG
, DMUS_PMSG
** ppCopyPMSG
) {
805 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
806 FIXME("(%p, %p, %p): stub\n", This
, pSourcePMSG
, ppCopyPMSG
);
810 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSourceConfig
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
) {
811 IDirectMusicAudioPathImpl
*default_path
;
812 IDirectMusicAudioPath
*pPath
;
814 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
815 FIXME("(%p, %p, %d, %p): stub\n", This
, pSourceConfig
, fActivate
, ppNewPath
);
817 if (NULL
== ppNewPath
) {
821 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath
, (LPVOID
*)&pPath
, NULL
);
822 default_path
= (IDirectMusicAudioPathImpl
*)((char*)(pPath
) - offsetof(IDirectMusicAudioPathImpl
,AudioPathVtbl
));
823 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
829 return IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
832 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwType
, DWORD dwPChannelCount
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
) {
833 IDirectMusicAudioPathImpl
*default_path
;
834 IDirectMusicAudioPath
*pPath
;
837 LPDIRECTSOUNDBUFFER buffer
;
840 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
842 FIXME("(%p)->(%d, %d, %d, %p): semi-stub\n", This
, dwType
, dwPChannelCount
, fActivate
, ppNewPath
);
844 if (NULL
== ppNewPath
) {
848 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath
, (LPVOID
*)&pPath
, NULL
);
849 default_path
= (IDirectMusicAudioPathImpl
*)((char*)(pPath
) - offsetof(IDirectMusicAudioPathImpl
,AudioPathVtbl
));
850 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
852 /* Secondary buffer description */
853 memset(&format
, 0, sizeof(format
));
854 format
.wFormatTag
= WAVE_FORMAT_PCM
;
855 format
.nChannels
= 1;
856 format
.nSamplesPerSec
= 44000;
857 format
.nAvgBytesPerSec
= 44000*2;
858 format
.nBlockAlign
= 2;
859 format
.wBitsPerSample
= 16;
862 memset(&desc
, 0, sizeof(desc
));
863 desc
.dwSize
= sizeof(desc
);
864 desc
.dwFlags
= DSBCAPS_CTRLFX
| DSBCAPS_CTRLPAN
| DSBCAPS_CTRLVOLUME
| DSBCAPS_GLOBALFOCUS
;
865 desc
.dwBufferBytes
= DSBSIZE_MIN
;
867 desc
.lpwfxFormat
= &format
;
868 desc
.guid3DAlgorithm
= GUID_NULL
;
871 case DMUS_APATH_DYNAMIC_3D
:
872 desc
.dwFlags
|= DSBCAPS_CTRL3D
| DSBCAPS_CTRLFREQUENCY
| DSBCAPS_MUTE3DATMAXDISTANCE
;
874 case DMUS_APATH_DYNAMIC_MONO
:
875 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
877 case DMUS_APATH_SHARED_STEREOPLUSREVERB
:
878 /* normally we have to create 2 buffers (one for music other for reverb)
879 * in this case. See msdn
881 case DMUS_APATH_DYNAMIC_STEREO
:
882 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
883 format
.nChannels
= 2;
884 format
.nBlockAlign
*= 2;
885 format
.nAvgBytesPerSec
*=2;
888 HeapFree(GetProcessHeap(), 0, default_path
);
893 /* FIXME: Should we create one secondary buffer for each PChannel? */
894 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
896 HeapFree(GetProcessHeap(), 0, default_path
);
898 return DSERR_BUFFERLOST
;
900 default_path
->pDSBuffer
= buffer
;
902 /* Update description for creating primary buffer */
903 desc
.dwFlags
|= DSBCAPS_PRIMARYBUFFER
;
904 desc
.dwBufferBytes
= 0;
905 desc
.lpwfxFormat
= NULL
;
907 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
909 IDirectSoundBuffer_Release(default_path
->pDSBuffer
);
910 HeapFree(GetProcessHeap(), 0, default_path
);
912 return DSERR_BUFFERLOST
;
914 default_path
->pPrimary
= buffer
;
918 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath
);
920 return IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
923 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
* pAudioPath
) {
924 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
926 FIXME("(%p, %p): semi-stub\n", This
, pAudioPath
);
927 if (NULL
!= This
->pDefaultPath
) {
928 IDirectMusicAudioPath_Release(This
->pDefaultPath
);
929 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= NULL
;
930 This
->pDefaultPath
= NULL
;
932 This
->pDefaultPath
= pAudioPath
;
933 if (NULL
!= This
->pDefaultPath
) {
934 IDirectMusicAudioPath_AddRef(This
->pDefaultPath
);
935 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= (IDirectMusicPerformance8
*) This
;
941 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
** ppAudioPath
) {
942 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
944 FIXME("(%p, %p): semi-stub (%p)\n", This
, ppAudioPath
, This
->pDefaultPath
);
946 if (NULL
!= This
->pDefaultPath
) {
947 *ppAudioPath
= This
->pDefaultPath
;
948 IDirectMusicAudioPath_AddRef(*ppAudioPath
);
955 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParamEx (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwTrackID
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
) {
956 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
958 FIXME("(%p, %s, %d, %d, %d, %d, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwTrackID
, dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
963 static const IDirectMusicPerformance8Vtbl DirectMusicPerformance8_Vtbl
= {
964 IDirectMusicPerformance8Impl_QueryInterface
,
965 IDirectMusicPerformance8Impl_AddRef
,
966 IDirectMusicPerformance8Impl_Release
,
967 IDirectMusicPerformance8Impl_Init
,
968 IDirectMusicPerformance8Impl_PlaySegment
,
969 IDirectMusicPerformance8Impl_Stop
,
970 IDirectMusicPerformance8Impl_GetSegmentState
,
971 IDirectMusicPerformance8Impl_SetPrepareTime
,
972 IDirectMusicPerformance8Impl_GetPrepareTime
,
973 IDirectMusicPerformance8Impl_SetBumperLength
,
974 IDirectMusicPerformance8Impl_GetBumperLength
,
975 IDirectMusicPerformance8Impl_SendPMsg
,
976 IDirectMusicPerformance8Impl_MusicToReferenceTime
,
977 IDirectMusicPerformance8Impl_ReferenceToMusicTime
,
978 IDirectMusicPerformance8Impl_IsPlaying
,
979 IDirectMusicPerformance8Impl_GetTime
,
980 IDirectMusicPerformance8Impl_AllocPMsg
,
981 IDirectMusicPerformance8Impl_FreePMsg
,
982 IDirectMusicPerformance8Impl_GetGraph
,
983 IDirectMusicPerformance8Impl_SetGraph
,
984 IDirectMusicPerformance8Impl_SetNotificationHandle
,
985 IDirectMusicPerformance8Impl_GetNotificationPMsg
,
986 IDirectMusicPerformance8Impl_AddNotificationType
,
987 IDirectMusicPerformance8Impl_RemoveNotificationType
,
988 IDirectMusicPerformance8Impl_AddPort
,
989 IDirectMusicPerformance8Impl_RemovePort
,
990 IDirectMusicPerformance8Impl_AssignPChannelBlock
,
991 IDirectMusicPerformance8Impl_AssignPChannel
,
992 IDirectMusicPerformance8Impl_PChannelInfo
,
993 IDirectMusicPerformance8Impl_DownloadInstrument
,
994 IDirectMusicPerformance8Impl_Invalidate
,
995 IDirectMusicPerformance8Impl_GetParam
,
996 IDirectMusicPerformance8Impl_SetParam
,
997 IDirectMusicPerformance8Impl_GetGlobalParam
,
998 IDirectMusicPerformance8Impl_SetGlobalParam
,
999 IDirectMusicPerformance8Impl_GetLatencyTime
,
1000 IDirectMusicPerformance8Impl_GetQueueTime
,
1001 IDirectMusicPerformance8Impl_AdjustTime
,
1002 IDirectMusicPerformance8Impl_CloseDown
,
1003 IDirectMusicPerformance8Impl_GetResolvedTime
,
1004 IDirectMusicPerformance8Impl_MIDIToMusic
,
1005 IDirectMusicPerformance8Impl_MusicToMIDI
,
1006 IDirectMusicPerformance8Impl_TimeToRhythm
,
1007 IDirectMusicPerformance8Impl_RhythmToTime
,
1008 IDirectMusicPerformance8Impl_InitAudio
,
1009 IDirectMusicPerformance8Impl_PlaySegmentEx
,
1010 IDirectMusicPerformance8Impl_StopEx
,
1011 IDirectMusicPerformance8Impl_ClonePMsg
,
1012 IDirectMusicPerformance8Impl_CreateAudioPath
,
1013 IDirectMusicPerformance8Impl_CreateStandardAudioPath
,
1014 IDirectMusicPerformance8Impl_SetDefaultAudioPath
,
1015 IDirectMusicPerformance8Impl_GetDefaultAudioPath
,
1016 IDirectMusicPerformance8Impl_GetParamEx
1019 /* for ClassFactory */
1020 HRESULT WINAPI
DMUSIC_CreateDirectMusicPerformanceImpl (LPCGUID lpcGUID
, LPVOID
*ppobj
, LPUNKNOWN pUnkOuter
) {
1021 IDirectMusicPerformance8Impl
*obj
;
1023 TRACE("(%p,%p,%p)\n", lpcGUID
, ppobj
, pUnkOuter
);
1025 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicPerformance8Impl
));
1028 return E_OUTOFMEMORY
;
1030 obj
->lpVtbl
= &DirectMusicPerformance8_Vtbl
;
1031 obj
->ref
= 0; /* will be inited by QueryInterface */
1032 obj
->pDirectMusic
= NULL
;
1033 obj
->pDirectSound
= NULL
;
1034 obj
->pDefaultPath
= NULL
;
1035 InitializeCriticalSection(&obj
->safe
);
1036 obj
->safe
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IDirectMusicPerformance8Impl*->safe");
1038 obj
->rtLatencyTime
= 100; /* 100ms TO FIX */
1039 obj
->dwBumperLength
= 50; /* 50ms default */
1040 obj
->dwPrepareTime
= 1000; /* 1000ms default */
1041 return IDirectMusicPerformance8Impl_QueryInterface ((LPDIRECTMUSICPERFORMANCE8
)obj
, lpcGUID
, ppobj
);