1 /* IDirectMusicPerformance Implementation
3 * Copyright (C) 2003-2004 Rok Mandeljc
4 * Copyright (C) 2003-2004 Raphael Junqueira
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Library General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "dmime_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
25 typedef struct DMUS_PMSGItem DMUS_PMSGItem;
26 struct DMUS_PMSGItem {
30 REFERENCE_TIME rtItemTime;
36 #define DMUS_PMSGToItem(pMSG) ((DMUS_PMSGItem*) (((unsigned char*) pPMSG) - offsetof(DMUS_PMSGItem, pMsg)))
37 #define DMUS_ItemToPMSG(pItem) (&(pItem->pMsg))
38 #define DMUS_ItemRemoveFromQueue(This,pItem) \
40 if (pItem->prev) pItem->prev->next = pItem->next;\
41 if (pItem->next) pItem->next->prev = pItem->prev;\
42 if (This->head == pItem) This->head = pItem->next;\
43 if (This->imm_head == pItem) This->imm_head = pItem->next;\
44 pItem->bInUse = FALSE;\
47 #define PROCESSMSG_START (WM_APP + 0)
48 #define PROCESSMSG_EXIT (WM_APP + 1)
49 #define PROCESSMSG_REMOVE (WM_APP + 2)
50 #define PROCESSMSG_ADD (WM_APP + 4)
53 static DMUS_PMSGItem* ProceedMsg(IDirectMusicPerformance8Impl* This, DMUS_PMSGItem* cur) {
54 if (cur->pMsg.dwType == DMUS_PMSGT_NOTIFICATION) {
55 SetEvent(This->hNotification);
57 DMUS_ItemRemoveFromQueue(This, cur);
58 switch (cur->pMsg.dwType) {
60 case DMUS_PMSGT_TEMPO:
63 FIXME("Unhandled PMsg Type: 0x%lx\n", cur->pMsg.dwType);
69 static DWORD WINAPI ProcessMsgThread(LPVOID lpParam) {
70 IDirectMusicPerformance8Impl* This = (IDirectMusicPerformance8Impl*) lpParam;
71 DWORD timeOut = INFINITE;
74 REFERENCE_TIME rtLastTime;
75 REFERENCE_TIME rtCurTime;
76 DMUS_PMSGItem* it = NULL;
77 DMUS_PMSGItem* cur = NULL;
78 DMUS_PMSGItem* it_next = NULL;
81 DWORD dwDec = This->rtLatencyTime + This->dwBumperLength;
83 if (timeOut > 0) MsgWaitForMultipleObjects(0, NULL, FALSE, timeOut, QS_POSTMESSAGE|QS_SENDMESSAGE|QS_TIMER);
86 EnterCriticalSection(&This->safe);
87 rtLastTime = rtCurTime;
88 hr = IDirectMusicPerformance8Impl_GetTime((IDirectMusicPerformance8*) This, &rtCurTime, NULL);
93 for (it = This->imm_head; NULL != it; ) {
95 cur = ProceedMsg(This, it);
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 HRESULT WINAPI IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface, REFIID riid, LPVOID *ppobj) {
168 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
169 TRACE("(%p, %s,%p)\n", This, debugstr_dmguid(riid), ppobj);
171 if (IsEqualIID (riid, &IID_IUnknown) ||
172 IsEqualIID (riid, &IID_IDirectMusicPerformance) ||
173 IsEqualIID (riid, &IID_IDirectMusicPerformance8)) {
174 IDirectMusicPerformance8Impl_AddRef(iface);
179 WARN("(%p, %s,%p): not found\n", This, debugstr_dmguid(riid), ppobj);
180 return E_NOINTERFACE;
183 ULONG WINAPI IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface) {
184 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
185 ULONG ref = InterlockedIncrement(&This->ref);
187 TRACE("(%p): AddRef from %ld\n", This, ref - 1);
194 ULONG WINAPI IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface) {
195 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
196 ULONG ref = InterlockedDecrement(&This->ref);
197 TRACE("(%p): ReleaseRef to %ld\n", This, ref);
200 DeleteCriticalSection(&This->safe);
201 HeapFree(GetProcessHeap(), 0, This);
204 DMIME_UnlockModule();
209 /* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
210 HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd) {
211 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
213 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This, ppDirectMusic, pDirectSound, hWnd);
214 if (This->pDirectMusic || This->pDirectSound)
215 return DMUS_E_ALREADY_INITED;
218 hWnd = GetForegroundWindow();
221 if (NULL != pDirectSound) {
222 This->pDirectSound = (IDirectSound*) pDirectSound;
223 IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound);
225 DirectSoundCreate8(NULL, (LPDIRECTSOUND8*) &This->pDirectSound, NULL);
229 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp
232 IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);
234 /* how to get the ForeGround window handle ? */
235 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
237 if (!This->pDirectSound)
238 return DSERR_NODRIVER;
241 if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
242 /* app creates it's own dmusic object and gives it to performance */
243 This->pDirectMusic = (IDirectMusic8*) *ppDirectMusic;
244 IDirectMusic8_AddRef((LPDIRECTMUSIC8) This->pDirectMusic);
246 /* app allows the performance to initialise itfself and needs a pointer to object*/
247 CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic);
249 *ppDirectMusic = (LPDIRECTMUSIC) This->pDirectMusic;
250 IDirectMusic8_AddRef((LPDIRECTMUSIC8) *ppDirectMusic);
257 HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState) {
258 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
259 FIXME("(%p, %p, %ld, %lli, %p): stub\n", This, pSegment, dwFlags, i64StartTime, ppSegmentState);
263 HRESULT WINAPI IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegmentState, MUSIC_TIME mtTime, DWORD dwFlags) {
264 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
265 FIXME("(%p, %p, %p, %ld, %ld): stub\n", This, pSegment, pSegmentState, mtTime, dwFlags);
269 HRESULT WINAPI IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegmentState** ppSegmentState, MUSIC_TIME mtTime) {
270 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
271 FIXME("(%p,%p, %ld): stub\n", This, ppSegmentState, mtTime);
275 HRESULT WINAPI IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds) {
276 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
277 TRACE("(%p, %ld)\n", This, dwMilliSeconds);
278 This->dwPrepareTime = dwMilliSeconds;
282 HRESULT WINAPI IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds) {
283 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
284 TRACE("(%p, %p)\n", This, pdwMilliSeconds);
285 if (NULL == pdwMilliSeconds) {
288 *pdwMilliSeconds = This->dwPrepareTime;
292 HRESULT WINAPI IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds) {
293 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
294 TRACE("(%p, %ld)\n", This, dwMilliSeconds);
295 This->dwBumperLength = dwMilliSeconds;
299 HRESULT WINAPI IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds) {
300 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
301 TRACE("(%p, %p)\n", This, pdwMilliSeconds);
302 if (NULL == pdwMilliSeconds) {
305 *pdwMilliSeconds = This->dwBumperLength;
309 HRESULT WINAPI IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG) {
310 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
311 DMUS_PMSGItem* pItem = NULL;
312 DMUS_PMSGItem* it = NULL;
313 DMUS_PMSGItem* prev_it = NULL;
314 DMUS_PMSGItem** queue = NULL;
316 FIXME("(%p, %p): stub\n", This, pPMSG);
321 pItem = DMUS_PMSGToItem(pPMSG);
326 return DMUS_E_ALREADY_SENT;
329 /* TODO: Valid Flags */
330 /* TODO: DMUS_PMSGF_MUSICTIME */
331 pItem->rtItemTime = pPMSG->rtTime;
333 if (pPMSG->dwFlags & DMUS_PMSGF_TOOL_IMMEDIATE) {
334 queue = &This->imm_head;
339 EnterCriticalSection(&This->safe);
340 for (it = *queue; NULL != it && it->rtItemTime < pItem->rtItemTime; it = it->next) {
343 if (NULL == prev_it) {
345 if (NULL != *queue) pItem->next = (*queue)->next;
346 /*assert( NULL == pItem->next->prev );*/
347 if (NULL != pItem->next) pItem->next->prev = pItem;
350 pItem->prev = prev_it;
351 pItem->next = prev_it->next;
352 prev_it->next = pItem;
353 if (NULL != pItem->next) pItem->next->prev = pItem;
355 LeaveCriticalSection(&This->safe);
357 /** now in use, prevent from stupid Frees */
358 pItem->bInUse = TRUE;
362 HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, REFERENCE_TIME* prtTime) {
363 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
364 FIXME("(%p, %ld, %p): stub\n", This, mtTime, prtTime);
368 HRESULT WINAPI IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, MUSIC_TIME* pmtTime) {
369 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
370 FIXME("(%p, %lli, %p): stub\n", This, rtTime, pmtTime);
374 HRESULT WINAPI IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegState) {
375 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
376 FIXME("(%p, %p, %p): stub\n", This, pSegment, pSegState);
380 HRESULT WINAPI IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtNow, MUSIC_TIME* pmtNow) {
381 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
383 REFERENCE_TIME rtCur = 0;
385 /*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */
386 if (This->procThreadTicStarted) {
387 rtCur = ((REFERENCE_TIME) GetTickCount() * 10000) - This->procThreadStartTime;
389 /*return DMUS_E_NO_MASTER_CLOCK;*/
391 if (NULL != prtNow) {
394 if (NULL != pmtNow) {
395 hr = IDirectMusicPerformance8_ReferenceToMusicTime(iface, rtCur, pmtNow);
400 HRESULT WINAPI IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface, ULONG cb, DMUS_PMSG** ppPMSG) {
401 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
402 DMUS_PMSGItem* pItem = NULL;
404 FIXME("(%p, %ld, %p): stub\n", This, cb, ppPMSG);
406 if (sizeof(DMUS_PMSG) > cb) {
409 if (NULL == ppPMSG) {
412 pItem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb - sizeof(DMUS_PMSG) + sizeof(DMUS_PMSGItem));
414 return E_OUTOFMEMORY;
416 pItem->pMsg.dwSize = cb;
417 *ppPMSG = DMUS_ItemToPMSG(pItem);
421 HRESULT WINAPI IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG) {
422 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
423 DMUS_PMSGItem* pItem = NULL;
425 FIXME("(%p, %p): stub\n", This, pPMSG);
430 pItem = DMUS_PMSGToItem(pPMSG);
435 /** prevent for freeing PMsg in queue (ie to be processed) */
436 return DMUS_E_CANNOT_FREE;
438 /** now we can remove it safely */
439 EnterCriticalSection(&This->safe);
440 DMUS_ItemRemoveFromQueue( This, pItem );
441 LeaveCriticalSection(&This->safe);
443 /** TODO: see if we should Release the pItem->pMsg->punkUser and others Interfaces */
444 HeapFree(GetProcessHeap(), 0, pItem);
448 HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph** ppGraph) {
449 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
450 FIXME("(%p, %p): to check\n", This, ppGraph);
451 if (NULL != This->pToolGraph) {
452 *ppGraph = (LPDIRECTMUSICGRAPH) This->pToolGraph;
453 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) *ppGraph);
460 HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph* pGraph) {
461 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
463 FIXME("(%p, %p): to check\n", This, pGraph);
465 if (NULL != This->pToolGraph) {
466 /* Todo clean buffers and tools before */
467 IDirectMusicGraph_Release((LPDIRECTMUSICGRAPH) This->pToolGraph);
469 This->pToolGraph = pGraph;
470 if (NULL != This->pToolGraph) {
471 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) This->pToolGraph);
476 HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface, HANDLE hNotification, REFERENCE_TIME rtMinimum) {
477 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
478 FIXME("(%p, %p, %lli): stub\n", This, hNotification, rtMinimum);
479 This->hNotification = hNotification;
480 if (rtMinimum) This->rtMinimum = rtMinimum;
484 HRESULT WINAPI IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_NOTIFICATION_PMSG** ppNotificationPMsg) {
485 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
488 FIXME("(%p, %p): stub\n", This, ppNotificationPMsg);
489 if (NULL == ppNotificationPMsg) {
499 HRESULT WINAPI IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType) {
500 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
501 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
505 HRESULT WINAPI IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType) {
506 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
507 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
511 HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort) {
512 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
513 FIXME("(%p, %p): stub\n", This, pPort);
514 IDirectMusicPort_AddRef (pPort);
518 HRESULT WINAPI IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort) {
519 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
520 FIXME("(%p, %p): stub\n", This, pPort);
521 IDirectMusicPort_Release (pPort);
525 HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwBlockNum, IDirectMusicPort* pPort, DWORD dwGroup) {
526 int i, j, range /* min value in range */;
527 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
529 FIXME("(%p, %ld, %p, %ld): semi-stub\n", This, dwBlockNum, pPort, dwGroup-1);
530 range = 16 * dwBlockNum;
533 for (i = range; i < range+16; i++) {
534 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
535 This->PChannel[i].port = pPort;
536 This->PChannel[i].group = dwGroup - 1; /* first index is always zero */
537 This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
544 HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel) {
545 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
547 TRACE("(%p, %ld, %p, %ld, %ld)\n", This, dwPChannel, pPort, dwGroup, dwMChannel);
548 This->PChannel[dwPChannel].port = pPort;
549 This->PChannel[dwPChannel].group = dwGroup;
550 This->PChannel[dwPChannel].channel = dwMChannel;
555 HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) {
556 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
557 FIXME("(%p, %ld, %p, %p, %p): stub\n", This, dwPChannel, ppPort, pdwGroup, pdwMChannel);
561 HRESULT WINAPI IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicInstrument* pInst, DWORD dwPChannel, IDirectMusicDownloadedInstrument** ppDownInst, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) {
562 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
563 FIXME("(%p, %p, %ld, %p, %p, %ld, %p, %p, %p): stub\n", This, pInst, dwPChannel, ppDownInst, pNoteRanges, dwNumNoteRanges, ppPort, pdwGroup, pdwMChannel);
567 HRESULT WINAPI IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DWORD dwFlags) {
568 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
569 FIXME("(%p, %ld, %ld): stub\n", This, mtTime, dwFlags);
573 HRESULT WINAPI IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
574 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
575 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
579 HRESULT WINAPI IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam) {
580 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
581 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pParam);
585 HRESULT WINAPI IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize) {
586 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
588 TRACE("(%p, %s, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
590 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload))
591 memcpy(pParam, &This->fAutoDownload, sizeof(&This->fAutoDownload));
592 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel))
593 memcpy(pParam, &This->cMasterGrooveLevel, sizeof(&This->cMasterGrooveLevel));
594 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo))
595 memcpy(pParam, &This->fMasterTempo, sizeof(&This->fMasterTempo));
596 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume))
597 memcpy(pParam, &This->lMasterVolume, sizeof(&This->lMasterVolume));
602 HRESULT WINAPI IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize) {
603 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
605 TRACE("(%p, %s, %p, %ld)\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
607 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload)) {
608 memcpy(&This->fAutoDownload, pParam, dwSize);
609 TRACE("=> AutoDownload set to %d\n", This->fAutoDownload);
611 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel)) {
612 memcpy(&This->cMasterGrooveLevel, pParam, dwSize);
613 TRACE("=> MasterGrooveLevel set to %i\n", This->cMasterGrooveLevel);
615 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo)) {
616 memcpy(&This->fMasterTempo, pParam, dwSize);
617 TRACE("=> MasterTempo set to %f\n", This->fMasterTempo);
619 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume)) {
620 memcpy(&This->lMasterVolume, pParam, dwSize);
621 TRACE("=> MasterVolume set to %li\n", This->lMasterVolume);
627 HRESULT WINAPI IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime) {
628 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
629 TRACE("(%p, %p): stub\n", This, prtTime);
630 *prtTime = This->rtLatencyTime;
634 HRESULT WINAPI IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime) {
635 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
636 FIXME("(%p, %p): stub\n", This, prtTime);
640 HRESULT WINAPI IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtAmount) {
641 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
642 FIXME("(%p, %lli): stub\n", This, rtAmount);
646 HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface) {
647 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
648 FIXME("(%p): stub\n", This);
649 if (PostMessageToProcessMsgThread(This, PROCESSMSG_EXIT)) {
650 WaitForSingleObject(This->procThread, INFINITE);
651 This->procThreadTicStarted = FALSE;
652 CloseHandle(This->procThread);
654 if (NULL != This->pDirectSound) {
655 IDirectSound_Release((LPDIRECTSOUND) This->pDirectSound);
656 This->pDirectSound = NULL;
658 if (NULL != This->pDirectMusic) {
659 IDirectMusic8_Release((LPDIRECTMUSIC8) This->pDirectMusic);
660 This->pDirectMusic = NULL;
665 HRESULT WINAPI IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, REFERENCE_TIME* prtResolved, DWORD dwTimeResolveFlags) {
666 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
667 FIXME("(%p, %lli, %p, %ld): stub\n", This, rtTime, prtResolved, dwTimeResolveFlags);
671 HRESULT WINAPI IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface, BYTE bMIDIValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, WORD* pwMusicValue) {
672 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
673 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, bMIDIValue, pChord, bPlayMode, bChordLevel, pwMusicValue);
677 HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMusicValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, BYTE* pbMIDIValue) {
678 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
679 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, wMusicValue, pChord, bPlayMode, bChordLevel, pbMIDIValue);
683 HRESULT WINAPI IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DMUS_TIMESIGNATURE* pTimeSig, WORD* pwMeasure, BYTE* pbBeat, BYTE* pbGrid, short* pnOffset) {
684 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
685 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This, mtTime, pTimeSig, pwMeasure, pbBeat, pbGrid, pnOffset);
689 HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMeasure, BYTE bBeat, BYTE bGrid, short nOffset, DMUS_TIMESIGNATURE* pTimeSig, MUSIC_TIME* pmtTime) {
690 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
691 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This, wMeasure, bBeat, bGrid, nOffset, pTimeSig, pmtTime);
695 /* IDirectMusicPerformance8 Interface part follow: */
696 HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 iface,
697 IDirectMusic** ppDirectMusic,
698 IDirectSound** ppDirectSound,
700 DWORD dwDefaultPathType,
701 DWORD dwPChannelCount,
703 DMUS_AUDIOPARAMS* pParams) {
705 IDirectSound* dsound = NULL;
708 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
709 FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
711 if (This->pDirectMusic || This->pDirectSound)
712 return DMUS_E_ALREADY_INITED;
714 if (NULL != ppDirectSound && NULL != *ppDirectSound) {
715 dsound = *ppDirectSound;
717 hr = DirectSoundCreate8 (NULL, (LPDIRECTSOUND8*) &dsound, NULL);
718 FIXME("return dsound(%p,%ld)\n", dsound, hr);
719 if (FAILED(hr) || !dsound)
720 return DSERR_NODRIVER;
722 *ppDirectSound = dsound;
725 IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, dsound, hWnd);
727 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
728 if (NULL == ppDirectSound) {
729 IDirectSound_Release(This->pDirectSound);
732 /* as seen in msdn we need params init before audio path creation */
733 if (NULL != pParams) {
734 memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS));
737 * TODO, how can i fill the struct
738 * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp
740 memset(&This->pParams, 0, sizeof(DMUS_AUDIOPARAMS));
741 This->pParams.dwSize = sizeof(DMUS_AUDIOPARAMS);
742 This->pParams.fInitNow = FALSE;
743 This->pParams.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES | DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH;
744 This->pParams.dwVoices = 64;
745 This->pParams.dwSampleRate = (DWORD) 22.050;
746 This->pParams.dwFeatures = dwFlags;
747 This->pParams.clsidDefaultSynth = CLSID_DirectMusicSynthSink;
749 hr = IDirectMusicPerformance8Impl_CreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath);
751 PostMessageToProcessMsgThread(This, PROCESSMSG_START);
756 HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath) {
757 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
758 FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This, pSource, pwzSegmentName, pTransition, dwFlags, i64StartTime, ppSegmentState, pFrom, pAudioPath);
762 HRESULT WINAPI IDirectMusicPerformance8Impl_StopEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pObjectToStop, __int64 i64StopTime, DWORD dwFlags) {
763 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
764 FIXME("(%p, %p, %lli, %ld): stub\n", This, pObjectToStop, i64StopTime, dwFlags);
768 HRESULT WINAPI IDirectMusicPerformance8Impl_ClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pSourcePMSG, DMUS_PMSG** ppCopyPMSG) {
769 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
770 FIXME("(%p, %p, %p): stub\n", This, pSourcePMSG, ppCopyPMSG);
774 HRESULT WINAPI IDirectMusicPerformance8Impl_CreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSourceConfig, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) {
775 IDirectMusicAudioPathImpl *default_path;
776 IDirectMusicAudioPath *pPath;
778 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
779 FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ppNewPath);
781 if (NULL == ppNewPath) {
785 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath, (LPVOID*)&pPath, NULL);
786 default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl));
787 default_path->pPerf = (IDirectMusicPerformance8*) This;
791 *ppNewPath = (LPDIRECTMUSICAUDIOPATH) pPath;
793 return IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate(*ppNewPath, fActivate);
797 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp
799 HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) {
800 IDirectMusicAudioPathImpl *default_path;
801 IDirectMusicAudioPath *pPath;
804 LPDIRECTSOUNDBUFFER buffer;
807 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
809 FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
811 if (NULL == ppNewPath) {
815 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath, (LPVOID*)&pPath, NULL);
816 default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl));
817 default_path->pPerf = (IDirectMusicPerformance8*) This;
819 /* Secondary buffer description */
820 memset(&format, 0, sizeof(format));
821 format.wFormatTag = WAVE_FORMAT_PCM;
822 format.nChannels = 1;
823 format.nSamplesPerSec = 44000;
824 format.nAvgBytesPerSec = 44000*2;
825 format.nBlockAlign = 2;
826 format.wBitsPerSample = 16;
829 memset(&desc, 0, sizeof(desc));
830 desc.dwSize = sizeof(desc);
831 desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS;
832 desc.dwBufferBytes = DSBSIZE_MIN;
834 desc.lpwfxFormat = &format;
835 desc.guid3DAlgorithm = GUID_NULL;
838 case DMUS_APATH_DYNAMIC_3D:
839 desc.dwFlags |= DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE;
841 case DMUS_APATH_DYNAMIC_MONO:
842 desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
844 case DMUS_APATH_SHARED_STEREOPLUSREVERB:
845 /* normally we havet to create 2 buffers (one for music other for reverb)
846 * in this case. See msdn
848 case DMUS_APATH_DYNAMIC_STEREO:
849 desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
850 format.nChannels = 2;
851 format.nBlockAlign *= 2;
852 format.nAvgBytesPerSec *=2;
855 HeapFree(GetProcessHeap(), 0, default_path);
860 /* FIXME: Should we create one secondary buffer for each PChannel? */
861 hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
863 HeapFree(GetProcessHeap(), 0, default_path);
865 return DSERR_BUFFERLOST;
867 default_path->pDSBuffer = buffer;
869 /* Update description for creating primary buffer */
870 desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
871 desc.dwBufferBytes = 0;
872 desc.lpwfxFormat = NULL;
874 hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
876 IDirectSoundBuffer_Release(default_path->pDSBuffer);
877 HeapFree(GetProcessHeap(), 0, default_path);
879 return DSERR_BUFFERLOST;
881 default_path->pPrimary = buffer;
883 *ppNewPath = (LPDIRECTMUSICAUDIOPATH) pPath;
885 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath);
887 return IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate(*ppNewPath, fActivate);
890 HRESULT WINAPI IDirectMusicPerformance8Impl_SetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath) {
891 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
893 FIXME("(%p, %p): semi-stub\n", This, pAudioPath);
894 if (NULL != This->pDefaultPath) {
895 IDirectMusicAudioPath_Release((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
896 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = NULL;
897 This->pDefaultPath = NULL;
899 This->pDefaultPath = pAudioPath;
900 if (NULL != This->pDefaultPath) {
901 IDirectMusicAudioPath_AddRef((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
902 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = (IDirectMusicPerformance8*) This;
908 HRESULT WINAPI IDirectMusicPerformance8Impl_GetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath** ppAudioPath) {
909 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
911 FIXME("(%p, %p): semi-stub (%p)\n", This, ppAudioPath, This->pDefaultPath);
913 if (NULL != This->pDefaultPath) {
914 *ppAudioPath = (LPDIRECTMUSICAUDIOPATH) This->pDefaultPath;
915 IDirectMusicAudioPath_AddRef(*ppAudioPath);
922 HRESULT WINAPI IDirectMusicPerformance8Impl_GetParamEx (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
923 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
925 FIXME("(%p, %s, %ld, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwTrackID, dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
930 static const IDirectMusicPerformance8Vtbl DirectMusicPerformance8_Vtbl = {
931 IDirectMusicPerformance8Impl_QueryInterface,
932 IDirectMusicPerformance8Impl_AddRef,
933 IDirectMusicPerformance8Impl_Release,
934 IDirectMusicPerformance8Impl_Init,
935 IDirectMusicPerformance8Impl_PlaySegment,
936 IDirectMusicPerformance8Impl_Stop,
937 IDirectMusicPerformance8Impl_GetSegmentState,
938 IDirectMusicPerformance8Impl_SetPrepareTime,
939 IDirectMusicPerformance8Impl_GetPrepareTime,
940 IDirectMusicPerformance8Impl_SetBumperLength,
941 IDirectMusicPerformance8Impl_GetBumperLength,
942 IDirectMusicPerformance8Impl_SendPMsg,
943 IDirectMusicPerformance8Impl_MusicToReferenceTime,
944 IDirectMusicPerformance8Impl_ReferenceToMusicTime,
945 IDirectMusicPerformance8Impl_IsPlaying,
946 IDirectMusicPerformance8Impl_GetTime,
947 IDirectMusicPerformance8Impl_AllocPMsg,
948 IDirectMusicPerformance8Impl_FreePMsg,
949 IDirectMusicPerformance8Impl_GetGraph,
950 IDirectMusicPerformance8Impl_SetGraph,
951 IDirectMusicPerformance8Impl_SetNotificationHandle,
952 IDirectMusicPerformance8Impl_GetNotificationPMsg,
953 IDirectMusicPerformance8Impl_AddNotificationType,
954 IDirectMusicPerformance8Impl_RemoveNotificationType,
955 IDirectMusicPerformance8Impl_AddPort,
956 IDirectMusicPerformance8Impl_RemovePort,
957 IDirectMusicPerformance8Impl_AssignPChannelBlock,
958 IDirectMusicPerformance8Impl_AssignPChannel,
959 IDirectMusicPerformance8Impl_PChannelInfo,
960 IDirectMusicPerformance8Impl_DownloadInstrument,
961 IDirectMusicPerformance8Impl_Invalidate,
962 IDirectMusicPerformance8Impl_GetParam,
963 IDirectMusicPerformance8Impl_SetParam,
964 IDirectMusicPerformance8Impl_GetGlobalParam,
965 IDirectMusicPerformance8Impl_SetGlobalParam,
966 IDirectMusicPerformance8Impl_GetLatencyTime,
967 IDirectMusicPerformance8Impl_GetQueueTime,
968 IDirectMusicPerformance8Impl_AdjustTime,
969 IDirectMusicPerformance8Impl_CloseDown,
970 IDirectMusicPerformance8Impl_GetResolvedTime,
971 IDirectMusicPerformance8Impl_MIDIToMusic,
972 IDirectMusicPerformance8Impl_MusicToMIDI,
973 IDirectMusicPerformance8Impl_TimeToRhythm,
974 IDirectMusicPerformance8Impl_RhythmToTime,
975 IDirectMusicPerformance8Impl_InitAudio,
976 IDirectMusicPerformance8Impl_PlaySegmentEx,
977 IDirectMusicPerformance8Impl_StopEx,
978 IDirectMusicPerformance8Impl_ClonePMsg,
979 IDirectMusicPerformance8Impl_CreateAudioPath,
980 IDirectMusicPerformance8Impl_CreateStandardAudioPath,
981 IDirectMusicPerformance8Impl_SetDefaultAudioPath,
982 IDirectMusicPerformance8Impl_GetDefaultAudioPath,
983 IDirectMusicPerformance8Impl_GetParamEx
986 /* for ClassFactory */
987 HRESULT WINAPI DMUSIC_CreateDirectMusicPerformanceImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
988 IDirectMusicPerformance8Impl *obj;
990 TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
992 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPerformance8Impl));
994 *ppobj = (LPDIRECTMUSICPERFORMANCE8)NULL;
995 return E_OUTOFMEMORY;
997 obj->lpVtbl = &DirectMusicPerformance8_Vtbl;
998 obj->ref = 0; /* will be inited by QueryInterface */
999 obj->pDirectMusic = NULL;
1000 obj->pDirectSound = NULL;
1001 obj->pDefaultPath = NULL;
1002 InitializeCriticalSection(&obj->safe);
1005 * @see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/latencyandbumpertime.asp
1007 obj->rtLatencyTime = 100; /* 100ms TO FIX */
1008 obj->dwBumperLength = 50; /* 50ms default */
1009 obj->dwPrepareTime = 1000; /* 1000ms default */
1010 return IDirectMusicPerformance8Impl_QueryInterface ((LPDIRECTMUSICPERFORMANCE8)obj, lpcGUID, ppobj);