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);
192 ULONG WINAPI IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface) {
193 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
194 ULONG ref = InterlockedDecrement(&This->ref);
195 TRACE("(%p): ReleaseRef to %ld\n", This, ref);
197 DeleteCriticalSection(&This->safe);
198 HeapFree(GetProcessHeap(), 0, This);
203 /* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
204 HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd) {
205 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
207 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This, ppDirectMusic, pDirectSound, hWnd);
208 if (This->pDirectMusic || This->pDirectSound)
209 return DMUS_E_ALREADY_INITED;
212 hWnd = GetForegroundWindow();
215 if (NULL != pDirectSound) {
216 This->pDirectSound = (IDirectSound*) pDirectSound;
217 IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound);
219 DirectSoundCreate8(NULL, (LPDIRECTSOUND8*) &This->pDirectSound, NULL);
223 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp
226 IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);
228 /* how to get the ForeGround window handle ? */
229 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
231 if (!This->pDirectSound)
232 return DSERR_NODRIVER;
235 if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
236 /* app creates it's own dmusic object and gives it to performance */
237 This->pDirectMusic = (IDirectMusic8*) *ppDirectMusic;
238 IDirectMusic8_AddRef((LPDIRECTMUSIC8) This->pDirectMusic);
240 /* app allows the performance to initialise itfself and needs a pointer to object*/
241 CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic);
243 *ppDirectMusic = (LPDIRECTMUSIC) This->pDirectMusic;
244 IDirectMusic8_AddRef((LPDIRECTMUSIC8) *ppDirectMusic);
251 HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState) {
252 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
253 FIXME("(%p, %p, %ld, %lli, %p): stub\n", This, pSegment, dwFlags, i64StartTime, ppSegmentState);
257 HRESULT WINAPI IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegmentState, MUSIC_TIME mtTime, DWORD dwFlags) {
258 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
259 FIXME("(%p, %p, %p, %ld, %ld): stub\n", This, pSegment, pSegmentState, mtTime, dwFlags);
263 HRESULT WINAPI IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegmentState** ppSegmentState, MUSIC_TIME mtTime) {
264 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
265 FIXME("(%p,%p, %ld): stub\n", This, ppSegmentState, mtTime);
269 HRESULT WINAPI IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds) {
270 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
271 TRACE("(%p, %ld)\n", This, dwMilliSeconds);
272 This->dwPrepareTime = dwMilliSeconds;
276 HRESULT WINAPI IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds) {
277 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
278 TRACE("(%p, %p)\n", This, pdwMilliSeconds);
279 if (NULL == pdwMilliSeconds) {
282 *pdwMilliSeconds = This->dwPrepareTime;
286 HRESULT WINAPI IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds) {
287 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
288 TRACE("(%p, %ld)\n", This, dwMilliSeconds);
289 This->dwBumperLength = dwMilliSeconds;
293 HRESULT WINAPI IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds) {
294 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
295 TRACE("(%p, %p)\n", This, pdwMilliSeconds);
296 if (NULL == pdwMilliSeconds) {
299 *pdwMilliSeconds = This->dwBumperLength;
303 HRESULT WINAPI IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG) {
304 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
305 DMUS_PMSGItem* pItem = NULL;
306 DMUS_PMSGItem* it = NULL;
307 DMUS_PMSGItem* prev_it = NULL;
308 DMUS_PMSGItem** queue = NULL;
310 FIXME("(%p, %p): stub\n", This, pPMSG);
315 pItem = DMUS_PMSGToItem(pPMSG);
320 return DMUS_E_ALREADY_SENT;
323 /* TODO: Valid Flags */
324 /* TODO: DMUS_PMSGF_MUSICTIME */
325 pItem->rtItemTime = pPMSG->rtTime;
327 if (pPMSG->dwFlags & DMUS_PMSGF_TOOL_IMMEDIATE) {
328 queue = &This->imm_head;
333 EnterCriticalSection(&This->safe);
334 for (it = *queue; NULL != it && it->rtItemTime < pItem->rtItemTime; it = it->next) {
337 if (NULL == prev_it) {
339 if (NULL != *queue) pItem->next = (*queue)->next;
340 /*assert( NULL == pItem->next->prev );*/
341 if (NULL != pItem->next) pItem->next->prev = pItem;
344 pItem->prev = prev_it;
345 pItem->next = prev_it->next;
346 prev_it->next = pItem;
347 if (NULL != pItem->next) pItem->next->prev = pItem;
349 LeaveCriticalSection(&This->safe);
351 /** now in use, prevent from stupid Frees */
352 pItem->bInUse = TRUE;
356 HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, REFERENCE_TIME* prtTime) {
357 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
358 FIXME("(%p, %ld, %p): stub\n", This, mtTime, prtTime);
362 HRESULT WINAPI IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, MUSIC_TIME* pmtTime) {
363 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
364 FIXME("(%p, %lli, %p): stub\n", This, rtTime, pmtTime);
368 HRESULT WINAPI IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegState) {
369 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
370 FIXME("(%p, %p, %p): stub\n", This, pSegment, pSegState);
374 HRESULT WINAPI IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtNow, MUSIC_TIME* pmtNow) {
375 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
377 REFERENCE_TIME rtCur = 0;
379 /*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */
380 if (This->procThreadTicStarted) {
381 rtCur = ((REFERENCE_TIME) GetTickCount() * 10000) - This->procThreadStartTime;
383 /*return DMUS_E_NO_MASTER_CLOCK;*/
385 if (NULL != prtNow) {
388 if (NULL != pmtNow) {
389 hr = IDirectMusicPerformance8_ReferenceToMusicTime(iface, rtCur, pmtNow);
394 HRESULT WINAPI IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface, ULONG cb, DMUS_PMSG** ppPMSG) {
395 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
396 DMUS_PMSGItem* pItem = NULL;
398 FIXME("(%p, %ld, %p): stub\n", This, cb, ppPMSG);
400 if (sizeof(DMUS_PMSG) > cb) {
403 if (NULL == ppPMSG) {
406 pItem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb - sizeof(DMUS_PMSG) + sizeof(DMUS_PMSGItem));
408 return E_OUTOFMEMORY;
410 pItem->pMsg.dwSize = cb;
411 *ppPMSG = DMUS_ItemToPMSG(pItem);
415 HRESULT WINAPI IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG) {
416 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
417 DMUS_PMSGItem* pItem = NULL;
419 FIXME("(%p, %p): stub\n", This, pPMSG);
424 pItem = DMUS_PMSGToItem(pPMSG);
429 /** prevent for freeing PMsg in queue (ie to be processed) */
430 return DMUS_E_CANNOT_FREE;
432 /** now we can remove it safely */
433 EnterCriticalSection(&This->safe);
434 DMUS_ItemRemoveFromQueue( This, pItem );
435 LeaveCriticalSection(&This->safe);
437 /** TODO: see if we should Release the pItem->pMsg->punkUser and others Interfaces */
438 HeapFree(GetProcessHeap(), 0, pItem);
442 HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph** ppGraph) {
443 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
444 FIXME("(%p, %p): to check\n", This, ppGraph);
445 if (NULL != This->pToolGraph) {
446 *ppGraph = (LPDIRECTMUSICGRAPH) This->pToolGraph;
447 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) *ppGraph);
454 HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph* pGraph) {
455 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
457 FIXME("(%p, %p): to check\n", This, pGraph);
459 if (NULL != This->pToolGraph) {
460 /* Todo clean buffers and tools before */
461 IDirectMusicGraph_Release((LPDIRECTMUSICGRAPH) This->pToolGraph);
463 This->pToolGraph = pGraph;
464 if (NULL != This->pToolGraph) {
465 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) This->pToolGraph);
470 HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface, HANDLE hNotification, REFERENCE_TIME rtMinimum) {
471 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
472 FIXME("(%p, %p, %lli): stub\n", This, hNotification, rtMinimum);
473 This->hNotification = hNotification;
474 if (rtMinimum) This->rtMinimum = rtMinimum;
478 HRESULT WINAPI IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_NOTIFICATION_PMSG** ppNotificationPMsg) {
479 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
482 FIXME("(%p, %p): stub\n", This, ppNotificationPMsg);
483 if (NULL == ppNotificationPMsg) {
493 HRESULT WINAPI IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType) {
494 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
495 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
499 HRESULT WINAPI IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType) {
500 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
501 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
505 HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort) {
506 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
507 FIXME("(%p, %p): stub\n", This, pPort);
508 IDirectMusicPort_AddRef (pPort);
512 HRESULT WINAPI IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort) {
513 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
514 FIXME("(%p, %p): stub\n", This, pPort);
515 IDirectMusicPort_Release (pPort);
519 HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwBlockNum, IDirectMusicPort* pPort, DWORD dwGroup) {
520 int i, j, range /* min value in range */;
521 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
523 FIXME("(%p, %ld, %p, %ld): semi-stub\n", This, dwBlockNum, pPort, dwGroup-1);
524 range = 16 * dwBlockNum;
527 for (i = range; i < range+16; i++) {
528 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
529 This->PChannel[i].port = pPort;
530 This->PChannel[i].group = dwGroup - 1; /* first index is always zero */
531 This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
538 HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel) {
539 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
541 TRACE("(%p, %ld, %p, %ld, %ld)\n", This, dwPChannel, pPort, dwGroup, dwMChannel);
542 This->PChannel[dwPChannel].port = pPort;
543 This->PChannel[dwPChannel].group = dwGroup;
544 This->PChannel[dwPChannel].channel = dwMChannel;
549 HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) {
550 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
551 FIXME("(%p, %ld, %p, %p, %p): stub\n", This, dwPChannel, ppPort, pdwGroup, pdwMChannel);
555 HRESULT WINAPI IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicInstrument* pInst, DWORD dwPChannel, IDirectMusicDownloadedInstrument** ppDownInst, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) {
556 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
557 FIXME("(%p, %p, %ld, %p, %p, %ld, %p, %p, %p): stub\n", This, pInst, dwPChannel, ppDownInst, pNoteRanges, dwNumNoteRanges, ppPort, pdwGroup, pdwMChannel);
561 HRESULT WINAPI IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DWORD dwFlags) {
562 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
563 FIXME("(%p, %ld, %ld): stub\n", This, mtTime, dwFlags);
567 HRESULT WINAPI IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
568 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
569 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
573 HRESULT WINAPI IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam) {
574 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
575 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pParam);
579 HRESULT WINAPI IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize) {
580 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
582 TRACE("(%p, %s, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
584 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload))
585 memcpy(pParam, &This->fAutoDownload, sizeof(&This->fAutoDownload));
586 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel))
587 memcpy(pParam, &This->cMasterGrooveLevel, sizeof(&This->cMasterGrooveLevel));
588 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo))
589 memcpy(pParam, &This->fMasterTempo, sizeof(&This->fMasterTempo));
590 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume))
591 memcpy(pParam, &This->lMasterVolume, sizeof(&This->lMasterVolume));
596 HRESULT WINAPI IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize) {
597 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
599 TRACE("(%p, %s, %p, %ld)\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
601 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload)) {
602 memcpy(&This->fAutoDownload, pParam, dwSize);
603 TRACE("=> AutoDownload set to %d\n", This->fAutoDownload);
605 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel)) {
606 memcpy(&This->cMasterGrooveLevel, pParam, dwSize);
607 TRACE("=> MasterGrooveLevel set to %i\n", This->cMasterGrooveLevel);
609 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo)) {
610 memcpy(&This->fMasterTempo, pParam, dwSize);
611 TRACE("=> MasterTempo set to %f\n", This->fMasterTempo);
613 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume)) {
614 memcpy(&This->lMasterVolume, pParam, dwSize);
615 TRACE("=> MasterVolume set to %li\n", This->lMasterVolume);
621 HRESULT WINAPI IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime) {
622 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
623 TRACE("(%p, %p): stub\n", This, prtTime);
624 *prtTime = This->rtLatencyTime;
628 HRESULT WINAPI IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime) {
629 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
630 FIXME("(%p, %p): stub\n", This, prtTime);
634 HRESULT WINAPI IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtAmount) {
635 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
636 FIXME("(%p, %lli): stub\n", This, rtAmount);
640 HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface) {
641 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
642 FIXME("(%p): stub\n", This);
643 if (PostMessageToProcessMsgThread(This, PROCESSMSG_EXIT)) {
644 WaitForSingleObject(This->procThread, INFINITE);
645 This->procThreadTicStarted = FALSE;
646 CloseHandle(This->procThread);
648 if (NULL != This->pDirectSound) {
649 IDirectSound_Release((LPDIRECTSOUND) This->pDirectSound);
650 This->pDirectSound = NULL;
652 if (NULL != This->pDirectMusic) {
653 IDirectMusic8_Release((LPDIRECTMUSIC8) This->pDirectMusic);
654 This->pDirectMusic = NULL;
659 HRESULT WINAPI IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, REFERENCE_TIME* prtResolved, DWORD dwTimeResolveFlags) {
660 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
661 FIXME("(%p, %lli, %p, %ld): stub\n", This, rtTime, prtResolved, dwTimeResolveFlags);
665 HRESULT WINAPI IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface, BYTE bMIDIValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, WORD* pwMusicValue) {
666 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
667 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, bMIDIValue, pChord, bPlayMode, bChordLevel, pwMusicValue);
671 HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMusicValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, BYTE* pbMIDIValue) {
672 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
673 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, wMusicValue, pChord, bPlayMode, bChordLevel, pbMIDIValue);
677 HRESULT WINAPI IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DMUS_TIMESIGNATURE* pTimeSig, WORD* pwMeasure, BYTE* pbBeat, BYTE* pbGrid, short* pnOffset) {
678 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
679 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This, mtTime, pTimeSig, pwMeasure, pbBeat, pbGrid, pnOffset);
683 HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMeasure, BYTE bBeat, BYTE bGrid, short nOffset, DMUS_TIMESIGNATURE* pTimeSig, MUSIC_TIME* pmtTime) {
684 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
685 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This, wMeasure, bBeat, bGrid, nOffset, pTimeSig, pmtTime);
689 /* IDirectMusicPerformance8 Interface part follow: */
690 HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 iface,
691 IDirectMusic** ppDirectMusic,
692 IDirectSound** ppDirectSound,
694 DWORD dwDefaultPathType,
695 DWORD dwPChannelCount,
697 DMUS_AUDIOPARAMS* pParams) {
699 IDirectSound* dsound = NULL;
702 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
703 FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
705 if (This->pDirectMusic || This->pDirectSound)
706 return DMUS_E_ALREADY_INITED;
708 if (NULL != ppDirectSound && NULL != *ppDirectSound) {
709 dsound = *ppDirectSound;
711 hr = DirectSoundCreate8 (NULL, (LPDIRECTSOUND8*) &dsound, NULL);
712 FIXME("return dsound(%p,%ld)\n", dsound, hr);
713 if (FAILED(hr) || !dsound)
714 return DSERR_NODRIVER;
716 *ppDirectSound = dsound;
719 IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, dsound, hWnd);
721 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
722 if (NULL == ppDirectSound) {
723 IDirectSound_Release(This->pDirectSound);
726 /* as seen in msdn we need params init before audio path creation */
727 if (NULL != pParams) {
728 memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS));
731 * TODO, how can i fill the struct
732 * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp
734 memset(&This->pParams, 0, sizeof(DMUS_AUDIOPARAMS));
735 This->pParams.dwSize = sizeof(DMUS_AUDIOPARAMS);
736 This->pParams.fInitNow = FALSE;
737 This->pParams.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES | DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH;
738 This->pParams.dwVoices = 64;
739 This->pParams.dwSampleRate = (DWORD) 22.050;
740 This->pParams.dwFeatures = dwFlags;
741 This->pParams.clsidDefaultSynth = CLSID_DirectMusicSynthSink;
743 hr = IDirectMusicPerformance8Impl_CreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath);
745 PostMessageToProcessMsgThread(This, PROCESSMSG_START);
750 HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath) {
751 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
752 FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This, pSource, pwzSegmentName, pTransition, dwFlags, i64StartTime, ppSegmentState, pFrom, pAudioPath);
756 HRESULT WINAPI IDirectMusicPerformance8Impl_StopEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pObjectToStop, __int64 i64StopTime, DWORD dwFlags) {
757 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
758 FIXME("(%p, %p, %lli, %ld): stub\n", This, pObjectToStop, i64StopTime, dwFlags);
762 HRESULT WINAPI IDirectMusicPerformance8Impl_ClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pSourcePMSG, DMUS_PMSG** ppCopyPMSG) {
763 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
764 FIXME("(%p, %p, %p): stub\n", This, pSourcePMSG, ppCopyPMSG);
768 HRESULT WINAPI IDirectMusicPerformance8Impl_CreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSourceConfig, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) {
769 IDirectMusicAudioPathImpl *default_path;
770 IDirectMusicAudioPath *pPath;
772 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
773 FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ppNewPath);
775 if (NULL == ppNewPath) {
779 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath, (LPVOID*)&pPath, NULL);
780 default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl));
781 default_path->pPerf = (IDirectMusicPerformance8*) This;
785 *ppNewPath = (LPDIRECTMUSICAUDIOPATH) pPath;
787 return IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate(*ppNewPath, fActivate);
791 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp
793 HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) {
794 IDirectMusicAudioPathImpl *default_path;
795 IDirectMusicAudioPath *pPath;
798 LPDIRECTSOUNDBUFFER buffer;
801 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
803 FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
805 if (NULL == ppNewPath) {
809 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath, (LPVOID*)&pPath, NULL);
810 default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl));
811 default_path->pPerf = (IDirectMusicPerformance8*) This;
813 /* Secondary buffer description */
814 memset(&format, 0, sizeof(format));
815 format.wFormatTag = WAVE_FORMAT_PCM;
816 format.nChannels = 1;
817 format.nSamplesPerSec = 44000;
818 format.nAvgBytesPerSec = 44000*2;
819 format.nBlockAlign = 2;
820 format.wBitsPerSample = 16;
823 memset(&desc, 0, sizeof(desc));
824 desc.dwSize = sizeof(desc);
825 desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS;
826 desc.dwBufferBytes = DSBSIZE_MIN;
828 desc.lpwfxFormat = &format;
829 desc.guid3DAlgorithm = GUID_NULL;
832 case DMUS_APATH_DYNAMIC_3D:
833 desc.dwFlags |= DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE;
835 case DMUS_APATH_DYNAMIC_MONO:
836 desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
838 case DMUS_APATH_SHARED_STEREOPLUSREVERB:
839 /* normally we havet to create 2 buffers (one for music other for reverb)
840 * in this case. See msdn
842 case DMUS_APATH_DYNAMIC_STEREO:
843 desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
844 format.nChannels = 2;
845 format.nBlockAlign *= 2;
846 format.nAvgBytesPerSec *=2;
849 HeapFree(GetProcessHeap(), 0, default_path);
854 /* FIXME: Should we create one secondary buffer for each PChannel? */
855 hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
857 HeapFree(GetProcessHeap(), 0, default_path);
859 return DSERR_BUFFERLOST;
861 default_path->pDSBuffer = buffer;
863 /* Update description for creating primary buffer */
864 desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
865 desc.dwBufferBytes = 0;
866 desc.lpwfxFormat = NULL;
868 hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
870 IDirectSoundBuffer_Release(default_path->pDSBuffer);
871 HeapFree(GetProcessHeap(), 0, default_path);
873 return DSERR_BUFFERLOST;
875 default_path->pPrimary = buffer;
877 *ppNewPath = (LPDIRECTMUSICAUDIOPATH) pPath;
879 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath);
881 return IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate(*ppNewPath, fActivate);
884 HRESULT WINAPI IDirectMusicPerformance8Impl_SetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath) {
885 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
887 FIXME("(%p, %p): semi-stub\n", This, pAudioPath);
888 if (NULL != This->pDefaultPath) {
889 IDirectMusicAudioPath_Release((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
890 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = NULL;
891 This->pDefaultPath = NULL;
893 This->pDefaultPath = pAudioPath;
894 if (NULL != This->pDefaultPath) {
895 IDirectMusicAudioPath_AddRef((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
896 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = (IDirectMusicPerformance8*) This;
902 HRESULT WINAPI IDirectMusicPerformance8Impl_GetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath** ppAudioPath) {
903 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
905 FIXME("(%p, %p): semi-stub (%p)\n", This, ppAudioPath, This->pDefaultPath);
907 if (NULL != This->pDefaultPath) {
908 *ppAudioPath = (LPDIRECTMUSICAUDIOPATH) This->pDefaultPath;
909 IDirectMusicAudioPath_AddRef(*ppAudioPath);
916 HRESULT WINAPI IDirectMusicPerformance8Impl_GetParamEx (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
917 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
919 FIXME("(%p, %s, %ld, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwTrackID, dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
924 IDirectMusicPerformance8Vtbl DirectMusicPerformance8_Vtbl = {
925 IDirectMusicPerformance8Impl_QueryInterface,
926 IDirectMusicPerformance8Impl_AddRef,
927 IDirectMusicPerformance8Impl_Release,
928 IDirectMusicPerformance8Impl_Init,
929 IDirectMusicPerformance8Impl_PlaySegment,
930 IDirectMusicPerformance8Impl_Stop,
931 IDirectMusicPerformance8Impl_GetSegmentState,
932 IDirectMusicPerformance8Impl_SetPrepareTime,
933 IDirectMusicPerformance8Impl_GetPrepareTime,
934 IDirectMusicPerformance8Impl_SetBumperLength,
935 IDirectMusicPerformance8Impl_GetBumperLength,
936 IDirectMusicPerformance8Impl_SendPMsg,
937 IDirectMusicPerformance8Impl_MusicToReferenceTime,
938 IDirectMusicPerformance8Impl_ReferenceToMusicTime,
939 IDirectMusicPerformance8Impl_IsPlaying,
940 IDirectMusicPerformance8Impl_GetTime,
941 IDirectMusicPerformance8Impl_AllocPMsg,
942 IDirectMusicPerformance8Impl_FreePMsg,
943 IDirectMusicPerformance8Impl_GetGraph,
944 IDirectMusicPerformance8Impl_SetGraph,
945 IDirectMusicPerformance8Impl_SetNotificationHandle,
946 IDirectMusicPerformance8Impl_GetNotificationPMsg,
947 IDirectMusicPerformance8Impl_AddNotificationType,
948 IDirectMusicPerformance8Impl_RemoveNotificationType,
949 IDirectMusicPerformance8Impl_AddPort,
950 IDirectMusicPerformance8Impl_RemovePort,
951 IDirectMusicPerformance8Impl_AssignPChannelBlock,
952 IDirectMusicPerformance8Impl_AssignPChannel,
953 IDirectMusicPerformance8Impl_PChannelInfo,
954 IDirectMusicPerformance8Impl_DownloadInstrument,
955 IDirectMusicPerformance8Impl_Invalidate,
956 IDirectMusicPerformance8Impl_GetParam,
957 IDirectMusicPerformance8Impl_SetParam,
958 IDirectMusicPerformance8Impl_GetGlobalParam,
959 IDirectMusicPerformance8Impl_SetGlobalParam,
960 IDirectMusicPerformance8Impl_GetLatencyTime,
961 IDirectMusicPerformance8Impl_GetQueueTime,
962 IDirectMusicPerformance8Impl_AdjustTime,
963 IDirectMusicPerformance8Impl_CloseDown,
964 IDirectMusicPerformance8Impl_GetResolvedTime,
965 IDirectMusicPerformance8Impl_MIDIToMusic,
966 IDirectMusicPerformance8Impl_MusicToMIDI,
967 IDirectMusicPerformance8Impl_TimeToRhythm,
968 IDirectMusicPerformance8Impl_RhythmToTime,
969 IDirectMusicPerformance8Impl_InitAudio,
970 IDirectMusicPerformance8Impl_PlaySegmentEx,
971 IDirectMusicPerformance8Impl_StopEx,
972 IDirectMusicPerformance8Impl_ClonePMsg,
973 IDirectMusicPerformance8Impl_CreateAudioPath,
974 IDirectMusicPerformance8Impl_CreateStandardAudioPath,
975 IDirectMusicPerformance8Impl_SetDefaultAudioPath,
976 IDirectMusicPerformance8Impl_GetDefaultAudioPath,
977 IDirectMusicPerformance8Impl_GetParamEx
980 /* for ClassFactory */
981 HRESULT WINAPI DMUSIC_CreateDirectMusicPerformanceImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
982 IDirectMusicPerformance8Impl *obj;
984 TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
986 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPerformance8Impl));
988 *ppobj = (LPDIRECTMUSICPERFORMANCE8)NULL;
989 return E_OUTOFMEMORY;
991 obj->lpVtbl = &DirectMusicPerformance8_Vtbl;
992 obj->ref = 0; /* will be inited by QueryInterface */
993 obj->pDirectMusic = NULL;
994 obj->pDirectSound = NULL;
995 obj->pDefaultPath = NULL;
996 InitializeCriticalSection(&obj->safe);
999 * @see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/latencyandbumpertime.asp
1001 obj->rtLatencyTime = 100; /* 100ms TO FIX */
1002 obj->dwBumperLength = 50; /* 50ms default */
1003 obj->dwPrepareTime = 1000; /* 1000ms default */
1004 return IDirectMusicPerformance8Impl_QueryInterface ((LPDIRECTMUSICPERFORMANCE8)obj, lpcGUID, ppobj);