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., 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%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 = 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 %ld\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 %ld\n", This, ref);
201 DeleteCriticalSection(&This->safe);
202 HeapFree(GetProcessHeap(), 0, This);
205 DMIME_UnlockModule();
210 /* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
211 static HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd) {
212 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
214 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This, ppDirectMusic, pDirectSound, hWnd);
215 if (This->pDirectMusic || This->pDirectSound)
216 return DMUS_E_ALREADY_INITED;
219 hWnd = GetForegroundWindow();
222 if (NULL != pDirectSound) {
223 This->pDirectSound = (IDirectSound*) pDirectSound;
224 IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound);
227 hr = DirectSoundCreate8(NULL, (LPDIRECTSOUND8*) &This->pDirectSound, NULL);
228 if (!This->pDirectSound) return DSERR_NODRIVER;
233 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp
236 IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);
238 /* how to get the ForeGround window handle ? */
239 /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
243 if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
244 /* app creates it's own dmusic object and gives it to performance */
245 This->pDirectMusic = (IDirectMusic8*) *ppDirectMusic;
246 IDirectMusic8_AddRef((LPDIRECTMUSIC8) This->pDirectMusic);
248 /* app allows the performance to initialise itfself and needs a pointer to object*/
249 CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic);
251 *ppDirectMusic = (LPDIRECTMUSIC) This->pDirectMusic;
252 IDirectMusic8_AddRef((LPDIRECTMUSIC8) *ppDirectMusic);
259 static HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState) {
260 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
261 FIXME("(%p, %p, %ld, %lli, %p): stub\n", This, pSegment, dwFlags, i64StartTime, ppSegmentState);
265 static HRESULT WINAPI IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegmentState, MUSIC_TIME mtTime, DWORD dwFlags) {
266 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
267 FIXME("(%p, %p, %p, %ld, %ld): stub\n", This, pSegment, pSegmentState, mtTime, dwFlags);
271 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegmentState** ppSegmentState, MUSIC_TIME mtTime) {
272 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
273 FIXME("(%p,%p, %ld): stub\n", This, ppSegmentState, mtTime);
277 static HRESULT WINAPI IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds) {
278 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
279 TRACE("(%p, %ld)\n", This, dwMilliSeconds);
280 This->dwPrepareTime = dwMilliSeconds;
284 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds) {
285 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
286 TRACE("(%p, %p)\n", This, pdwMilliSeconds);
287 if (NULL == pdwMilliSeconds) {
290 *pdwMilliSeconds = This->dwPrepareTime;
294 static HRESULT WINAPI IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds) {
295 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
296 TRACE("(%p, %ld)\n", This, dwMilliSeconds);
297 This->dwBumperLength = dwMilliSeconds;
301 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds) {
302 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
303 TRACE("(%p, %p)\n", This, pdwMilliSeconds);
304 if (NULL == pdwMilliSeconds) {
307 *pdwMilliSeconds = This->dwBumperLength;
311 static HRESULT WINAPI IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG) {
312 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
313 DMUS_PMSGItem* pItem = NULL;
314 DMUS_PMSGItem* it = NULL;
315 DMUS_PMSGItem* prev_it = NULL;
316 DMUS_PMSGItem** queue = NULL;
318 FIXME("(%p, %p): stub\n", This, pPMSG);
323 pItem = DMUS_PMSGToItem(pPMSG);
328 return DMUS_E_ALREADY_SENT;
331 /* TODO: Valid Flags */
332 /* TODO: DMUS_PMSGF_MUSICTIME */
333 pItem->rtItemTime = pPMSG->rtTime;
335 if (pPMSG->dwFlags & DMUS_PMSGF_TOOL_IMMEDIATE) {
336 queue = &This->imm_head;
341 EnterCriticalSection(&This->safe);
342 for (it = *queue; NULL != it && it->rtItemTime < pItem->rtItemTime; it = it->next) {
345 if (NULL == prev_it) {
347 if (NULL != *queue) pItem->next = (*queue)->next;
348 /*assert( NULL == pItem->next->prev );*/
349 if (NULL != pItem->next) pItem->next->prev = pItem;
352 pItem->prev = prev_it;
353 pItem->next = prev_it->next;
354 prev_it->next = pItem;
355 if (NULL != pItem->next) pItem->next->prev = pItem;
357 LeaveCriticalSection(&This->safe);
359 /** now in use, prevent from stupid Frees */
360 pItem->bInUse = TRUE;
364 static HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, REFERENCE_TIME* prtTime) {
365 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
366 FIXME("(%p, %ld, %p): stub\n", This, mtTime, prtTime);
370 static HRESULT WINAPI IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, MUSIC_TIME* pmtTime) {
371 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
372 FIXME("(%p, %lli, %p): stub\n", This, rtTime, pmtTime);
376 static HRESULT WINAPI IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegState) {
377 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
378 FIXME("(%p, %p, %p): stub\n", This, pSegment, pSegState);
382 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtNow, MUSIC_TIME* pmtNow) {
383 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
385 REFERENCE_TIME rtCur = 0;
387 /*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */
388 if (This->procThreadTicStarted) {
389 rtCur = ((REFERENCE_TIME) GetTickCount() * 10000) - This->procThreadStartTime;
391 /*return DMUS_E_NO_MASTER_CLOCK;*/
393 if (NULL != prtNow) {
396 if (NULL != pmtNow) {
397 hr = IDirectMusicPerformance8_ReferenceToMusicTime(iface, rtCur, pmtNow);
402 static HRESULT WINAPI IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface, ULONG cb, DMUS_PMSG** ppPMSG) {
403 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
404 DMUS_PMSGItem* pItem = NULL;
406 FIXME("(%p, %ld, %p): stub\n", This, cb, ppPMSG);
408 if (sizeof(DMUS_PMSG) > cb) {
411 if (NULL == ppPMSG) {
414 pItem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb - sizeof(DMUS_PMSG) + sizeof(DMUS_PMSGItem));
416 return E_OUTOFMEMORY;
418 pItem->pMsg.dwSize = cb;
419 *ppPMSG = DMUS_ItemToPMSG(pItem);
423 static HRESULT WINAPI IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG) {
424 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
425 DMUS_PMSGItem* pItem = NULL;
427 FIXME("(%p, %p): stub\n", This, pPMSG);
432 pItem = DMUS_PMSGToItem(pPMSG);
437 /** prevent for freeing PMsg in queue (ie to be processed) */
438 return DMUS_E_CANNOT_FREE;
440 /** now we can remove it safely */
441 EnterCriticalSection(&This->safe);
442 DMUS_ItemRemoveFromQueue( This, pItem );
443 LeaveCriticalSection(&This->safe);
445 /** TODO: see if we should Release the pItem->pMsg->punkUser and others Interfaces */
446 HeapFree(GetProcessHeap(), 0, pItem);
450 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph** ppGraph) {
451 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
452 FIXME("(%p, %p): to check\n", This, ppGraph);
453 if (NULL != This->pToolGraph) {
454 *ppGraph = (LPDIRECTMUSICGRAPH) This->pToolGraph;
455 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) *ppGraph);
462 static HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph* pGraph) {
463 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
465 FIXME("(%p, %p): to check\n", This, pGraph);
467 if (NULL != This->pToolGraph) {
468 /* Todo clean buffers and tools before */
469 IDirectMusicGraph_Release((LPDIRECTMUSICGRAPH) This->pToolGraph);
471 This->pToolGraph = pGraph;
472 if (NULL != This->pToolGraph) {
473 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) This->pToolGraph);
478 static HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface, HANDLE hNotification, REFERENCE_TIME rtMinimum) {
479 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
480 FIXME("(%p, %p, %lli): stub\n", This, hNotification, rtMinimum);
481 This->hNotification = hNotification;
482 if (rtMinimum) This->rtMinimum = rtMinimum;
486 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_NOTIFICATION_PMSG** ppNotificationPMsg) {
487 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
490 FIXME("(%p, %p): stub\n", This, ppNotificationPMsg);
491 if (NULL == ppNotificationPMsg) {
501 static HRESULT WINAPI IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType) {
502 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
503 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
507 static HRESULT WINAPI IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType) {
508 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
509 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
513 static HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort) {
514 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
516 FIXME("(%p, %p): stub\n", This, pPort);
517 if (!This->pDirectMusic || !This->pDirectSound) return DMUS_E_NOT_INIT;
520 IDirectMusicPort* pDefaultPort = NULL;
521 DMUS_PORTPARAMS params;
523 hr = IDirectMusic8_GetDefaultPort(This->pDirectMusic, &port_guid);
524 if (FAILED(hr)) return hr;
525 ZeroMemory(¶ms, sizeof(params));
526 params.dwSize = sizeof(params);
527 params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS | DMUS_PORTPARAMS_SHARE;
528 params.dwChannelGroups = 1;
529 params.fShare = TRUE;
530 hr = IDirectMusic8_CreatePort(This->pDirectMusic, &port_guid, ¶ms, &pDefaultPort, NULL);
531 if (FAILED(hr)) return hr;
532 hr = IDirectMusicPort_Activate(pDefaultPort, TRUE);
533 if (FAILED(hr)) { IDirectMusicPort_Release(pDefaultPort); return hr; }
535 for (i = 0; i < 16; ++i) {
536 if (NULL == This->PChannel[i].port) {
537 This->PChannel[i].port = pPort;
538 This->PChannel[i].group = 0;
539 This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
544 IDirectMusicPort_AddRef(pPort);
547 * We should remember added Ports (for example using a list)
548 * and control if Port is registered for each api who use ports
553 static HRESULT WINAPI IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort) {
554 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
555 FIXME("(%p, %p): stub\n", This, pPort);
556 IDirectMusicPort_Release (pPort);
560 static HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwBlockNum, IDirectMusicPort* pPort, DWORD dwGroup) {
561 int i, j, range /* min value in range */;
562 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
564 FIXME("(%p, %ld, %p, %ld): semi-stub\n", This, dwBlockNum, pPort, dwGroup-1);
565 if (NULL == pPort) return E_POINTER;
567 range = 16 * dwBlockNum;
569 for (i = range; i < range+16; i++) {
570 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
571 This->PChannel[i].port = pPort;
572 This->PChannel[i].group = dwGroup - 1; /* first index is always zero */
573 This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
576 /*if (dwGroup > 2) return S_FALSE;*/
581 static HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel) {
582 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
584 TRACE("(%p, %ld, %p, %ld, %ld)\n", This, dwPChannel, pPort, dwGroup, dwMChannel);
585 if (NULL == pPort) return E_POINTER;
586 This->PChannel[dwPChannel].port = pPort;
587 This->PChannel[dwPChannel].group = dwGroup;
588 This->PChannel[dwPChannel].channel = dwMChannel;
593 static HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) {
594 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
595 FIXME("(%p, %ld, %p, %p, %p): stub\n", This, dwPChannel, ppPort, pdwGroup, pdwMChannel);
599 static HRESULT WINAPI IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicInstrument* pInst, DWORD dwPChannel, IDirectMusicDownloadedInstrument** ppDownInst, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) {
600 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
601 FIXME("(%p, %p, %ld, %p, %p, %ld, %p, %p, %p): stub\n", This, pInst, dwPChannel, ppDownInst, pNoteRanges, dwNumNoteRanges, ppPort, pdwGroup, pdwMChannel);
605 static HRESULT WINAPI IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DWORD dwFlags) {
606 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
607 FIXME("(%p, %ld, %ld): stub\n", This, mtTime, dwFlags);
611 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
612 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
613 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
617 static HRESULT WINAPI IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam) {
618 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
619 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pParam);
623 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize) {
624 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
626 TRACE("(%p, %s, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
628 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload))
629 memcpy(pParam, &This->fAutoDownload, sizeof(&This->fAutoDownload));
630 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel))
631 memcpy(pParam, &This->cMasterGrooveLevel, sizeof(&This->cMasterGrooveLevel));
632 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo))
633 memcpy(pParam, &This->fMasterTempo, sizeof(&This->fMasterTempo));
634 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume))
635 memcpy(pParam, &This->lMasterVolume, sizeof(&This->lMasterVolume));
640 static HRESULT WINAPI IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize) {
641 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
643 TRACE("(%p, %s, %p, %ld)\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
645 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload)) {
646 memcpy(&This->fAutoDownload, pParam, dwSize);
647 TRACE("=> AutoDownload set to %d\n", This->fAutoDownload);
649 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel)) {
650 memcpy(&This->cMasterGrooveLevel, pParam, dwSize);
651 TRACE("=> MasterGrooveLevel set to %i\n", This->cMasterGrooveLevel);
653 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo)) {
654 memcpy(&This->fMasterTempo, pParam, dwSize);
655 TRACE("=> MasterTempo set to %f\n", This->fMasterTempo);
657 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume)) {
658 memcpy(&This->lMasterVolume, pParam, dwSize);
659 TRACE("=> MasterVolume set to %li\n", This->lMasterVolume);
665 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime) {
666 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
667 TRACE("(%p, %p): stub\n", This, prtTime);
668 *prtTime = This->rtLatencyTime;
672 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime) {
673 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
674 FIXME("(%p, %p): stub\n", This, prtTime);
678 static HRESULT WINAPI IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtAmount) {
679 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
680 FIXME("(%p, %lli): stub\n", This, rtAmount);
684 static HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface) {
685 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
686 FIXME("(%p): stub\n", This);
687 if (PostMessageToProcessMsgThread(This, PROCESSMSG_EXIT)) {
688 WaitForSingleObject(This->procThread, INFINITE);
689 This->procThreadTicStarted = FALSE;
690 CloseHandle(This->procThread);
692 if (NULL != This->pDirectSound) {
693 IDirectSound_Release((LPDIRECTSOUND) This->pDirectSound);
694 This->pDirectSound = NULL;
696 if (NULL != This->pDirectMusic) {
697 IDirectMusic8_Release((LPDIRECTMUSIC8) This->pDirectMusic);
698 This->pDirectMusic = NULL;
703 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, REFERENCE_TIME* prtResolved, DWORD dwTimeResolveFlags) {
704 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
705 FIXME("(%p, %lli, %p, %ld): stub\n", This, rtTime, prtResolved, dwTimeResolveFlags);
709 static HRESULT WINAPI IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface, BYTE bMIDIValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, WORD* pwMusicValue) {
710 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
711 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, bMIDIValue, pChord, bPlayMode, bChordLevel, pwMusicValue);
715 static HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMusicValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, BYTE* pbMIDIValue) {
716 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
717 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, wMusicValue, pChord, bPlayMode, bChordLevel, pbMIDIValue);
721 static HRESULT WINAPI IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DMUS_TIMESIGNATURE* pTimeSig, WORD* pwMeasure, BYTE* pbBeat, BYTE* pbGrid, short* pnOffset) {
722 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
723 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This, mtTime, pTimeSig, pwMeasure, pbBeat, pbGrid, pnOffset);
727 static HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMeasure, BYTE bBeat, BYTE bGrid, short nOffset, DMUS_TIMESIGNATURE* pTimeSig, MUSIC_TIME* pmtTime) {
728 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
729 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This, wMeasure, bBeat, bGrid, nOffset, pTimeSig, pmtTime);
733 /* IDirectMusicPerformance8 Interface part follow: */
734 static HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 iface,
735 IDirectMusic** ppDirectMusic,
736 IDirectSound** ppDirectSound,
738 DWORD dwDefaultPathType,
739 DWORD dwPChannelCount,
741 DMUS_AUDIOPARAMS* pParams) {
743 IDirectSound* dsound = NULL;
746 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
747 FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
749 if (This->pDirectMusic || This->pDirectSound)
750 return DMUS_E_ALREADY_INITED;
752 if (NULL != ppDirectSound && NULL != *ppDirectSound) {
753 dsound = *ppDirectSound;
755 hr = DirectSoundCreate8 (NULL, (LPDIRECTSOUND8*) &dsound, NULL);
756 FIXME("return dsound(%p,%ld)\n", dsound, hr);
757 if (FAILED(hr) || !dsound)
758 return DSERR_NODRIVER;
760 *ppDirectSound = dsound;
763 IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, dsound, hWnd);
765 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
766 if (NULL == ppDirectSound) {
767 IDirectSound_Release(This->pDirectSound);
770 /* as seen in msdn we need params init before audio path creation */
771 if (NULL != pParams) {
772 memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS));
775 * TODO, how can i fill the struct
776 * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp
778 memset(&This->pParams, 0, sizeof(DMUS_AUDIOPARAMS));
779 This->pParams.dwSize = sizeof(DMUS_AUDIOPARAMS);
780 This->pParams.fInitNow = FALSE;
781 This->pParams.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES | DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH;
782 This->pParams.dwVoices = 64;
783 This->pParams.dwSampleRate = (DWORD) 22.050;
784 This->pParams.dwFeatures = dwFlags;
785 This->pParams.clsidDefaultSynth = CLSID_DirectMusicSynthSink;
787 hr = IDirectMusicPerformance8_CreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath);
789 PostMessageToProcessMsgThread(This, PROCESSMSG_START);
794 static HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath) {
795 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
796 FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This, pSource, pwzSegmentName, pTransition, dwFlags, i64StartTime, ppSegmentState, pFrom, pAudioPath);
800 static HRESULT WINAPI IDirectMusicPerformance8Impl_StopEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pObjectToStop, __int64 i64StopTime, DWORD dwFlags) {
801 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
802 FIXME("(%p, %p, %lli, %ld): stub\n", This, pObjectToStop, i64StopTime, dwFlags);
806 static HRESULT WINAPI IDirectMusicPerformance8Impl_ClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pSourcePMSG, DMUS_PMSG** ppCopyPMSG) {
807 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
808 FIXME("(%p, %p, %p): stub\n", This, pSourcePMSG, ppCopyPMSG);
812 static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSourceConfig, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) {
813 IDirectMusicAudioPathImpl *default_path;
814 IDirectMusicAudioPath *pPath;
816 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
817 FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ppNewPath);
819 if (NULL == ppNewPath) {
823 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath, (LPVOID*)&pPath, NULL);
824 default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl));
825 default_path->pPerf = (IDirectMusicPerformance8*) This;
829 *ppNewPath = (LPDIRECTMUSICAUDIOPATH) pPath;
831 return IDirectMusicAudioPath_Activate(*ppNewPath, fActivate);
835 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp
837 static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) {
838 IDirectMusicAudioPathImpl *default_path;
839 IDirectMusicAudioPath *pPath;
842 LPDIRECTSOUNDBUFFER buffer;
845 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
847 FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
849 if (NULL == ppNewPath) {
853 DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath, (LPVOID*)&pPath, NULL);
854 default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl));
855 default_path->pPerf = (IDirectMusicPerformance8*) This;
857 /* Secondary buffer description */
858 memset(&format, 0, sizeof(format));
859 format.wFormatTag = WAVE_FORMAT_PCM;
860 format.nChannels = 1;
861 format.nSamplesPerSec = 44000;
862 format.nAvgBytesPerSec = 44000*2;
863 format.nBlockAlign = 2;
864 format.wBitsPerSample = 16;
867 memset(&desc, 0, sizeof(desc));
868 desc.dwSize = sizeof(desc);
869 desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS;
870 desc.dwBufferBytes = DSBSIZE_MIN;
872 desc.lpwfxFormat = &format;
873 desc.guid3DAlgorithm = GUID_NULL;
876 case DMUS_APATH_DYNAMIC_3D:
877 desc.dwFlags |= DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE;
879 case DMUS_APATH_DYNAMIC_MONO:
880 desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
882 case DMUS_APATH_SHARED_STEREOPLUSREVERB:
883 /* normally we havet to create 2 buffers (one for music other for reverb)
884 * in this case. See msdn
886 case DMUS_APATH_DYNAMIC_STEREO:
887 desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
888 format.nChannels = 2;
889 format.nBlockAlign *= 2;
890 format.nAvgBytesPerSec *=2;
893 HeapFree(GetProcessHeap(), 0, default_path);
898 /* FIXME: Should we create one secondary buffer for each PChannel? */
899 hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
901 HeapFree(GetProcessHeap(), 0, default_path);
903 return DSERR_BUFFERLOST;
905 default_path->pDSBuffer = buffer;
907 /* Update description for creating primary buffer */
908 desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
909 desc.dwBufferBytes = 0;
910 desc.lpwfxFormat = NULL;
912 hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
914 IDirectSoundBuffer_Release(default_path->pDSBuffer);
915 HeapFree(GetProcessHeap(), 0, default_path);
917 return DSERR_BUFFERLOST;
919 default_path->pPrimary = buffer;
921 *ppNewPath = (LPDIRECTMUSICAUDIOPATH) pPath;
923 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath);
925 return IDirectMusicAudioPath_Activate(*ppNewPath, fActivate);
928 static HRESULT WINAPI IDirectMusicPerformance8Impl_SetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath) {
929 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
931 FIXME("(%p, %p): semi-stub\n", This, pAudioPath);
932 if (NULL != This->pDefaultPath) {
933 IDirectMusicAudioPath_Release((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
934 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = NULL;
935 This->pDefaultPath = NULL;
937 This->pDefaultPath = pAudioPath;
938 if (NULL != This->pDefaultPath) {
939 IDirectMusicAudioPath_AddRef((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
940 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = (IDirectMusicPerformance8*) This;
946 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath** ppAudioPath) {
947 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
949 FIXME("(%p, %p): semi-stub (%p)\n", This, ppAudioPath, This->pDefaultPath);
951 if (NULL != This->pDefaultPath) {
952 *ppAudioPath = (LPDIRECTMUSICAUDIOPATH) This->pDefaultPath;
953 IDirectMusicAudioPath_AddRef(*ppAudioPath);
960 static HRESULT WINAPI IDirectMusicPerformance8Impl_GetParamEx (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
961 IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
963 FIXME("(%p, %s, %ld, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwTrackID, dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
968 static const IDirectMusicPerformance8Vtbl DirectMusicPerformance8_Vtbl = {
969 IDirectMusicPerformance8Impl_QueryInterface,
970 IDirectMusicPerformance8Impl_AddRef,
971 IDirectMusicPerformance8Impl_Release,
972 IDirectMusicPerformance8Impl_Init,
973 IDirectMusicPerformance8Impl_PlaySegment,
974 IDirectMusicPerformance8Impl_Stop,
975 IDirectMusicPerformance8Impl_GetSegmentState,
976 IDirectMusicPerformance8Impl_SetPrepareTime,
977 IDirectMusicPerformance8Impl_GetPrepareTime,
978 IDirectMusicPerformance8Impl_SetBumperLength,
979 IDirectMusicPerformance8Impl_GetBumperLength,
980 IDirectMusicPerformance8Impl_SendPMsg,
981 IDirectMusicPerformance8Impl_MusicToReferenceTime,
982 IDirectMusicPerformance8Impl_ReferenceToMusicTime,
983 IDirectMusicPerformance8Impl_IsPlaying,
984 IDirectMusicPerformance8Impl_GetTime,
985 IDirectMusicPerformance8Impl_AllocPMsg,
986 IDirectMusicPerformance8Impl_FreePMsg,
987 IDirectMusicPerformance8Impl_GetGraph,
988 IDirectMusicPerformance8Impl_SetGraph,
989 IDirectMusicPerformance8Impl_SetNotificationHandle,
990 IDirectMusicPerformance8Impl_GetNotificationPMsg,
991 IDirectMusicPerformance8Impl_AddNotificationType,
992 IDirectMusicPerformance8Impl_RemoveNotificationType,
993 IDirectMusicPerformance8Impl_AddPort,
994 IDirectMusicPerformance8Impl_RemovePort,
995 IDirectMusicPerformance8Impl_AssignPChannelBlock,
996 IDirectMusicPerformance8Impl_AssignPChannel,
997 IDirectMusicPerformance8Impl_PChannelInfo,
998 IDirectMusicPerformance8Impl_DownloadInstrument,
999 IDirectMusicPerformance8Impl_Invalidate,
1000 IDirectMusicPerformance8Impl_GetParam,
1001 IDirectMusicPerformance8Impl_SetParam,
1002 IDirectMusicPerformance8Impl_GetGlobalParam,
1003 IDirectMusicPerformance8Impl_SetGlobalParam,
1004 IDirectMusicPerformance8Impl_GetLatencyTime,
1005 IDirectMusicPerformance8Impl_GetQueueTime,
1006 IDirectMusicPerformance8Impl_AdjustTime,
1007 IDirectMusicPerformance8Impl_CloseDown,
1008 IDirectMusicPerformance8Impl_GetResolvedTime,
1009 IDirectMusicPerformance8Impl_MIDIToMusic,
1010 IDirectMusicPerformance8Impl_MusicToMIDI,
1011 IDirectMusicPerformance8Impl_TimeToRhythm,
1012 IDirectMusicPerformance8Impl_RhythmToTime,
1013 IDirectMusicPerformance8Impl_InitAudio,
1014 IDirectMusicPerformance8Impl_PlaySegmentEx,
1015 IDirectMusicPerformance8Impl_StopEx,
1016 IDirectMusicPerformance8Impl_ClonePMsg,
1017 IDirectMusicPerformance8Impl_CreateAudioPath,
1018 IDirectMusicPerformance8Impl_CreateStandardAudioPath,
1019 IDirectMusicPerformance8Impl_SetDefaultAudioPath,
1020 IDirectMusicPerformance8Impl_GetDefaultAudioPath,
1021 IDirectMusicPerformance8Impl_GetParamEx
1024 /* for ClassFactory */
1025 HRESULT WINAPI DMUSIC_CreateDirectMusicPerformanceImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
1026 IDirectMusicPerformance8Impl *obj;
1028 TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
1030 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPerformance8Impl));
1032 *ppobj = (LPDIRECTMUSICPERFORMANCE8)NULL;
1033 return E_OUTOFMEMORY;
1035 obj->lpVtbl = &DirectMusicPerformance8_Vtbl;
1036 obj->ref = 0; /* will be inited by QueryInterface */
1037 obj->pDirectMusic = NULL;
1038 obj->pDirectSound = NULL;
1039 obj->pDefaultPath = NULL;
1040 InitializeCriticalSection(&obj->safe);
1043 * @see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/latencyandbumpertime.asp
1045 obj->rtLatencyTime = 100; /* 100ms TO FIX */
1046 obj->dwBumperLength = 50; /* 50ms default */
1047 obj->dwPrepareTime = 1000; /* 1000ms default */
1048 return IDirectMusicPerformance8Impl_QueryInterface ((LPDIRECTMUSICPERFORMANCE8)obj, lpcGUID, ppobj);