- implemented loader, loader's stream and loading of objects (now you
[wine/wine64.git] / dlls / dmime / performance.c
blobdfae2af8c550907b8ef687eb45711a69d8efacd0
1 /* IDirectMusicPerformance Implementation
3 * Copyright (C) 2003 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "windef.h"
21 #include "winbase.h"
22 #include "winuser.h"
23 #include "wingdi.h"
24 #include "wine/debug.h"
26 #include "dmime_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
30 /* IDirectMusicPerformance8 IUnknown part: */
31 HRESULT WINAPI IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface, REFIID riid, LPVOID *ppobj)
33 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
35 if (IsEqualIID (riid, &IID_IUnknown) ||
36 IsEqualIID (riid, &IID_IDirectMusicPerformance) ||
37 IsEqualIID (riid, &IID_IDirectMusicPerformance8)) {
38 IDirectMusicPerformance8Impl_AddRef(iface);
39 *ppobj = This;
40 return S_OK;
43 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
44 return E_NOINTERFACE;
47 ULONG WINAPI IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface)
49 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
50 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
51 return ++(This->ref);
54 ULONG WINAPI IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface)
56 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
57 ULONG ref = --This->ref;
58 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
59 if (ref == 0) {
60 HeapFree(GetProcessHeap(), 0, This);
62 return ref;
65 /* IDirectMusicPerformance8 IDirectMusicPerformance Interface part: */
66 HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd)
68 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
70 FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This, ppDirectMusic, pDirectSound, hWnd);
71 if (This->pDirectMusic || This->pDirectSound)
72 return DMUS_E_ALREADY_INITED;
74 if (NULL != pDirectSound) {
75 This->pDirectSound = (IDirectSound*) pDirectSound;
76 IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound);
77 } else {
78 DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->pDirectSound, NULL);
79 if (!This->pDirectSound)
80 return DSERR_NODRIVER;
83 if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
84 /* app creates it's own dmusic object and gives it to performance */
85 This->pDirectMusic = (IDirectMusic8*) *ppDirectMusic;
86 IDirectMusic8_AddRef((LPDIRECTMUSIC8) This->pDirectMusic);
87 } else {
88 /* app allows the performance to initialise itfself and needs a pointer to object*/
89 CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic);
90 if (ppDirectMusic) {
91 *ppDirectMusic = (LPDIRECTMUSIC) This->pDirectMusic;
92 IDirectMusic8_AddRef((LPDIRECTMUSIC8) *ppDirectMusic);
96 return S_OK;
99 HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState)
101 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
103 FIXME("(%p, %p, %ld, %lli, %p): stub\n", This, pSegment, dwFlags, i64StartTime, ppSegmentState);
105 return S_OK;
108 HRESULT WINAPI IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegmentState, MUSIC_TIME mtTime, DWORD dwFlags)
110 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
112 FIXME("(%p, %p, %p, %ld, %ld): stub\n", This, pSegment, pSegmentState, mtTime, dwFlags);
114 return S_OK;
117 HRESULT WINAPI IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegmentState** ppSegmentState, MUSIC_TIME mtTime)
119 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
121 FIXME("(%p,%p, %ld): stub\n", This, ppSegmentState, mtTime);
123 return S_OK;
126 HRESULT WINAPI IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds)
128 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
130 FIXME("(%p, %ld): stub\n", This, dwMilliSeconds);
132 return S_OK;
135 HRESULT WINAPI IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds)
137 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
139 FIXME("(%p, %p): stub\n", This, pdwMilliSeconds);
141 return S_OK;
144 HRESULT WINAPI IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds)
146 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
148 FIXME("(%p, %ld): stub\n", This, dwMilliSeconds);
150 return S_OK;
153 HRESULT WINAPI IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds)
155 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
157 FIXME("(%p, %p): stub\n", This, pdwMilliSeconds);
159 return S_OK;
162 HRESULT WINAPI IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG)
164 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
166 FIXME("(%p, %p): stub\n", This, pPMSG);
168 return S_OK;
171 HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, REFERENCE_TIME* prtTime)
173 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
175 FIXME("(%p, %ld, %p): stub\n", This, mtTime, prtTime);
177 return S_OK;
180 HRESULT WINAPI IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, MUSIC_TIME* pmtTime)
182 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
184 FIXME("(%p, %lli, %p): stub\n", This, rtTime, pmtTime);
186 return S_OK;
189 HRESULT WINAPI IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegState)
191 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
193 FIXME("(%p, %p, %p): stub\n", This, pSegment, pSegState);
195 return S_OK;
198 HRESULT WINAPI IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtNow, MUSIC_TIME* pmtNow)
200 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
202 FIXME("(%p, %p, %p): stub\n", This, prtNow, pmtNow);
204 return S_OK;
207 HRESULT WINAPI IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface, ULONG cb, DMUS_PMSG** ppPMSG)
209 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
211 FIXME("(%p, %ld, %p): stub\n", This, cb, ppPMSG);
213 return S_OK;
216 HRESULT WINAPI IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG)
218 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
220 FIXME("(%p, %p): stub\n", This, pPMSG);
222 return S_OK;
225 HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph** ppGraph)
227 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
229 FIXME("(%p, %p): to check\n", This, ppGraph);
231 if (NULL != This->pToolGraph) {
232 *ppGraph = (LPDIRECTMUSICGRAPH) This->pToolGraph;
233 IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) *ppGraph);
235 return S_OK;
238 HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph* pGraph)
240 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
242 FIXME("(%p, %p): to check\n", This, pGraph);
244 if (NULL != This->pToolGraph) {
245 /* Todo clean buffers and tools before */
246 IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) This->pToolGraph);
248 This->pToolGraph = pGraph;
249 if (NULL != This->pToolGraph) {
250 IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) This->pToolGraph);
252 return S_OK;
255 HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface, HANDLE hNotification, REFERENCE_TIME rtMinimum)
257 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
259 FIXME("(%p, %p, %lli): stub\n", This, hNotification, rtMinimum);
261 return S_OK;
264 HRESULT WINAPI IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_NOTIFICATION_PMSG** ppNotificationPMsg)
266 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
268 FIXME("(%p, %p): stub\n", This, ppNotificationPMsg);
270 return S_OK;
273 HRESULT WINAPI IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType)
275 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
277 FIXME("(%p, %s): stub\n", This, debugstr_guid(rguidNotificationType));
279 return S_OK;
282 HRESULT WINAPI IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType)
284 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
286 FIXME("(%p, %s): stub\n", This, debugstr_guid(rguidNotificationType));
288 return S_OK;
291 HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort)
293 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
295 FIXME("(%p, %p): stub\n", This, pPort);
296 IDirectMusicPort_AddRef (pPort);
298 return S_OK;
301 HRESULT WINAPI IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort)
303 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
305 FIXME("(%p, %p): stub\n", This, pPort);
306 IDirectMusicPort_Release (pPort);
308 return S_OK;
311 HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwBlockNum, IDirectMusicPort* pPort, DWORD dwGroup)
313 int i, j, range /* min value in range */;
314 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
316 FIXME("(%p, %ld, %p, %ld): semi-stub\n", This, dwBlockNum, pPort, dwGroup-1);
317 range = 16 * dwBlockNum;
318 j = 0;
320 for (i = range; i < range+16; i++) {
321 /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
322 This->PChannel[i].port = pPort;
323 This->PChannel[i].group = dwGroup - 1; /* first index is always zero */
324 This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
325 j++;
328 return S_OK;
331 HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel)
333 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
335 TRACE("(%p, %ld, %p, %ld, %ld)\n", This, dwPChannel, pPort, dwGroup, dwMChannel);
336 This->PChannel[dwPChannel].port = pPort;
337 This->PChannel[dwPChannel].group = dwGroup;
338 This->PChannel[dwPChannel].channel = dwMChannel;
340 return S_OK;
343 HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel)
345 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
347 FIXME("(%p, %ld, %p, %p, %p): stub\n", This, dwPChannel, ppPort, pdwGroup, pdwMChannel);
349 return S_OK;
352 HRESULT WINAPI IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicInstrument* pInst, DWORD dwPChannel, IDirectMusicDownloadedInstrument** ppDownInst, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel)
354 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
356 FIXME("(%p, %p, %ld, %p, %p, %ld, %p, %p, %p): stub\n", This, pInst, dwPChannel, ppDownInst, pNoteRanges, dwNumNoteRanges, ppPort, pdwGroup, pdwMChannel);
358 return S_OK;
361 HRESULT WINAPI IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DWORD dwFlags)
363 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
365 FIXME("(%p, %ld, %ld): stub\n", This, mtTime, dwFlags);
367 return S_OK;
370 HRESULT WINAPI IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam)
372 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
374 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_guid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
376 return S_OK;
379 HRESULT WINAPI IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam)
381 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
383 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This, debugstr_guid(rguidType), dwGroupBits, dwIndex, mtTime, pParam);
385 return S_OK;
388 HRESULT WINAPI IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize)
390 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
392 TRACE("(%p, %s, %p, %ld): stub\n", This, debugstr_guid(rguidType), pParam, dwSize);
394 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload))
395 memcpy(pParam, &This->fAutoDownload, sizeof(&This->fAutoDownload));
396 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel))
397 memcpy(pParam, &This->cMasterGrooveLevel, sizeof(&This->cMasterGrooveLevel));
398 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo))
399 memcpy(pParam, &This->fMasterTempo, sizeof(&This->fMasterTempo));
400 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume))
401 memcpy(pParam, &This->lMasterVolume, sizeof(&This->lMasterVolume));
403 return S_OK;
406 HRESULT WINAPI IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize)
408 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
410 TRACE("(%p, %s, %p, %ld)\n", This, debugstr_guid(rguidType), pParam, dwSize);
412 if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload)) {
413 memcpy(&This->fAutoDownload, pParam, dwSize);
414 TRACE("=> AutoDownload set to %d\n", This->fAutoDownload);
416 if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel)) {
417 memcpy(&This->cMasterGrooveLevel, pParam, dwSize);
418 TRACE("=> MasterGrooveLevel set to %i\n", This->cMasterGrooveLevel);
420 if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo)) {
421 memcpy(&This->fMasterTempo, pParam, dwSize);
422 TRACE("=> MasterTempo set to %f\n", This->fMasterTempo);
424 if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume)) {
425 memcpy(&This->lMasterVolume, pParam, dwSize);
426 TRACE("=> MasterVolume set to %li\n", This->lMasterVolume);
429 return S_OK;
432 HRESULT WINAPI IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime)
434 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
436 FIXME("(%p, %p): stub\n", This, prtTime);
438 return S_OK;
441 HRESULT WINAPI IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime)
443 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
445 FIXME("(%p, %p): stub\n", This, prtTime);
447 return S_OK;
450 HRESULT WINAPI IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtAmount)
452 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
454 FIXME("(%p, %lli): stub\n", This, rtAmount);
456 return S_OK;
459 HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface)
461 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
463 FIXME("(%p): stub\n", This);
465 return S_OK;
468 HRESULT WINAPI IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, REFERENCE_TIME* prtResolved, DWORD dwTimeResolveFlags)
470 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
472 FIXME("(%p, %lli, %p, %ld): stub\n", This, rtTime, prtResolved, dwTimeResolveFlags);
474 return S_OK;
477 HRESULT WINAPI IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface, BYTE bMIDIValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, WORD* pwMusicValue)
479 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
481 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, bMIDIValue, pChord, bPlayMode, bChordLevel, pwMusicValue);
483 return S_OK;
486 HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMusicValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, BYTE* pbMIDIValue)
488 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
490 FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, wMusicValue, pChord, bPlayMode, bChordLevel, pbMIDIValue);
492 return S_OK;
495 HRESULT WINAPI IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DMUS_TIMESIGNATURE* pTimeSig, WORD* pwMeasure, BYTE* pbBeat, BYTE* pbGrid, short* pnOffset)
497 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
499 FIXME("(%p, %ld, %p, %p, %p, %p, %p): stub\n", This, mtTime, pTimeSig, pwMeasure, pbBeat, pbGrid, pnOffset);
501 return S_OK;
504 HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMeasure, BYTE bBeat, BYTE bGrid, short nOffset, DMUS_TIMESIGNATURE* pTimeSig, MUSIC_TIME* pmtTime)
506 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
508 FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This, wMeasure, bBeat, bGrid, nOffset, pTimeSig, pmtTime);
510 return S_OK;
513 /* IDirectMusicPerformance8 Interface part follow: */
514 HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 iface,
515 IDirectMusic** ppDirectMusic,
516 IDirectSound** ppDirectSound,
517 HWND hWnd,
518 DWORD dwDefaultPathType,
519 DWORD dwPChannelCount,
520 DWORD dwFlags,
521 DMUS_AUDIOPARAMS* pParams)
523 IDirectSound* dsound;
525 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
526 FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
528 if (This->pDirectMusic || This->pDirectSound)
529 return DMUS_E_ALREADY_INITED;
531 if (NULL != ppDirectSound && NULL != *ppDirectSound) {
532 dsound = *ppDirectSound;
533 } else {
534 DirectSoundCreate8 (&IID_IDirectSound8, (LPDIRECTSOUND8*) &dsound, NULL);
535 if (!dsound)
536 return DSERR_NODRIVER;
537 if (ppDirectSound)
538 *ppDirectSound = dsound;
541 IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, dsound, hWnd);
543 /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
544 if (!ppDirectSound)
545 IDirectSound_Release(This->pDirectSound);
547 /* as seen in msdn we need params init before audio path creation */
548 if (NULL != pParams) {
549 memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS));
550 } else {
551 /* TODO, how can i fill the struct */
553 IDirectMusicPerformance8ImplCreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath);
555 return S_OK;
558 HRESULT WINAPI IDirectMusicPerformance8ImplPlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath)
560 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
562 FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This, pSource, pwzSegmentName, pTransition, dwFlags, i64StartTime, ppSegmentState, pFrom, pAudioPath);
564 return S_OK;
567 HRESULT WINAPI IDirectMusicPerformance8ImplStopEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pObjectToStop, __int64 i64StopTime, DWORD dwFlags)
569 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
571 FIXME("(%p, %p, %lli, %ld): stub\n", This, pObjectToStop, i64StopTime, dwFlags);
573 return S_OK;
576 HRESULT WINAPI IDirectMusicPerformance8ImplClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pSourcePMSG, DMUS_PMSG** ppCopyPMSG)
578 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
580 FIXME("(%p, %p, %p): stub\n", This, pSourcePMSG, ppCopyPMSG);
582 return S_OK;
585 HRESULT WINAPI IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSourceConfig, BOOL fActivate, IDirectMusicAudioPath** ppNewPath)
587 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
589 FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ppNewPath);
591 return S_OK;
594 HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath)
596 IDirectMusicAudioPathImpl *default_path;
597 DSBUFFERDESC desc;
598 WAVEFORMATEX format;
599 LPDIRECTSOUNDBUFFER8 buffer;
601 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
603 FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
605 default_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl));
606 if (NULL == default_path) {
607 *ppNewPath = (LPDIRECTMUSICAUDIOPATH) NULL;
608 return E_OUTOFMEMORY;
610 default_path->lpVtbl = &DirectMusicAudioPath_Vtbl;
611 default_path->ref = 1;
612 default_path->pPerf = (IDirectMusicPerformance8*) This;
614 /* Secondary buffer description */
615 format.wFormatTag = WAVE_FORMAT_PCM;
616 format.nChannels = 1;
617 format.nSamplesPerSec = 44000;
618 format.nAvgBytesPerSec = 44000*2;
619 format.nBlockAlign = 2;
620 format.wBitsPerSample = 16;
621 format.cbSize = 0;
623 desc.dwSize = sizeof(desc);
624 desc.dwFlags = 0;
625 desc.dwBufferBytes = DSBSIZE_MIN;
626 desc.dwReserved = 0;
627 desc.lpwfxFormat = &format;
628 desc.guid3DAlgorithm = GUID_NULL;
630 switch(dwType) {
631 case DMUS_APATH_DYNAMIC_3D:
632 desc.dwFlags |= DSBCAPS_CTRL3D;
633 break;
634 case DMUS_APATH_DYNAMIC_MONO:
635 break;
636 case DMUS_APATH_SHARED_STEREOPLUSREVERB:
637 case DMUS_APATH_DYNAMIC_STEREO:
638 format.nChannels = 2;
639 format.nBlockAlign *= 2;
640 format.nAvgBytesPerSec *=2;
641 break;
642 default:
643 break;
646 /* FIXME: Should we create one secondary buffer for each PChannel? */
647 IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
648 default_path->pDSBuffer = (IDirectSoundBuffer*) buffer;
650 /* Update description for creating primary buffer */
651 desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
652 desc.dwBufferBytes = 0;
653 desc.lpwfxFormat = NULL;
655 IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
657 default_path->pPrimary = (IDirectSoundBuffer*) buffer;
659 *ppNewPath = (LPDIRECTMUSICAUDIOPATH) default_path;
661 TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath);
663 return S_OK;
666 HRESULT WINAPI IDirectMusicPerformance8ImplSetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath)
668 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
670 FIXME("(%p, %p): semi-stub\n", This, pAudioPath);
671 if (NULL != This->pDefaultPath) {
672 IDirectMusicAudioPathImpl_Release((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
673 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = NULL;
674 This->pDefaultPath = NULL;
676 This->pDefaultPath = pAudioPath;
677 if (NULL != This->pDefaultPath) {
678 IDirectMusicAudioPathImpl_AddRef((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
679 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = (IDirectMusicPerformance8*) This;
682 return S_OK;
685 HRESULT WINAPI IDirectMusicPerformance8ImplGetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath** ppAudioPath)
687 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
689 FIXME("(%p, %p): semi-stub\n", This, ppAudioPath);
691 if (NULL != This->pDefaultPath) {
692 *ppAudioPath = (LPDIRECTMUSICAUDIOPATH) This->pDefaultPath;
693 IDirectMusicAudioPathImpl_AddRef(*ppAudioPath);
694 } else {
695 *ppAudioPath = NULL;
697 return S_OK;
700 HRESULT WINAPI IDirectMusicPerformance8ImplGetParamEx (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam)
702 ICOM_THIS(IDirectMusicPerformance8Impl,iface);
704 FIXME("(%p, %s, %ld, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_guid(rguidType), dwTrackID, dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
706 return S_OK;
709 ICOM_VTABLE(IDirectMusicPerformance8) DirectMusicPerformance8_Vtbl =
711 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
712 IDirectMusicPerformance8Impl_QueryInterface,
713 IDirectMusicPerformance8Impl_AddRef,
714 IDirectMusicPerformance8Impl_Release,
715 IDirectMusicPerformance8Impl_Init,
716 IDirectMusicPerformance8Impl_PlaySegment,
717 IDirectMusicPerformance8Impl_Stop,
718 IDirectMusicPerformance8Impl_GetSegmentState,
719 IDirectMusicPerformance8Impl_SetPrepareTime,
720 IDirectMusicPerformance8Impl_GetPrepareTime,
721 IDirectMusicPerformance8Impl_SetBumperLength,
722 IDirectMusicPerformance8Impl_GetBumperLength,
723 IDirectMusicPerformance8Impl_SendPMsg,
724 IDirectMusicPerformance8Impl_MusicToReferenceTime,
725 IDirectMusicPerformance8Impl_ReferenceToMusicTime,
726 IDirectMusicPerformance8Impl_IsPlaying,
727 IDirectMusicPerformance8Impl_GetTime,
728 IDirectMusicPerformance8Impl_AllocPMsg,
729 IDirectMusicPerformance8Impl_FreePMsg,
730 IDirectMusicPerformance8Impl_GetGraph,
731 IDirectMusicPerformance8Impl_SetGraph,
732 IDirectMusicPerformance8Impl_SetNotificationHandle,
733 IDirectMusicPerformance8Impl_GetNotificationPMsg,
734 IDirectMusicPerformance8Impl_AddNotificationType,
735 IDirectMusicPerformance8Impl_RemoveNotificationType,
736 IDirectMusicPerformance8Impl_AddPort,
737 IDirectMusicPerformance8Impl_RemovePort,
738 IDirectMusicPerformance8Impl_AssignPChannelBlock,
739 IDirectMusicPerformance8Impl_AssignPChannel,
740 IDirectMusicPerformance8Impl_PChannelInfo,
741 IDirectMusicPerformance8Impl_DownloadInstrument,
742 IDirectMusicPerformance8Impl_Invalidate,
743 IDirectMusicPerformance8Impl_GetParam,
744 IDirectMusicPerformance8Impl_SetParam,
745 IDirectMusicPerformance8Impl_GetGlobalParam,
746 IDirectMusicPerformance8Impl_SetGlobalParam,
747 IDirectMusicPerformance8Impl_GetLatencyTime,
748 IDirectMusicPerformance8Impl_GetQueueTime,
749 IDirectMusicPerformance8Impl_AdjustTime,
750 IDirectMusicPerformance8Impl_CloseDown,
751 IDirectMusicPerformance8Impl_GetResolvedTime,
752 IDirectMusicPerformance8Impl_MIDIToMusic,
753 IDirectMusicPerformance8Impl_MusicToMIDI,
754 IDirectMusicPerformance8Impl_TimeToRhythm,
755 IDirectMusicPerformance8Impl_RhythmToTime,
756 IDirectMusicPerformance8ImplInitAudio,
757 IDirectMusicPerformance8ImplPlaySegmentEx,
758 IDirectMusicPerformance8ImplStopEx,
759 IDirectMusicPerformance8ImplClonePMsg,
760 IDirectMusicPerformance8ImplCreateAudioPath,
761 IDirectMusicPerformance8ImplCreateStandardAudioPath,
762 IDirectMusicPerformance8ImplSetDefaultAudioPath,
763 IDirectMusicPerformance8ImplGetDefaultAudioPath,
764 IDirectMusicPerformance8ImplGetParamEx
767 /* for ClassFactory */
768 HRESULT WINAPI DMUSIC_CreateDirectMusicPerformance (LPCGUID lpcGUID, LPDIRECTMUSICPERFORMANCE8 *ppDMPerf, LPUNKNOWN pUnkOuter)
770 IDirectMusicPerformance8Impl *pPerf;
772 TRACE("(%p,%p,%p)\n",lpcGUID, ppDMPerf, pUnkOuter);
773 if (IsEqualIID (lpcGUID, &IID_IDirectMusicPerformance) ||
774 IsEqualIID (lpcGUID, &IID_IDirectMusicPerformance8)) {
775 pPerf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPerformance8Impl));
776 if (NULL == pPerf)
778 *ppDMPerf = (LPDIRECTMUSICPERFORMANCE8)NULL;
779 return E_OUTOFMEMORY;
781 pPerf->lpVtbl = &DirectMusicPerformance8_Vtbl;
782 pPerf->ref = 1;
783 pPerf->pDirectMusic = NULL;
784 pPerf->pDirectSound = NULL;
785 pPerf->pDefaultPath = NULL;
787 *ppDMPerf = (LPDIRECTMUSICPERFORMANCE8) pPerf;
788 return S_OK;
790 WARN("No interface found\n");
792 return E_NOINTERFACE;