-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, With this patch Unreal2 can pass the dmusic init stuff without crashing ;)))) But now it crash in some d3d8 things i better understand :( So, Jason have you finish to fix the DrawPrimitive ? i think it crash because the old code is buggy. Changelog: - Always use of IDirectMusicPerformance8Impl instead of IDirectMusicPerformanceImpl (as the first inherite from the second) - implements many Loader, AudioPath and Performance8 stubs - fix the class factory - more debug traces - for now IDirectMusicLoader8::LoadObjectFromFile return always not supported format - fix the IDirectMusicPerformance8::Init (many crashes) - implementation of IDirectMusicPerformance8InitAudio Todo: - remove all IDirectMusicPerformanceImpl code as it's not used anymore Regards, Raphael -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE+4bsqp7NA3AmQTU4RAhJUAJ9mI8Lvn2xYwndAM52ITwZ8FVhefACgnEW0 Ndl7wS4eC0Pj4YRR4zFEmaU= =pYi8 -----END PGP SIGNATURE-----
Index: dlls/dmusic/dmusic_loader.c =================================================================== RCS file: /home/wine/wine/dlls/dmusic/dmusic_loader.c,v retrieving revision 1.3 diff -u -r1.3 dmusic_loader.c --- dlls/dmusic/dmusic_loader.c 7 Jun 2003 00:39:18 -0000 1.3 +++ dlls/dmusic/dmusic_loader.c 7 Jun 2003 10:12:29 -0000 @@ -24,6 +24,7 @@ #include "winuser.h" #include "wingdi.h" #include "wine/debug.h" +#include "wine/unicode.h" #include "dmusic_private.h" @@ -64,12 +65,13 @@ } /* IDirectMusicLoader Interface follow: */ -HRESULT WINAPI IDirectMusicLoaderImpl_GetObject (LPDIRECTMUSICLOADER iface, LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID*ppv) +HRESULT WINAPI IDirectMusicLoaderImpl_GetObject (LPDIRECTMUSICLOADER iface, LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID* ppv) { ICOM_THIS(IDirectMusicLoaderImpl,iface); FIXME("(%p, %p, %s, %p): stub\n", This, pDesc, debugstr_guid(riid), ppv); + *ppv = NULL; return S_OK; } @@ -84,11 +86,15 @@ HRESULT WINAPI IDirectMusicLoaderImpl_SetSearchDirectory (LPDIRECTMUSICLOADER iface, REFGUID rguidClass, WCHAR* pwzPath, BOOL fClear) { - ICOM_THIS(IDirectMusicLoaderImpl,iface); - - FIXME("(%p, %s, %p, %d): stub\n", This, debugstr_guid(rguidClass), pwzPath, fClear); - - return S_OK; + ICOM_THIS(IDirectMusicLoaderImpl,iface); + + FIXME("(%p, %s, %p, %d): to check\n", This, debugstr_guid(rguidClass), pwzPath, fClear); + + if (0 == strncmpW(This->searchPath, pwzPath, MAX_PATH)) { + return S_FALSE; + } + strncpyW(This->searchPath, pwzPath, MAX_PATH); + return DS_OK; } HRESULT WINAPI IDirectMusicLoaderImpl_ScanDirectory (LPDIRECTMUSICLOADER iface, REFGUID rguidClass, WCHAR* pwzFileExtension, WCHAR* pwzScanFileName) @@ -201,10 +207,11 @@ HRESULT WINAPI IDirectMusicLoader8Impl_GetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID*ppv) { ICOM_THIS(IDirectMusicLoader8Impl,iface); - + FIXME("(%p, %p, %s, %p): stub\n", This, pDesc, debugstr_guid(riid), ppv); - return S_OK; + *ppv = NULL; + return DS_OK; } HRESULT WINAPI IDirectMusicLoader8Impl_SetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc) @@ -220,9 +227,9 @@ { ICOM_THIS(IDirectMusicLoader8Impl,iface); - FIXME("(%p, %s, %p, %d): stub\n", This, debugstr_guid(rguidClass), pwzPath, fClear); + FIXME("(%p, %s, %p, %d): forward to IDirectMusicLoaderImpl::SetSearchDirectory\n", This, debugstr_guid(rguidClass), pwzPath, fClear); - return S_OK; + return IDirectMusicLoaderImpl_SetSearchDirectory((LPDIRECTMUSICLOADER) iface, rguidClass, pwzPath, fClear); } HRESULT WINAPI IDirectMusicLoader8Impl_ScanDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzFileExtension, WCHAR* pwzScanFileName) @@ -296,13 +303,26 @@ return S_OK; } -HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClassID, REFIID iidInterfaceID, WCHAR* pwzFilePath, void** ppObject) +HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface, + REFGUID rguidClassID, + REFIID iidInterfaceID, + WCHAR* pwzFilePath, + void** ppObject) { ICOM_THIS(IDirectMusicLoader8Impl,iface); - FIXME("(%p, %s, %s, %p, %p): stub\n", This, debugstr_guid(rguidClassID), debugstr_guid(iidInterfaceID), pwzFilePath, ppObject); - - return S_OK; + FIXME("(%p, %s, %s, %s, %p): stub\n", This, debugstr_guid(rguidClassID), debugstr_guid(iidInterfaceID), debugstr_w(pwzFilePath), ppObject); + + if (IsEqualGUID(iidInterfaceID, &CLSID_DirectSoundWave)) { + FIXME("wanted 'wav'\n"); + } else if (IsEqualGUID(iidInterfaceID, &CLSID_DirectMusicScript)) { + FIXME("wanted 'spt'\n"); + } else if (IsEqualGUID(iidInterfaceID, &CLSID_DirectMusicContainer)) { + FIXME("wanted 'con'\n"); + } + + /** for now alway return not supported for avoiding futur crash */ + return DMUS_E_LOADER_FORMATNOTSUPPORTED; } ICOM_VTABLE(IDirectMusicLoader8) DirectMusicLoader8_Vtbl = @@ -330,7 +350,8 @@ IDirectMusicLoader8Impl *dmloader8; TRACE("(%p,%p,%p)\n",lpcGUID, ppDMLoad8, pUnkOuter); - if (IsEqualGUID(lpcGUID, &IID_IDirectMusicLoader8)) + if (IsEqualGUID(lpcGUID, &IID_IDirectMusicLoader) + || IsEqualGUID(lpcGUID, &IID_IDirectMusicLoader8)) { dmloader8 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicImpl)); if (NULL == dmloader8) Index: dlls/dmusic/dmusic_main.c =================================================================== RCS file: /home/wine/wine/dlls/dmusic/dmusic_main.c,v retrieving revision 1.4 diff -u -r1.4 dmusic_main.c --- dlls/dmusic/dmusic_main.c 7 Jun 2003 00:39:18 -0000 1.4 +++ dlls/dmusic/dmusic_main.c 7 Jun 2003 10:12:29 -0000 @@ -60,32 +60,30 @@ { ICOM_THIS(IClassFactoryImpl,iface); - TRACE ("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj); - if (IsEqualGUID (&IID_IDirectMusic, riid)) - { - return DMUSIC_CreateDirectMusic (riid, (LPDIRECTMUSIC*)ppobj, pOuter); + TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj); + if (IsEqualGUID (&IID_IDirectMusic, riid)) { + return DMUSIC_CreateDirectMusic (riid, (LPDIRECTMUSIC*) ppobj, pOuter); } - if (IsEqualGUID (&IID_IDirectMusicPerformance, riid)) + if (IsEqualGUID (&IID_IDirectMusicPerformance, riid) || + IsEqualGUID (&IID_IDirectMusicPerformance8, riid)) { - return DMUSIC_CreateDirectMusicPerformance (riid, (LPDIRECTMUSICPERFORMANCE*)ppobj, pOuter); + /*return DMUSIC_CreateDirectMusicPerformance (riid, (LPDIRECTMUSICPERFORMANCE*) ppobj, pOuter);*/ + return DMUSIC_CreateDirectMusicPerformance8(riid, (LPDIRECTMUSICPERFORMANCE8*) ppobj, pOuter); + } - if (IsEqualGUID (&IID_IDirectMusicPerformance8, riid)) - { - return DMUSIC_CreateDirectMusicPerformance8 (riid, (LPDIRECTMUSICPERFORMANCE8*)ppobj, pOuter); + if (IsEqualGUID (&IID_IDirectMusicLoader, riid) || + IsEqualGUID (&IID_IDirectMusicLoader8, riid)) { + return DMUSIC_CreateDirectMusicLoader8(riid, (LPDIRECTMUSICLOADER8*) ppobj, pOuter); } - /*if (IsEqualGUID (&IID_IDirectMusicLoader8, riid)) - { - return DMUSIC_CreateDirectMusicLoader8 (riid, (LPDIRECTMUSICLOADER8*)ppobj, pOuter); - }*/ - WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj); + WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj); return E_NOINTERFACE; } static HRESULT WINAPI DMCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { ICOM_THIS(IClassFactoryImpl,iface); - FIXME("(%p)->(%d),stub!\n",This,dolock); + FIXME("(%p)->(%d),stub!\n", This, dolock); return S_OK; } @@ -141,13 +139,11 @@ HRESULT WINAPI DMUSIC_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); - if (IsEqualCLSID (&IID_IClassFactory, riid)) - { - *ppv = (LPVOID)&DMUSIC_CF; - IClassFactory_AddRef((IClassFactory*)*ppv); - return S_OK; + if (IsEqualCLSID (&IID_IClassFactory, riid)) { + *ppv = (LPVOID) &DMUSIC_CF; + IClassFactory_AddRef((IClassFactory*)*ppv); + return S_OK; } - WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); return CLASS_E_CLASSNOTAVAILABLE; } Index: dlls/dmusic/dmusic_misc.c =================================================================== RCS file: /home/wine/wine/dlls/dmusic/dmusic_misc.c,v retrieving revision 1.2 diff -u -r1.2 dmusic_misc.c --- dlls/dmusic/dmusic_misc.c 7 Jun 2003 00:39:18 -0000 1.2 +++ dlls/dmusic/dmusic_misc.c 7 Jun 2003 10:12:31 -0000 @@ -215,7 +215,65 @@ FIXME("(%p, %ld, %ld, %ld, %s, %d, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_guid(guidObject), dwIndex, debugstr_guid(iidInterface), ppObject); - return S_OK; + switch (dwStage) { + case DMUS_PATH_AUDIOPATH_GRAPH: + { + if (IsEqualGUID(iidInterface, &IID_IDirectMusicGraph)) { + if (NULL == This->toolGraph) { + IDirectMusicGraphImpl* pGraph; + pGraph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl)); + pGraph->lpVtbl = &DirectMusicGraph_Vtbl; + pGraph->ref = 1; + This->toolGraph = (IDirectMusicGraph*) pGraph; + } + *ppObject = (LPDIRECTMUSICGRAPH) This->toolGraph; + IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) *ppObject); + return S_OK; + } + } + break; + + case DMUS_PATH_AUDIOPATH_TOOL: + { + /* TODO */ + } + break; + + case DMUS_PATH_PERFORMANCE: + { + /* TODO check wanted GUID */ + *ppObject = (LPDIRECTMUSICPERFORMANCE) This->perfo; + IDirectMusicPerformanceImpl_AddRef((LPDIRECTMUSICPERFORMANCE) *ppObject); + return S_OK; + } + break; + + case DMUS_PATH_PERFORMANCE_GRAPH: + { + IDirectMusicGraph* pPerfoGraph = NULL; + IDirectMusicPerformanceImpl_GetGraph((LPDIRECTMUSICPERFORMANCE) This->perfo, &pPerfoGraph); + if (NULL == pPerfoGraph) { + IDirectMusicGraphImpl* pGraph = NULL; + pGraph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl)); + pGraph->lpVtbl = &DirectMusicGraph_Vtbl; + pGraph->ref = 1; + IDirectMusicPerformanceImpl_SetGraph((LPDIRECTMUSICPERFORMANCE) This->perfo, pGraph); + /* we need release as SetGraph do an AddRef */ + IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) pGraph); + pPerfoGraph = (LPDIRECTMUSICGRAPH) pGraph; + } + *ppObject = (LPDIRECTMUSICGRAPH) pPerfoGraph; + return S_OK; + } + break; + + case DMUS_PATH_PERFORMANCE_TOOL: + default: + break; + } + + *ppObject = NULL; + return E_INVALIDARG; } HRESULT WINAPI IDirectMusicAudioPathImpl_Activate (LPDIRECTMUSICAUDIOPATH iface, BOOL fActivate) @@ -704,20 +762,66 @@ HRESULT WINAPI IDirectMusicGraphImpl_InsertTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex) { - ICOM_THIS(IDirectMusicGraphImpl,iface); - - FIXME("(%p, %p, %p, %ld, %li): stub\n", This, pTool, pdwPChannels, cPChannels, lIndex); - - return S_OK; + int i; + IDirectMusicToolImpl* p; + IDirectMusicToolImpl* toAdd = (IDirectMusicToolImpl*) pTool; + ICOM_THIS(IDirectMusicGraphImpl,iface); + + FIXME("(%p, %p, %p, %ld, %li): use of pdwPChannels\n", This, pTool, pdwPChannels, cPChannels, lIndex); + + if (0 == This->num_tools) { + This->first = This->last = toAdd; + toAdd->prev = toAdd->next = NULL; + } else if (lIndex == 0 || lIndex <= -This->num_tools) { + This->first->prev = toAdd; + toAdd->next = This->first; + toAdd->prev = NULL; + This->first = toAdd; + } else if (lIndex < 0) { + p = This->last; + for (i = 0; i < -lIndex; ++i) { + p = p->prev; + } + toAdd->next = p->next; + if (p->next) p->next->prev = toAdd; + p->next = toAdd; + toAdd->prev = p; + } else if (lIndex >= This->num_tools) { + This->last->next = toAdd; + toAdd->prev = This->last; + toAdd->next = NULL; + This->last = toAdd; + } else if (lIndex > 0) { + p = This->first; + for (i = 0; i < lIndex; ++i) { + p = p->next; + } + toAdd->prev = p->prev; + if (p->prev) p->prev->next = toAdd; + p->prev = toAdd; + toAdd->next = p; + } + ++This->num_tools; + return DS_OK; } HRESULT WINAPI IDirectMusicGraphImpl_GetTool (LPDIRECTMUSICGRAPH iface, DWORD dwIndex, IDirectMusicTool** ppTool) { - ICOM_THIS(IDirectMusicGraphImpl,iface); - + int i; + IDirectMusicToolImpl* p = NULL; + ICOM_THIS(IDirectMusicGraphImpl,iface); + FIXME("(%p, %ld, %p): stub\n", This, dwIndex, ppTool); - return S_OK; + p = This->first; + for (i = 0; i < dwIndex && i < This->num_tools; ++i) { + p = p->next; + } + *ppTool = (IDirectMusicTool*) p; + if (NULL != *ppTool) { + IDirectMusicToolImpl_AddRef(*ppTool); + } + return DS_OK; } HRESULT WINAPI IDirectMusicGraphImpl_RemoveTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool) Index: dlls/dmusic/dmusic_performance.c =================================================================== RCS file: /home/wine/wine/dlls/dmusic/dmusic_performance.c,v retrieving revision 1.5 diff -u -r1.5 dmusic_performance.c --- dlls/dmusic/dmusic_performance.c 7 Jun 2003 00:39:18 -0000 1.5 +++ dlls/dmusic/dmusic_performance.c 7 Jun 2003 10:12:36 -0000 @@ -70,35 +70,10 @@ HRESULT WINAPI IDirectMusicPerformanceImpl_Init (LPDIRECTMUSICPERFORMANCE iface, IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd) { ICOM_THIS(IDirectMusicPerformanceImpl,iface); - FIXME("(iface = %p, dmusic = %p (*dmusic = %p), dsound = %p, hwnd = %p): semi-stub\n", This, ppDirectMusic, *ppDirectMusic, pDirectSound, hWnd); - /* app creates it's own dmusic object and gives it to performance */ - if (*ppDirectMusic) - { - TRACE("App provides DirectMusic\n"); - /* FIXME: is this correct? */ - memcpy((LPDIRECTMUSIC)This->dmusic, *ppDirectMusic, sizeof(*ppDirectMusic)); - IDirectMusicImpl_AddRef((LPDIRECTMUSIC)This->dmusic); - /* app is supposed to be in charge of everything else */ - return S_OK; - } - /* app allows the performance to initialise itfself and needs a pointer to object*/ - if (!*ppDirectMusic) - { - TRACE("DirectMusic to be created; needed\n"); - if (!This->dmusic) - DMUSIC_CreateDirectMusic(&IID_IDirectMusic, (LPDIRECTMUSIC*)&This->dmusic, NULL); - *ppDirectMusic = (LPDIRECTMUSIC)This->dmusic; - if (*ppDirectMusic) - IDirectMusicImpl_AddRef(*ppDirectMusic); - } - /* app allows the performance to initialise itself and does not need a pointer to object*/ - if (!ppDirectMusic) - { - TRACE("DirectMusic to be created; not needed\n"); - } - - return S_OK; + FIXME("(iface = %p, dmusic = %p (*dmusic = %p), dsound = %p, hwnd = %p): forward to IDirectMusicPerformance8Impl::Init\n", This, ppDirectMusic, *ppDirectMusic, pDirectSound, hWnd); + + return IDirectMusicPerformanceImpl_Init((LPDIRECTMUSICPERFORMANCE) iface, ppDirectMusic, pDirectSound, hWnd); } HRESULT WINAPI IDirectMusicPerformanceImpl_PlaySegment (LPDIRECTMUSICPERFORMANCE iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState) @@ -233,7 +208,7 @@ FIXME("(%p, %p): stub\n", This, ppGraph); - return S_OK; + return IDirectMusicPerformance8Impl_GetGraph((LPDIRECTMUSICPERFORMANCE8) iface, ppGraph); } HRESULT WINAPI IDirectMusicPerformanceImpl_SetGraph (LPDIRECTMUSICPERFORMANCE iface, IDirectMusicGraph* pGraph) @@ -242,7 +217,7 @@ FIXME("(%p, %p): stub\n", This, pGraph); - return S_OK; + return IDirectMusicPerformance8Impl_SetGraph((LPDIRECTMUSICPERFORMANCE8) iface, pGraph); } HRESULT WINAPI IDirectMusicPerformanceImpl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE iface, HANDLE hNotification, REFERENCE_TIME rtMinimum) @@ -303,34 +278,20 @@ HRESULT WINAPI IDirectMusicPerformanceImpl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE iface, DWORD dwBlockNum, IDirectMusicPort* pPort, DWORD dwGroup) { ICOM_THIS(IDirectMusicPerformanceImpl,iface); - int i, j, range /* min value in range */; - - range = 16 * dwBlockNum; - j = 0; - - FIXME("(%p, %ld, %p, %ld): semi-stub\n", This, dwBlockNum, pPort, dwGroup-1); - for (i = range; i < range+16; i++) - { - /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */ - This->PChannel[i].port = pPort; - This->PChannel[i].group = dwGroup - 1; /* first index is always zero */ - This->PChannel[i].channel = j; /* FIXME: should this be assigned? */ - j++; - } - - return S_FALSE; + + FIXME("(%p, %ld, %p, %ld): forward to IDirectMusicPerformance8Impl::AssignPChannelBlock\n", This, dwBlockNum, pPort, dwGroup-1); + + return IDirectMusicPerformance8Impl_AssignPChannelBlock((LPDIRECTMUSICPERFORMANCE8) iface, dwBlockNum, pPort, dwGroup); } -HRESULT WINAPI IDirectMusicPerformanceImpl_AssignPChannel (LPDIRECTMUSICPERFORMANCE iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel) +HRESULT WINAPI IDirectMusicPerformanceImpl_AssignPChannel (LPDIRECTMUSICPERFORMANCE iface, DWORD dwPChannel, + IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel) { ICOM_THIS(IDirectMusicPerformanceImpl,iface); - TRACE("(%p, %ld, %p, %ld, %ld)\n", This, dwPChannel, pPort, dwGroup, dwMChannel); - This->PChannel[dwPChannel].port = pPort; - This->PChannel[dwPChannel].group = dwGroup; - This->PChannel[dwPChannel].channel = dwMChannel; - - return S_OK; + TRACE("(%p, %ld, %p, %ld, %ld): forward to IDirectMusicPerformance8Impl::AssignPChannel\n", This, dwPChannel, pPort, dwGroup, dwMChannel); + + return IDirectMusicPerformance8Impl_AssignPChannel((LPDIRECTMUSICPERFORMANCE8) iface, dwPChannel, pPort, dwGroup, dwMChannel); } HRESULT WINAPI IDirectMusicPerformanceImpl_PChannelInfo (LPDIRECTMUSICPERFORMANCE iface, DWORD dwPChannel, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) @@ -378,52 +339,24 @@ return S_OK; } -HRESULT WINAPI IDirectMusicPerformanceImpl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE iface, REFGUID rguidType, void* pParam, DWORD dwSize) +HRESULT WINAPI IDirectMusicPerformanceImpl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE iface, REFGUID rguidType, + void* pParam, DWORD dwSize) { ICOM_THIS(IDirectMusicPerformanceImpl,iface); - TRACE("(%p, %s, %p, %ld)\n", This, debugstr_guid(rguidType), pParam, dwSize); + TRACE("(%p, %s, %p, %ld): forward to IDirectMusicPerformance8Impl::GetGlobalParam\n", This, debugstr_guid(rguidType), pParam, dwSize); - if (IsEqualGUID(rguidType, &GUID_PerfAutoDownload)) - memcpy(pParam, &This->AutoDownload, sizeof(&This->AutoDownload)); - if (IsEqualGUID(rguidType, &GUID_PerfMasterGrooveLevel)) - memcpy(pParam, &This->MasterGrooveLevel, sizeof(&This->MasterGrooveLevel)); - if (IsEqualGUID(rguidType, &GUID_PerfMasterTempo)) - memcpy(pParam, &This->MasterTempo, sizeof(&This->MasterTempo)); - if (IsEqualGUID(rguidType, &GUID_PerfMasterVolume)) - memcpy(pParam, &This->MasterVolume, sizeof(&This->MasterVolume)); - - return S_OK; + return IDirectMusicPerformance8Impl_GetGlobalParam((LPDIRECTMUSICPERFORMANCE8) iface, rguidType, pParam, dwSize); } -HRESULT WINAPI IDirectMusicPerformanceImpl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE iface, REFGUID rguidType, void* pParam, DWORD dwSize) +HRESULT WINAPI IDirectMusicPerformanceImpl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE iface, REFGUID rguidType, + void* pParam, DWORD dwSize) { ICOM_THIS(IDirectMusicPerformanceImpl,iface); - TRACE("(%p, %s, %p, %ld)\n", This, debugstr_guid(rguidType), pParam, dwSize); - - if (IsEqualGUID(rguidType, &GUID_PerfAutoDownload)) - { - memcpy(&This->AutoDownload, pParam, dwSize); - TRACE("=> AutoDownload set to %d\n", This->AutoDownload); - } - if (IsEqualGUID(rguidType, &GUID_PerfMasterGrooveLevel)) - { - memcpy(&This->MasterGrooveLevel, pParam, dwSize); - TRACE("=> MasterGrooveLevel set to %i\n", This->MasterGrooveLevel); - } - if (IsEqualGUID(rguidType, &GUID_PerfMasterTempo)) - { - memcpy(&This->MasterTempo, pParam, dwSize); - TRACE("=> MasterTempo set to %f\n", This->MasterTempo); - } - if (IsEqualGUID(rguidType, &GUID_PerfMasterVolume)) - { - memcpy(&This->MasterVolume, pParam, dwSize); - TRACE("=> MasterVolume set to %li\n", This->MasterVolume); - } + TRACE("(%p, %s, %p, %ld): forward to IDirectMusicPerformance8Impl::SetGlobalParam\n", This, debugstr_guid(rguidType), pParam, dwSize); - return S_OK; + return IDirectMusicPerformance8Impl_SetGlobalParam((LPDIRECTMUSICPERFORMANCE8) iface, rguidType, pParam, dwSize);; } HRESULT WINAPI IDirectMusicPerformanceImpl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE iface, REFERENCE_TIME* prtTime) @@ -586,7 +519,9 @@ { ICOM_THIS(IDirectMusicPerformance8Impl,iface); - if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicPerformance8)) + if (IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_IDirectMusicPerformance) || + IsEqualGUID(riid, &IID_IDirectMusicPerformance8)) { IDirectMusicPerformance8Impl_AddRef(iface); *ppobj = This; @@ -619,35 +554,40 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd) { ICOM_THIS(IDirectMusicPerformance8Impl,iface); - FIXME("(iface = %p, dmusic = %p (*dmusic = %p), dsound = %p, hwnd = %p): semi-stub\n", This, ppDirectMusic, *ppDirectMusic, pDirectSound, hWnd); - - /* app creates it's own dmusic object and gives it to performance */ - if (*ppDirectMusic) - { - TRACE("App provides DirectMusic\n"); - /* FIXME: is this correct? */ - memcpy((LPDIRECTMUSIC)This->dmusic, *ppDirectMusic, sizeof(*ppDirectMusic)); - IDirectMusicImpl_AddRef((LPDIRECTMUSIC)This->dmusic); - /* app is supposed to be in charge of everything else */ - return S_OK; - } - /* app allows the performance to initialise itfself and needs a pointer to object*/ - if (!*ppDirectMusic) - { - TRACE("DirectMusic to be created; needed\n"); - if (!This->dmusic) - DMUSIC_CreateDirectMusic(&IID_IDirectMusic, (LPDIRECTMUSIC*)&This->dmusic, NULL); - *ppDirectMusic = (LPDIRECTMUSIC)This->dmusic; - if (*ppDirectMusic) - IDirectMusicImpl_AddRef(*ppDirectMusic); + + FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p): forward to IDirectMusicPerformanceImpl::Init\n", This, ppDirectMusic, pDirectSound, hWnd); + + if (NULL != ppDirectMusic) { + /* app creates it's own dmusic object and gives it to performance */ + if (NULL != *ppDirectMusic) { + if (NULL != This->dmusic) { + } + This->dmusic = (IDirectMusic*) *ppDirectMusic; + IDirectMusicImpl_AddRef((LPDIRECTMUSIC) This->dmusic); + } else { /* app allows the performance to initialise itfself and needs a pointer to object*/ + /* maybe IID_IDirectMusic8 must be used here */ + DMUSIC_CreateDirectMusic(&IID_IDirectMusic, (LPDIRECTMUSIC*) &This->dmusic, NULL); + *ppDirectMusic = (LPDIRECTMUSIC) This->dmusic; + if (NULL != *ppDirectMusic) { + IDirectMusic_AddRef(*ppDirectMusic); + } + } + } else { + TRACE("DirectMusic to be created; not needed\n"); } - /* app allows the performance to initialise itself and does not need a pointer to object*/ - if (!ppDirectMusic) - { - TRACE("DirectMusic to be created; not needed\n"); + + if (NULL != pDirectSound) { + if (NULL != This->dsound) { + } + This->dsound = (IDirectSound*) pDirectSound; + IDirectSound_AddRef((LPDIRECTSOUND) This->dsound); + } else { + DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) This->dsound, NULL); } return S_OK; + + } HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState) @@ -778,20 +718,32 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph** ppGraph) { - ICOM_THIS(IDirectMusicPerformance8Impl,iface); + ICOM_THIS(IDirectMusicPerformanceImpl,iface); - FIXME("(%p, %p): stub\n", This, ppGraph); + FIXME("(%p, %p): to check\n", This, ppGraph); - return S_OK; + if (NULL != This->toolGraph) { + *ppGraph = (LPDIRECTMUSICGRAPH) This->toolGraph; + IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) *ppGraph); + } + return DS_OK; } HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph* pGraph) { - ICOM_THIS(IDirectMusicPerformance8Impl,iface); + ICOM_THIS(IDirectMusicPerformanceImpl,iface); - FIXME("(%p, %p): stub\n", This, pGraph); + FIXME("(%p, %p): to check\n", This, pGraph); - return S_OK; + if (NULL != This->toolGraph) { + /* Todo clean buffers and tools before */ + IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) This->toolGraph); + } + This->toolGraph = pGraph; + if (NULL != This->toolGraph) { + IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) This->toolGraph); + } + return DS_OK; } HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface, HANDLE hNotification, REFERENCE_TIME rtMinimum) @@ -850,18 +802,34 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwBlockNum, IDirectMusicPort* pPort, DWORD dwGroup) { + int i, j, range /* min value in range */; ICOM_THIS(IDirectMusicPerformance8Impl,iface); - FIXME("(%p, %ld, %p, %ld): stub\n", This, dwBlockNum, pPort, dwGroup); - - return S_OK; + FIXME("(%p, %ld, %p, %ld): semi-stub\n", This, dwBlockNum, pPort, dwGroup-1); + + range = 16 * dwBlockNum; + j = 0; + + for (i = range; i < range+16; i++) + { + /*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */ + This->PChannel[i].port = pPort; + This->PChannel[i].group = dwGroup - 1; /* first index is always zero */ + This->PChannel[i].channel = j; /* FIXME: should this be assigned? */ + j++; + } + + return S_FALSE; } HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel) { ICOM_THIS(IDirectMusicPerformance8Impl,iface); - FIXME("(%p, %ld, %p, %ld, %ld): stub\n", This, dwPChannel, pPort, dwGroup, dwMChannel); + TRACE("(%p, %ld, %p, %ld, %ld)\n", This, dwPChannel, pPort, dwGroup, dwMChannel); + This->PChannel[dwPChannel].port = pPort; + This->PChannel[dwPChannel].group = dwGroup; + This->PChannel[dwPChannel].channel = dwMChannel; return S_OK; } @@ -915,7 +883,16 @@ { ICOM_THIS(IDirectMusicPerformance8Impl,iface); - FIXME("(%p, %s, %p, %ld): stub\n", This, debugstr_guid(rguidType), pParam, dwSize); + TRACE("(%p, %s, %p, %ld): stub\n", This, debugstr_guid(rguidType), pParam, dwSize); + + if (IsEqualGUID(rguidType, &GUID_PerfAutoDownload)) + memcpy(pParam, &This->AutoDownload, sizeof(&This->AutoDownload)); + if (IsEqualGUID(rguidType, &GUID_PerfMasterGrooveLevel)) + memcpy(pParam, &This->MasterGrooveLevel, sizeof(&This->MasterGrooveLevel)); + if (IsEqualGUID(rguidType, &GUID_PerfMasterTempo)) + memcpy(pParam, &This->MasterTempo, sizeof(&This->MasterTempo)); + if (IsEqualGUID(rguidType, &GUID_PerfMasterVolume)) + memcpy(pParam, &This->MasterVolume, sizeof(&This->MasterVolume)); return S_OK; } @@ -924,7 +901,28 @@ { ICOM_THIS(IDirectMusicPerformance8Impl,iface); - FIXME("(%p, %s, %p, %ld): stub\n", This, debugstr_guid(rguidType), pParam, dwSize); + TRACE("(%p, %s, %p, %ld)\n", This, debugstr_guid(rguidType), pParam, dwSize); + + if (IsEqualGUID(rguidType, &GUID_PerfAutoDownload)) + { + memcpy(&This->AutoDownload, pParam, dwSize); + TRACE("=> AutoDownload set to %d\n", This->AutoDownload); + } + if (IsEqualGUID(rguidType, &GUID_PerfMasterGrooveLevel)) + { + memcpy(&This->MasterGrooveLevel, pParam, dwSize); + TRACE("=> MasterGrooveLevel set to %i\n", This->MasterGrooveLevel); + } + if (IsEqualGUID(rguidType, &GUID_PerfMasterTempo)) + { + memcpy(&This->MasterTempo, pParam, dwSize); + TRACE("=> MasterTempo set to %f\n", This->MasterTempo); + } + if (IsEqualGUID(rguidType, &GUID_PerfMasterVolume)) + { + memcpy(&This->MasterVolume, pParam, dwSize); + TRACE("=> MasterVolume set to %li\n", This->MasterVolume); + } return S_OK; } @@ -1011,13 +1009,39 @@ } /* IDirectMusicPerformance8 Interface part follow: */ -HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, IDirectSound** ppDirectSound, HWND hWnd, DWORD dwDefaultPathType, DWORD dwPChannelCount, DWORD dwFlags, DMUS_AUDIOPARAMS* pParams) -{ - ICOM_THIS(IDirectMusicPerformance8Impl,iface); - - FIXME("(%p, %p, %p, %p, %ld, %ld, %ld, %p): stub\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams); +HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 iface, + IDirectMusic** ppDirectMusic, + IDirectSound** ppDirectSound, + HWND hWnd, + DWORD dwDefaultPathType, + DWORD dwPChannelCount, + DWORD dwFlags, + DMUS_AUDIOPARAMS* pParams) +{ + ICOM_THIS(IDirectMusicPerformance8Impl,iface); + FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams); + + if (NULL != ppDirectSound && NULL != *ppDirectSound) { + This->dsound = *ppDirectSound; + } else { + This->dsound = NULL; + } + IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, This->dsound, hWnd); + if (NULL != ppDirectSound && NULL == *ppDirectSound) { + *ppDirectSound = (IDirectSound*) This->dsound; + if (NULL != *ppDirectSound) { + IDirectSound_AddRef(*ppDirectSound); + } + } + /* as seen in msdn we need params init before audio path creation */ + if (NULL != pParams) { + memcpy(&This->params, pParams, sizeof(DMUS_AUDIOPARAMS)); + } else { + /* TODO, how can i fill the struct */ + } + IDirectMusicPerformance8ImplCreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->default_path); - return S_OK; + return DS_OK; } HRESULT WINAPI IDirectMusicPerformance8ImplPlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath) @@ -1058,29 +1082,62 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) { - ICOM_THIS(IDirectMusicPerformance8Impl,iface); + IDirectMusicAudioPathImpl* default_path; + ICOM_THIS(IDirectMusicPerformance8Impl,iface); - FIXME("(%p, %ld, %ld, %d, %p): stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath); + FIXME("(%p, %ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath); - return S_OK; + switch (dwType) { + case DMUS_APATH_DYNAMIC_3D: + case DMUS_APATH_DYNAMIC_MONO: + case DMUS_APATH_DYNAMIC_STEREO: + case DMUS_APATH_SHARED_STEREOPLUSREVERB: + break; + default: + break; + } + + default_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl)); + default_path->lpVtbl = &DirectMusicAudioPath_Vtbl; + default_path->ref = 1; + default_path->perfo = (IDirectMusicPerformance*) This; + + *ppNewPath = (IDirectMusicAudioPath*) default_path; + return DS_OK; } HRESULT WINAPI IDirectMusicPerformance8ImplSetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath) { - ICOM_THIS(IDirectMusicPerformance8Impl,iface); + ICOM_THIS(IDirectMusicPerformance8Impl,iface); - FIXME("(%p, %p): stub\n", This, pAudioPath); + FIXME("(%p, %p): semi-stub\n", This, pAudioPath); - return S_OK; + if (NULL != This->default_path) { + IDirectMusicAudioPathImpl_Release((LPDIRECTMUSICAUDIOPATH) This->default_path); + ((IDirectMusicAudioPathImpl*) This->default_path)->perfo = NULL; + This->default_path = NULL; + } + This->default_path = (IDirectMusicAudioPathImpl*) pAudioPath; + if (NULL != This->default_path) { + IDirectMusicAudioPathImpl_AddRef((LPDIRECTMUSICAUDIOPATH) This->default_path); + ((IDirectMusicAudioPathImpl*) This->default_path)->perfo = (IDirectMusicPerformance*) This; + } + return DS_OK; } HRESULT WINAPI IDirectMusicPerformance8ImplGetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath** ppAudioPath) { - ICOM_THIS(IDirectMusicPerformance8Impl,iface); + ICOM_THIS(IDirectMusicPerformance8Impl,iface); - FIXME("(%p, %p): stub\n", This, ppAudioPath); + FIXME("(%p, %p): semi-stub\n", This, ppAudioPath); - return S_OK; + if (NULL != This->default_path) { + *ppAudioPath = (LPDIRECTMUSICAUDIOPATH) This->default_path; + IDirectMusicAudioPathImpl_AddRef(*ppAudioPath); + } else { + *ppAudioPath = NULL; + } + return DS_OK; } HRESULT WINAPI IDirectMusicPerformance8ImplGetParamEx (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) @@ -1166,6 +1223,10 @@ } pPerf8->lpVtbl = &DirectMusicPerformance8_Vtbl; pPerf8->ref = 1; + pPerf8->dmusic = NULL; + pPerf8->dsound = NULL; + pPerf8->default_path = NULL; + *ppDMPerf8 = (LPDIRECTMUSICPERFORMANCE8)pPerf8; return S_OK; } Index: dlls/dmusic/dmusic_private.h =================================================================== RCS file: /home/wine/wine/dlls/dmusic/dmusic_private.h,v retrieving revision 1.7 diff -u -r1.7 dmusic_private.h --- dlls/dmusic/dmusic_private.h 7 Jun 2003 00:39:18 -0000 1.7 +++ dlls/dmusic/dmusic_private.h 7 Jun 2003 10:12:41 -0000 @@ -543,6 +543,8 @@ DWORD ref; /* IDirectMusicToolImpl fields */ + IDirectMusicToolImpl* prev; + IDirectMusicToolImpl* next; }; /* IUnknown: */ @@ -567,6 +569,8 @@ DWORD ref; /* IDirectMusicTool8Impl fields */ + IDirectMusicToolImpl* prev; + IDirectMusicToolImpl* next; }; /* IUnknown: */ @@ -698,6 +702,7 @@ DWORD ref; /* IDirectMusicLoaderImpl fields */ + WCHAR searchPath[MAX_PATH]; }; /* IUnknown: */ @@ -725,6 +730,8 @@ DWORD ref; /* IDirectMusicLoader8Impl fields */ + WCHAR searchPath[MAX_PATH]; + /* IDirectMusicLoader8Impl fields */ }; /* IUnknown: */ @@ -914,6 +921,8 @@ DWORD ref; /* IDirectMusicAudioPathImpl fields */ + IDirectMusicPerformance* perfo; + IDirectMusicGraph* toolGraph; }; /* IUnknown: */ @@ -933,17 +942,19 @@ { /* IUnknown fields */ ICOM_VFIELD(IDirectMusicPerformance); - DWORD ref; + DWORD ref; /* IDirectMusicPerformanceImpl fields */ - IDirectMusicImpl *dmusic; - IDirectSound *dsound; + IDirectMusic* dmusic; + IDirectSound* dsound; + IDirectMusicGraph* toolGraph; + DMUS_AUDIOPARAMS params; /* global parameters */ - BOOL AutoDownload; - char MasterGrooveLevel; + BOOL AutoDownload; + char MasterGrooveLevel; float MasterTempo; - long MasterVolume; + long MasterVolume; /* performance channels */ DMUSIC_PRIVATE_PCHANNEL PChannel[1]; @@ -1005,11 +1016,25 @@ { /* IUnknown fields */ ICOM_VFIELD(IDirectMusicPerformance8); - DWORD ref; + DWORD ref; + + /* IDirectMusicPerformanceImpl fields */ + IDirectMusic* dmusic; + IDirectSound* dsound; + IDirectMusicGraph* toolGraph; + DMUS_AUDIOPARAMS params; + + /* global parameters */ + BOOL AutoDownload; + char MasterGrooveLevel; + float MasterTempo; + long MasterVolume; + + /* performance channels */ + DMUSIC_PRIVATE_PCHANNEL PChannel[1]; - /* IDirectMusicPerformance8Impl fields */ - IDirectMusicImpl *dmusic; - IDirectSound *dsound; + /* IDirectMusicPerformance8Impl fields */ + IDirectMusicAudioPath* default_path; }; /* IUnknown: */ @@ -1081,6 +1106,9 @@ DWORD ref; /* IDirectMusicGraphImpl fields */ + IDirectMusicToolImpl* first; + IDirectMusicToolImpl* last; + WORD num_tools; }; /* IUnknown: */