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
= (IDirectMusicPerformance8Impl
*) 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
;
79 RENAME_CURRENT_THREAD("dmime process message thread");
82 DWORD dwDec
= This
->rtLatencyTime
+ This
->dwBumperLength
;
84 if (timeOut
> 0) MsgWaitForMultipleObjects(0, NULL
, FALSE
, timeOut
, QS_POSTMESSAGE
|QS_SENDMESSAGE
|QS_TIMER
);
87 EnterCriticalSection(&This
->safe
);
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_IDirectMusicPerformance2
) ||
174 IsEqualIID (riid
, &IID_IDirectMusicPerformance8
)) {
175 IUnknown_AddRef(iface
);
180 WARN("(%p, %s,%p): not found\n", This
, debugstr_dmguid(riid
), ppobj
);
181 return E_NOINTERFACE
;
184 static ULONG WINAPI
IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface
) {
185 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
186 ULONG ref
= InterlockedIncrement(&This
->ref
);
188 TRACE("(%p): AddRef from %d\n", This
, ref
- 1);
195 static ULONG WINAPI
IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface
) {
196 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
197 ULONG ref
= InterlockedDecrement(&This
->ref
);
198 TRACE("(%p): ReleaseRef to %d\n", This
, ref
);
201 This
->safe
.DebugInfo
->Spare
[0] = 0;
202 DeleteCriticalSection(&This
->safe
);
203 HeapFree(GetProcessHeap(), 0, This
);
206 DMIME_UnlockModule();
211 /* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
212 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusic
** ppDirectMusic
, LPDIRECTSOUND pDirectSound
, HWND hWnd
) {
213 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
215 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This
, ppDirectMusic
, pDirectSound
, hWnd
);
216 if (This
->pDirectMusic
|| This
->pDirectSound
)
217 return DMUS_E_ALREADY_INITED
;
220 hWnd
= GetForegroundWindow();
223 if (NULL
!= pDirectSound
) {
224 This
->pDirectSound
= pDirectSound
;
225 IDirectSound_AddRef(This
->pDirectSound
);
228 hr
= DirectSoundCreate8(NULL
, (LPDIRECTSOUND8
*) &This
->pDirectSound
, NULL
);
229 if (!This
->pDirectSound
) return DSERR_NODRIVER
;
234 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp
237 IDirectSound8_SetCooperativeLevel(This
->pDirectSound
, hWnd
, DSSCL_PRIORITY
);
239 /* how to get the ForeGround window handle ? */
240 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
244 if (NULL
!= ppDirectMusic
&& NULL
!= *ppDirectMusic
) {
245 /* app creates it's own dmusic object and gives it to performance */
246 This
->pDirectMusic
= (IDirectMusic8
*) *ppDirectMusic
;
247 IDirectMusic8_AddRef(This
->pDirectMusic
);
249 /* app allows the performance to initialise itfself and needs a pointer to object*/
250 CoCreateInstance (&CLSID_DirectMusic
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusic8
, (void**)&This
->pDirectMusic
);
252 *ppDirectMusic
= (LPDIRECTMUSIC
) This
->pDirectMusic
;
253 IDirectMusic8_AddRef((LPDIRECTMUSIC8
) *ppDirectMusic
);
260 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
) {
261 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
262 FIXME("(%p, %p, %d, 0x%s, %p): stub\n", This
, pSegment
, dwFlags
,
263 wine_dbgstr_longlong(i64StartTime
), ppSegmentState
);
267 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegmentState
, MUSIC_TIME mtTime
, DWORD dwFlags
) {
268 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
269 FIXME("(%p, %p, %p, %ld, %d): stub\n", This
, pSegment
, pSegmentState
, mtTime
, dwFlags
);
273 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegmentState
** ppSegmentState
, MUSIC_TIME mtTime
) {
274 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
275 FIXME("(%p,%p, %ld): stub\n", This
, ppSegmentState
, mtTime
);
279 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
) {
280 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
281 TRACE("(%p, %d)\n", This
, dwMilliSeconds
);
282 This
->dwPrepareTime
= dwMilliSeconds
;
286 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
) {
287 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
288 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
289 if (NULL
== pdwMilliSeconds
) {
292 *pdwMilliSeconds
= This
->dwPrepareTime
;
296 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwMilliSeconds
) {
297 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
298 TRACE("(%p, %d)\n", This
, dwMilliSeconds
);
299 This
->dwBumperLength
= dwMilliSeconds
;
303 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD
* pdwMilliSeconds
) {
304 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
305 TRACE("(%p, %p)\n", This
, pdwMilliSeconds
);
306 if (NULL
== pdwMilliSeconds
) {
309 *pdwMilliSeconds
= This
->dwBumperLength
;
313 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
) {
314 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
315 DMUS_PMSGItem
* pItem
= NULL
;
316 DMUS_PMSGItem
* it
= NULL
;
317 DMUS_PMSGItem
* prev_it
= NULL
;
318 DMUS_PMSGItem
** queue
= NULL
;
320 FIXME("(%p, %p): stub\n", This
, pPMSG
);
325 pItem
= DMUS_PMSGToItem(pPMSG
);
330 return DMUS_E_ALREADY_SENT
;
333 /* TODO: Valid Flags */
334 /* TODO: DMUS_PMSGF_MUSICTIME */
335 pItem
->rtItemTime
= pPMSG
->rtTime
;
337 if (pPMSG
->dwFlags
& DMUS_PMSGF_TOOL_IMMEDIATE
) {
338 queue
= &This
->imm_head
;
343 EnterCriticalSection(&This
->safe
);
344 for (it
= *queue
; NULL
!= it
&& it
->rtItemTime
< pItem
->rtItemTime
; it
= it
->next
) {
347 if (NULL
== prev_it
) {
349 if (NULL
!= *queue
) pItem
->next
= (*queue
)->next
;
350 /*assert( NULL == pItem->next->prev );*/
351 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
354 pItem
->prev
= prev_it
;
355 pItem
->next
= prev_it
->next
;
356 prev_it
->next
= pItem
;
357 if (NULL
!= pItem
->next
) pItem
->next
->prev
= pItem
;
359 LeaveCriticalSection(&This
->safe
);
361 /** now in use, prevent from stupid Frees */
362 pItem
->bInUse
= TRUE
;
366 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, REFERENCE_TIME
* prtTime
) {
367 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
368 FIXME("(%p, %ld, %p): stub\n", This
, mtTime
, prtTime
);
372 static HRESULT WINAPI
IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, MUSIC_TIME
* pmtTime
) {
373 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
374 FIXME("(%p, 0x%s, %p): stub\n", This
, wine_dbgstr_longlong(rtTime
), pmtTime
);
378 static HRESULT WINAPI
IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicSegment
* pSegment
, IDirectMusicSegmentState
* pSegState
) {
379 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
380 FIXME("(%p, %p, %p): stub\n", This
, pSegment
, pSegState
);
384 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtNow
, MUSIC_TIME
* pmtNow
) {
385 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
387 REFERENCE_TIME rtCur
= 0;
389 /*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */
390 if (This
->procThreadTicStarted
) {
391 rtCur
= ((REFERENCE_TIME
) GetTickCount() * 10000) - This
->procThreadStartTime
;
393 /*return DMUS_E_NO_MASTER_CLOCK;*/
395 if (NULL
!= prtNow
) {
398 if (NULL
!= pmtNow
) {
399 hr
= IDirectMusicPerformance8_ReferenceToMusicTime(iface
, rtCur
, pmtNow
);
404 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, ULONG cb
, DMUS_PMSG
** ppPMSG
) {
405 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
406 DMUS_PMSGItem
* pItem
= NULL
;
408 FIXME("(%p, %d, %p): stub\n", This
, cb
, ppPMSG
);
410 if (sizeof(DMUS_PMSG
) > cb
) {
413 if (NULL
== ppPMSG
) {
416 pItem
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, cb
- sizeof(DMUS_PMSG
) + sizeof(DMUS_PMSGItem
));
418 return E_OUTOFMEMORY
;
420 pItem
->pMsg
.dwSize
= cb
;
421 *ppPMSG
= DMUS_ItemToPMSG(pItem
);
425 static HRESULT WINAPI
IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pPMSG
) {
426 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
427 DMUS_PMSGItem
* pItem
= NULL
;
429 FIXME("(%p, %p): stub\n", This
, pPMSG
);
434 pItem
= DMUS_PMSGToItem(pPMSG
);
439 /** prevent for freeing PMsg in queue (ie to be processed) */
440 return DMUS_E_CANNOT_FREE
;
442 /** now we can remove it safely */
443 EnterCriticalSection(&This
->safe
);
444 DMUS_ItemRemoveFromQueue( This
, pItem
);
445 LeaveCriticalSection(&This
->safe
);
447 /** TODO: see if we should Release the pItem->pMsg->punkUser and others Interfaces */
448 HeapFree(GetProcessHeap(), 0, pItem
);
452 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
** ppGraph
) {
453 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
454 FIXME("(%p, %p): to check\n", This
, ppGraph
);
455 if (NULL
!= This
->pToolGraph
) {
456 *ppGraph
= This
->pToolGraph
;
457 IDirectMusicGraph_AddRef(*ppGraph
);
464 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicGraph
* pGraph
) {
465 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
467 FIXME("(%p, %p): to check\n", This
, pGraph
);
469 if (NULL
!= This
->pToolGraph
) {
470 /* Todo clean buffers and tools before */
471 IDirectMusicGraph_Release(This
->pToolGraph
);
473 This
->pToolGraph
= pGraph
;
474 if (NULL
!= This
->pToolGraph
) {
475 IDirectMusicGraph_AddRef(This
->pToolGraph
);
480 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface
, HANDLE hNotification
, REFERENCE_TIME rtMinimum
) {
481 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
482 FIXME("(%p, %p, 0x%s): stub\n", This
, hNotification
, wine_dbgstr_longlong(rtMinimum
));
483 This
->hNotification
= hNotification
;
484 if (rtMinimum
) This
->rtMinimum
= rtMinimum
;
488 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_NOTIFICATION_PMSG
** ppNotificationPMsg
) {
489 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
492 FIXME("(%p, %p): stub\n", This
, ppNotificationPMsg
);
493 if (NULL
== ppNotificationPMsg
) {
503 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
) {
504 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
505 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
509 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidNotificationType
) {
510 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
511 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
515 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
) {
516 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
518 FIXME("(%p, %p): stub\n", This
, pPort
);
519 if (!This
->pDirectMusic
|| !This
->pDirectSound
) return DMUS_E_NOT_INIT
;
522 IDirectMusicPort
* pDefaultPort
= NULL
;
523 DMUS_PORTPARAMS params
;
525 hr
= IDirectMusic8_GetDefaultPort(This
->pDirectMusic
, &port_guid
);
526 if (FAILED(hr
)) return hr
;
527 ZeroMemory(¶ms
, sizeof(params
));
528 params
.dwSize
= sizeof(params
);
529 params
.dwValidParams
= DMUS_PORTPARAMS_CHANNELGROUPS
| DMUS_PORTPARAMS_SHARE
;
530 params
.dwChannelGroups
= 1;
531 params
.fShare
= TRUE
;
532 hr
= IDirectMusic8_CreatePort(This
->pDirectMusic
, &port_guid
, ¶ms
, &pDefaultPort
, NULL
);
533 if (FAILED(hr
)) return hr
;
534 hr
= IDirectMusicPort_Activate(pDefaultPort
, TRUE
);
535 if (FAILED(hr
)) { IDirectMusicPort_Release(pDefaultPort
); return hr
; }
537 for (i
= 0; i
< 16; ++i
) {
538 if (NULL
== This
->PChannel
[i
].port
) {
539 This
->PChannel
[i
].port
= pPort
;
540 This
->PChannel
[i
].group
= 0;
541 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
546 IDirectMusicPort_AddRef(pPort
);
549 * We should remember added Ports (for example using a list)
550 * and control if Port is registered for each api who use ports
555 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicPort
* pPort
) {
556 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
557 FIXME("(%p, %p): stub\n", This
, pPort
);
558 IDirectMusicPort_Release (pPort
);
562 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwBlockNum
, IDirectMusicPort
* pPort
, DWORD dwGroup
) {
563 int i
, j
, range
/* min value in range */;
564 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
566 FIXME("(%p, %d, %p, %d): semi-stub\n", This
, dwBlockNum
, pPort
, dwGroup
-1);
567 if (NULL
== pPort
) return E_POINTER
;
569 range
= 16 * dwBlockNum
;
571 for (i
= range
; i
< range
+16; i
++) {
572 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
573 This
->PChannel
[i
].port
= pPort
;
574 This
->PChannel
[i
].group
= dwGroup
- 1; /* first index is always zero */
575 This
->PChannel
[i
].channel
= j
; /* FIXME: should this be assigned? */
578 /*if (dwGroup > 2) return S_FALSE;*/
583 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
* pPort
, DWORD dwGroup
, DWORD dwMChannel
) {
584 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
586 TRACE("(%p, %d, %p, %d, %d)\n", This
, dwPChannel
, pPort
, dwGroup
, dwMChannel
);
587 if (NULL
== pPort
) return E_POINTER
;
588 This
->PChannel
[dwPChannel
].port
= pPort
;
589 This
->PChannel
[dwPChannel
].group
= dwGroup
;
590 This
->PChannel
[dwPChannel
].channel
= dwMChannel
;
595 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwPChannel
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
) {
596 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
597 FIXME("(%p, %d, %p, %p, %p): stub\n", This
, dwPChannel
, ppPort
, pdwGroup
, pdwMChannel
);
601 static HRESULT WINAPI
IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicInstrument
* pInst
, DWORD dwPChannel
, IDirectMusicDownloadedInstrument
** ppDownInst
, DMUS_NOTERANGE
* pNoteRanges
, DWORD dwNumNoteRanges
, IDirectMusicPort
** ppPort
, DWORD
* pdwGroup
, DWORD
* pdwMChannel
) {
602 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
603 FIXME("(%p, %p, %d, %p, %p, %d, %p, %p, %p): stub\n", This
, pInst
, dwPChannel
, ppDownInst
, pNoteRanges
, dwNumNoteRanges
, ppPort
, pdwGroup
, pdwMChannel
);
607 static HRESULT WINAPI
IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DWORD dwFlags
) {
608 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
609 FIXME("(%p, %ld, %d): stub\n", This
, mtTime
, dwFlags
);
613 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
) {
614 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
615 FIXME("(%p, %s, %d, %d, %ld, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
619 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, void* pParam
) {
620 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
621 FIXME("(%p, %s, %d, %d, %ld, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pParam
);
625 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
) {
626 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
628 TRACE("(%p, %s, %p, %d): stub\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
630 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
))
631 memcpy(pParam
, &This
->fAutoDownload
, sizeof(&This
->fAutoDownload
));
632 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
))
633 memcpy(pParam
, &This
->cMasterGrooveLevel
, sizeof(&This
->cMasterGrooveLevel
));
634 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
))
635 memcpy(pParam
, &This
->fMasterTempo
, sizeof(&This
->fMasterTempo
));
636 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
))
637 memcpy(pParam
, &This
->lMasterVolume
, sizeof(&This
->lMasterVolume
));
642 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, void* pParam
, DWORD dwSize
) {
643 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
645 TRACE("(%p, %s, %p, %d)\n", This
, debugstr_dmguid(rguidType
), pParam
, dwSize
);
647 if (IsEqualGUID (rguidType
, &GUID_PerfAutoDownload
)) {
648 memcpy(&This
->fAutoDownload
, pParam
, dwSize
);
649 TRACE("=> AutoDownload set to %d\n", This
->fAutoDownload
);
651 if (IsEqualGUID (rguidType
, &GUID_PerfMasterGrooveLevel
)) {
652 memcpy(&This
->cMasterGrooveLevel
, pParam
, dwSize
);
653 TRACE("=> MasterGrooveLevel set to %i\n", This
->cMasterGrooveLevel
);
655 if (IsEqualGUID (rguidType
, &GUID_PerfMasterTempo
)) {
656 memcpy(&This
->fMasterTempo
, pParam
, dwSize
);
657 TRACE("=> MasterTempo set to %f\n", This
->fMasterTempo
);
659 if (IsEqualGUID (rguidType
, &GUID_PerfMasterVolume
)) {
660 memcpy(&This
->lMasterVolume
, pParam
, dwSize
);
661 TRACE("=> MasterVolume set to %li\n", This
->lMasterVolume
);
667 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
) {
668 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
669 TRACE("(%p, %p): stub\n", This
, prtTime
);
670 *prtTime
= This
->rtLatencyTime
;
674 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME
* prtTime
) {
675 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
676 FIXME("(%p, %p): stub\n", This
, prtTime
);
680 static HRESULT WINAPI
IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtAmount
) {
681 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
682 FIXME("(%p, 0x%s): stub\n", This
, wine_dbgstr_longlong(rtAmount
));
686 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface
) {
687 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
688 FIXME("(%p): stub\n", This
);
689 if (PostMessageToProcessMsgThread(This
, PROCESSMSG_EXIT
)) {
690 WaitForSingleObject(This
->procThread
, INFINITE
);
691 This
->procThreadTicStarted
= FALSE
;
692 CloseHandle(This
->procThread
);
694 if (NULL
!= This
->pDirectSound
) {
695 IDirectSound_Release(This
->pDirectSound
);
696 This
->pDirectSound
= NULL
;
698 if (NULL
!= This
->pDirectMusic
) {
699 IDirectMusic8_Release(This
->pDirectMusic
);
700 This
->pDirectMusic
= NULL
;
705 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface
, REFERENCE_TIME rtTime
, REFERENCE_TIME
* prtResolved
, DWORD dwTimeResolveFlags
) {
706 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
707 FIXME("(%p, 0x%s, %p, %d): stub\n", This
, wine_dbgstr_longlong(rtTime
),
708 prtResolved
, dwTimeResolveFlags
);
712 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface
, BYTE bMIDIValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, WORD
* pwMusicValue
) {
713 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
714 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, bMIDIValue
, pChord
, bPlayMode
, bChordLevel
, pwMusicValue
);
718 static HRESULT WINAPI
IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMusicValue
, DMUS_CHORD_KEY
* pChord
, BYTE bPlayMode
, BYTE bChordLevel
, BYTE
* pbMIDIValue
) {
719 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
720 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This
, wMusicValue
, pChord
, bPlayMode
, bChordLevel
, pbMIDIValue
);
724 static HRESULT WINAPI
IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface
, MUSIC_TIME mtTime
, DMUS_TIMESIGNATURE
* pTimeSig
, WORD
* pwMeasure
, BYTE
* pbBeat
, BYTE
* pbGrid
, short* pnOffset
) {
725 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
726 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This
, mtTime
, pTimeSig
, pwMeasure
, pbBeat
, pbGrid
, pnOffset
);
730 static HRESULT WINAPI
IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface
, WORD wMeasure
, BYTE bBeat
, BYTE bGrid
, short nOffset
, DMUS_TIMESIGNATURE
* pTimeSig
, MUSIC_TIME
* pmtTime
) {
731 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
732 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This
, wMeasure
, bBeat
, bGrid
, nOffset
, pTimeSig
, pmtTime
);
736 /* IDirectMusicPerformance8 Interface part follow: */
737 static HRESULT WINAPI
IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 iface
,
738 IDirectMusic
** ppDirectMusic
,
739 IDirectSound
** ppDirectSound
,
741 DWORD dwDefaultPathType
,
742 DWORD dwPChannelCount
,
744 DMUS_AUDIOPARAMS
* pParams
) {
746 IDirectSound
* dsound
= NULL
;
749 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
750 FIXME("(%p, %p, %p, %p, %x, %u, %x, %p): to check\n", This
, ppDirectMusic
, ppDirectSound
, hWnd
, dwDefaultPathType
, dwPChannelCount
, dwFlags
, pParams
);
752 if (This
->pDirectMusic
|| This
->pDirectSound
)
753 return DMUS_E_ALREADY_INITED
;
755 if (NULL
!= ppDirectSound
&& NULL
!= *ppDirectSound
) {
756 dsound
= *ppDirectSound
;
758 hr
= DirectSoundCreate8 (NULL
, (LPDIRECTSOUND8
*) &dsound
, NULL
);
759 FIXME("return dsound(%p,%d)\n", dsound
, hr
);
760 if (FAILED(hr
) || !dsound
)
761 return DSERR_NODRIVER
;
763 *ppDirectSound
= dsound
;
766 IDirectMusicPerformance8Impl_Init(iface
, ppDirectMusic
, dsound
, hWnd
);
768 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
769 if (NULL
== ppDirectSound
) {
770 IDirectSound_Release(This
->pDirectSound
);
773 /* as seen in msdn we need params init before audio path creation */
774 if (NULL
!= pParams
) {
775 memcpy(&This
->pParams
, pParams
, sizeof(DMUS_AUDIOPARAMS
));
778 * TODO, how can i fill the struct
779 * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp
781 memset(&This
->pParams
, 0, sizeof(DMUS_AUDIOPARAMS
));
782 This
->pParams
.dwSize
= sizeof(DMUS_AUDIOPARAMS
);
783 This
->pParams
.fInitNow
= FALSE
;
784 This
->pParams
.dwValidData
= DMUS_AUDIOPARAMS_FEATURES
| DMUS_AUDIOPARAMS_VOICES
| DMUS_AUDIOPARAMS_SAMPLERATE
| DMUS_AUDIOPARAMS_DEFAULTSYNTH
;
785 This
->pParams
.dwVoices
= 64;
786 This
->pParams
.dwSampleRate
= (DWORD
) 22.050;
787 This
->pParams
.dwFeatures
= dwFlags
;
788 This
->pParams
.clsidDefaultSynth
= CLSID_DirectMusicSynthSink
;
790 hr
= IDirectMusicPerformance8_CreateStandardAudioPath(iface
, dwDefaultPathType
, dwPChannelCount
, FALSE
, &This
->pDefaultPath
);
792 PostMessageToProcessMsgThread(This
, PROCESSMSG_START
);
797 static HRESULT WINAPI
IDirectMusicPerformance8Impl_PlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSource
, WCHAR
* pwzSegmentName
, IUnknown
* pTransition
, DWORD dwFlags
, __int64 i64StartTime
, IDirectMusicSegmentState
** ppSegmentState
, IUnknown
* pFrom
, IUnknown
* pAudioPath
) {
798 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
799 FIXME("(%p, %p, %p, %p, %d, 0x%s, %p, %p, %p): stub\n", This
, pSource
, pwzSegmentName
,
800 pTransition
, dwFlags
, wine_dbgstr_longlong(i64StartTime
), ppSegmentState
, pFrom
, pAudioPath
);
804 static HRESULT WINAPI
IDirectMusicPerformance8Impl_StopEx (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pObjectToStop
, __int64 i64StopTime
, DWORD dwFlags
) {
805 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
806 FIXME("(%p, %p, 0x%s, %d): stub\n", This
, pObjectToStop
,
807 wine_dbgstr_longlong(i64StopTime
), dwFlags
);
811 static HRESULT WINAPI
IDirectMusicPerformance8Impl_ClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface
, DMUS_PMSG
* pSourcePMSG
, DMUS_PMSG
** ppCopyPMSG
) {
812 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
813 FIXME("(%p, %p, %p): stub\n", This
, pSourcePMSG
, ppCopyPMSG
);
817 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IUnknown
* pSourceConfig
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
) {
818 IDirectMusicAudioPathImpl
*default_path
;
819 IDirectMusicAudioPath
*pPath
;
821 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
822 FIXME("(%p, %p, %d, %p): stub\n", This
, pSourceConfig
, fActivate
, ppNewPath
);
824 if (NULL
== ppNewPath
) {
828 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath
, (LPVOID
*)&pPath
, NULL
);
829 default_path
= (IDirectMusicAudioPathImpl
*)((char*)(pPath
) - offsetof(IDirectMusicAudioPathImpl
,AudioPathVtbl
));
830 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
836 return IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
840 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp
842 static HRESULT WINAPI
IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, DWORD dwType
, DWORD dwPChannelCount
, BOOL fActivate
, IDirectMusicAudioPath
** ppNewPath
) {
843 IDirectMusicAudioPathImpl
*default_path
;
844 IDirectMusicAudioPath
*pPath
;
847 LPDIRECTSOUNDBUFFER buffer
;
850 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
852 FIXME("(%p)->(%d, %d, %d, %p): semi-stub\n", This
, dwType
, dwPChannelCount
, fActivate
, ppNewPath
);
854 if (NULL
== ppNewPath
) {
858 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath
, (LPVOID
*)&pPath
, NULL
);
859 default_path
= (IDirectMusicAudioPathImpl
*)((char*)(pPath
) - offsetof(IDirectMusicAudioPathImpl
,AudioPathVtbl
));
860 default_path
->pPerf
= (IDirectMusicPerformance8
*) This
;
862 /* Secondary buffer description */
863 memset(&format
, 0, sizeof(format
));
864 format
.wFormatTag
= WAVE_FORMAT_PCM
;
865 format
.nChannels
= 1;
866 format
.nSamplesPerSec
= 44000;
867 format
.nAvgBytesPerSec
= 44000*2;
868 format
.nBlockAlign
= 2;
869 format
.wBitsPerSample
= 16;
872 memset(&desc
, 0, sizeof(desc
));
873 desc
.dwSize
= sizeof(desc
);
874 desc
.dwFlags
= DSBCAPS_CTRLFX
| DSBCAPS_CTRLPAN
| DSBCAPS_CTRLVOLUME
| DSBCAPS_GLOBALFOCUS
;
875 desc
.dwBufferBytes
= DSBSIZE_MIN
;
877 desc
.lpwfxFormat
= &format
;
878 desc
.guid3DAlgorithm
= GUID_NULL
;
881 case DMUS_APATH_DYNAMIC_3D
:
882 desc
.dwFlags
|= DSBCAPS_CTRL3D
| DSBCAPS_CTRLFREQUENCY
| DSBCAPS_MUTE3DATMAXDISTANCE
;
884 case DMUS_APATH_DYNAMIC_MONO
:
885 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
887 case DMUS_APATH_SHARED_STEREOPLUSREVERB
:
888 /* normally we havet to create 2 buffers (one for music other for reverb)
889 * in this case. See msdn
891 case DMUS_APATH_DYNAMIC_STEREO
:
892 desc
.dwFlags
|= DSBCAPS_CTRLFREQUENCY
;
893 format
.nChannels
= 2;
894 format
.nBlockAlign
*= 2;
895 format
.nAvgBytesPerSec
*=2;
898 HeapFree(GetProcessHeap(), 0, default_path
);
903 /* FIXME: Should we create one secondary buffer for each PChannel? */
904 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
906 HeapFree(GetProcessHeap(), 0, default_path
);
908 return DSERR_BUFFERLOST
;
910 default_path
->pDSBuffer
= buffer
;
912 /* Update description for creating primary buffer */
913 desc
.dwFlags
|= DSBCAPS_PRIMARYBUFFER
;
914 desc
.dwBufferBytes
= 0;
915 desc
.lpwfxFormat
= NULL
;
917 hr
= IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8
) This
->pDirectSound
, &desc
, &buffer
, NULL
);
919 IDirectSoundBuffer_Release(default_path
->pDSBuffer
);
920 HeapFree(GetProcessHeap(), 0, default_path
);
922 return DSERR_BUFFERLOST
;
924 default_path
->pPrimary
= buffer
;
928 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath
);
930 return IDirectMusicAudioPath_Activate(*ppNewPath
, fActivate
);
933 static HRESULT WINAPI
IDirectMusicPerformance8Impl_SetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
* pAudioPath
) {
934 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
936 FIXME("(%p, %p): semi-stub\n", This
, pAudioPath
);
937 if (NULL
!= This
->pDefaultPath
) {
938 IDirectMusicAudioPath_Release(This
->pDefaultPath
);
939 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= NULL
;
940 This
->pDefaultPath
= NULL
;
942 This
->pDefaultPath
= pAudioPath
;
943 if (NULL
!= This
->pDefaultPath
) {
944 IDirectMusicAudioPath_AddRef(This
->pDefaultPath
);
945 ((IDirectMusicAudioPathImpl
*) This
->pDefaultPath
)->pPerf
= (IDirectMusicPerformance8
*) This
;
951 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface
, IDirectMusicAudioPath
** ppAudioPath
) {
952 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
954 FIXME("(%p, %p): semi-stub (%p)\n", This
, ppAudioPath
, This
->pDefaultPath
);
956 if (NULL
!= This
->pDefaultPath
) {
957 *ppAudioPath
= This
->pDefaultPath
;
958 IDirectMusicAudioPath_AddRef(*ppAudioPath
);
965 static HRESULT WINAPI
IDirectMusicPerformance8Impl_GetParamEx (LPDIRECTMUSICPERFORMANCE8 iface
, REFGUID rguidType
, DWORD dwTrackID
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
) {
966 IDirectMusicPerformance8Impl
*This
= (IDirectMusicPerformance8Impl
*)iface
;
968 FIXME("(%p, %s, %d, %d, %d, %ld, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwTrackID
, dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
973 static const IDirectMusicPerformance8Vtbl DirectMusicPerformance8_Vtbl
= {
974 IDirectMusicPerformance8Impl_QueryInterface
,
975 IDirectMusicPerformance8Impl_AddRef
,
976 IDirectMusicPerformance8Impl_Release
,
977 IDirectMusicPerformance8Impl_Init
,
978 IDirectMusicPerformance8Impl_PlaySegment
,
979 IDirectMusicPerformance8Impl_Stop
,
980 IDirectMusicPerformance8Impl_GetSegmentState
,
981 IDirectMusicPerformance8Impl_SetPrepareTime
,
982 IDirectMusicPerformance8Impl_GetPrepareTime
,
983 IDirectMusicPerformance8Impl_SetBumperLength
,
984 IDirectMusicPerformance8Impl_GetBumperLength
,
985 IDirectMusicPerformance8Impl_SendPMsg
,
986 IDirectMusicPerformance8Impl_MusicToReferenceTime
,
987 IDirectMusicPerformance8Impl_ReferenceToMusicTime
,
988 IDirectMusicPerformance8Impl_IsPlaying
,
989 IDirectMusicPerformance8Impl_GetTime
,
990 IDirectMusicPerformance8Impl_AllocPMsg
,
991 IDirectMusicPerformance8Impl_FreePMsg
,
992 IDirectMusicPerformance8Impl_GetGraph
,
993 IDirectMusicPerformance8Impl_SetGraph
,
994 IDirectMusicPerformance8Impl_SetNotificationHandle
,
995 IDirectMusicPerformance8Impl_GetNotificationPMsg
,
996 IDirectMusicPerformance8Impl_AddNotificationType
,
997 IDirectMusicPerformance8Impl_RemoveNotificationType
,
998 IDirectMusicPerformance8Impl_AddPort
,
999 IDirectMusicPerformance8Impl_RemovePort
,
1000 IDirectMusicPerformance8Impl_AssignPChannelBlock
,
1001 IDirectMusicPerformance8Impl_AssignPChannel
,
1002 IDirectMusicPerformance8Impl_PChannelInfo
,
1003 IDirectMusicPerformance8Impl_DownloadInstrument
,
1004 IDirectMusicPerformance8Impl_Invalidate
,
1005 IDirectMusicPerformance8Impl_GetParam
,
1006 IDirectMusicPerformance8Impl_SetParam
,
1007 IDirectMusicPerformance8Impl_GetGlobalParam
,
1008 IDirectMusicPerformance8Impl_SetGlobalParam
,
1009 IDirectMusicPerformance8Impl_GetLatencyTime
,
1010 IDirectMusicPerformance8Impl_GetQueueTime
,
1011 IDirectMusicPerformance8Impl_AdjustTime
,
1012 IDirectMusicPerformance8Impl_CloseDown
,
1013 IDirectMusicPerformance8Impl_GetResolvedTime
,
1014 IDirectMusicPerformance8Impl_MIDIToMusic
,
1015 IDirectMusicPerformance8Impl_MusicToMIDI
,
1016 IDirectMusicPerformance8Impl_TimeToRhythm
,
1017 IDirectMusicPerformance8Impl_RhythmToTime
,
1018 IDirectMusicPerformance8Impl_InitAudio
,
1019 IDirectMusicPerformance8Impl_PlaySegmentEx
,
1020 IDirectMusicPerformance8Impl_StopEx
,
1021 IDirectMusicPerformance8Impl_ClonePMsg
,
1022 IDirectMusicPerformance8Impl_CreateAudioPath
,
1023 IDirectMusicPerformance8Impl_CreateStandardAudioPath
,
1024 IDirectMusicPerformance8Impl_SetDefaultAudioPath
,
1025 IDirectMusicPerformance8Impl_GetDefaultAudioPath
,
1026 IDirectMusicPerformance8Impl_GetParamEx
1029 /* for ClassFactory */
1030 HRESULT WINAPI
DMUSIC_CreateDirectMusicPerformanceImpl (LPCGUID lpcGUID
, LPVOID
*ppobj
, LPUNKNOWN pUnkOuter
) {
1031 IDirectMusicPerformance8Impl
*obj
;
1033 TRACE("(%p,%p,%p)\n", lpcGUID
, ppobj
, pUnkOuter
);
1035 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicPerformance8Impl
));
1037 *ppobj
= (LPDIRECTMUSICPERFORMANCE8
)NULL
;
1038 return E_OUTOFMEMORY
;
1040 obj
->lpVtbl
= &DirectMusicPerformance8_Vtbl
;
1041 obj
->ref
= 0; /* will be inited by QueryInterface */
1042 obj
->pDirectMusic
= NULL
;
1043 obj
->pDirectSound
= NULL
;
1044 obj
->pDefaultPath
= NULL
;
1045 InitializeCriticalSection(&obj
->safe
);
1046 obj
->safe
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IDirectMusicPerformance8Impl*->safe");
1049 * @see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/latencyandbumpertime.asp
1051 obj
->rtLatencyTime
= 100; /* 100ms TO FIX */
1052 obj
->dwBumperLength
= 50; /* 50ms default */
1053 obj
->dwPrepareTime
= 1000; /* 1000ms default */
1054 return IDirectMusicPerformance8Impl_QueryInterface ((LPDIRECTMUSICPERFORMANCE8
)obj
, lpcGUID
, ppobj
);