diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index 913c9bc5051..bbb075e8645 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -78,6 +78,17 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 ifac IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound); } else { DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->pDirectSound, NULL); + /** + * as seen in msdn + * + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp + */ + if (NULL != hWnd) { + IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY); + } else { + /* how to get the ForeGround window handle ? */ + /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/ + } if (!This->pDirectSound) return DSERR_NODRIVER; } @@ -88,7 +99,7 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 ifac IDirectMusic8_AddRef((LPDIRECTMUSIC8) This->pDirectMusic); } else { /* app allows the performance to initialise itfself and needs a pointer to object*/ - CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic); + CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic); if (ppDirectMusic) { *ppDirectMusic = (LPDIRECTMUSIC) This->pDirectMusic; IDirectMusic8_AddRef((LPDIRECTMUSIC8) *ppDirectMusic); @@ -523,8 +534,9 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 DMUS_AUDIOPARAMS* pParams) { IDirectSound* dsound; + HRESULT hr = S_OK; - ICOM_THIS(IDirectMusicPerformance8Impl,iface); + 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 (This->pDirectMusic || This->pDirectSound) @@ -550,11 +562,21 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 if (NULL != pParams) { memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS)); } else { - /* TODO, how can i fill the struct */ + /** + * TODO, how can i fill the struct + * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp + */ + This->pParams.dwSize = sizeof(DMUS_AUDIOPARAMS); + This->pParams.fInitNow = FALSE; + This->pParams.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES | DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH; + This->pParams.dwVoices = 64; + This->pParams.dwSampleRate = (DWORD) 22.050; + This->pParams.dwFeatures = dwFlags; + This->pParams.clsidDefaultSynth = CLSID_DirectMusicSynthSink; } - IDirectMusicPerformance8ImplCreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath); + hr = IDirectMusicPerformance8ImplCreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath); - return S_OK; + return hr; } HRESULT WINAPI IDirectMusicPerformance8ImplPlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath) @@ -593,17 +615,24 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORM return S_OK; } +/** + * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp + */ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) { IDirectMusicAudioPathImpl *default_path; DSBUFFERDESC desc; WAVEFORMATEX format; LPDIRECTSOUNDBUFFER8 buffer; + HRESULT hr = S_OK; ICOM_THIS(IDirectMusicPerformance8Impl,iface); FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath); + if (NULL == ppNewPath) { + return E_POINTER; + } default_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl)); if (NULL == default_path) { *ppNewPath = (LPDIRECTMUSICAUDIOPATH) NULL; @@ -623,7 +652,7 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSI format.cbSize = 0; desc.dwSize = sizeof(desc); - desc.dwFlags = 0; + desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS; desc.dwBufferBytes = DSBSIZE_MIN; desc.dwReserved = 0; desc.lpwfxFormat = &format; @@ -631,22 +660,35 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSI switch(dwType) { case DMUS_APATH_DYNAMIC_3D: - desc.dwFlags |= DSBCAPS_CTRL3D; + desc.dwFlags |= DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE; break; case DMUS_APATH_DYNAMIC_MONO: + desc.dwFlags |= DSBCAPS_CTRLFREQUENCY; break; - case DMUS_APATH_SHARED_STEREOPLUSREVERB: + case DMUS_APATH_SHARED_STEREOPLUSREVERB: + /* normally we havet to create 2 buffers (one for music other for reverb) + * in this case. See msdn + */ case DMUS_APATH_DYNAMIC_STEREO: + desc.dwFlags |= DSBCAPS_CTRLFREQUENCY; format.nChannels = 2; format.nBlockAlign *= 2; format.nAvgBytesPerSec *=2; break; default: - break; + HeapFree(GetProcessHeap(), 0, default_path); + *ppNewPath = NULL; + return E_INVALIDARG; + break; } /* FIXME: Should we create one secondary buffer for each PChannel? */ - IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL); + hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL); + if (FAILED(hr)) { + HeapFree(GetProcessHeap(), 0, default_path); + *ppNewPath = NULL; + return DSERR_BUFFERLOST; + } default_path->pDSBuffer = (IDirectSoundBuffer*) buffer; /* Update description for creating primary buffer */ @@ -654,8 +696,13 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSI desc.dwBufferBytes = 0; desc.lpwfxFormat = NULL; - IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL); - + hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL); + if (FAILED(hr)) { + IDirectSoundBuffer_Release(default_path->pDSBuffer); + HeapFree(GetProcessHeap(), 0, default_path); + *ppNewPath = NULL; + return DSERR_BUFFERLOST; + } default_path->pPrimary = (IDirectSoundBuffer*) buffer; *ppNewPath = (LPDIRECTMUSICAUDIOPATH) default_path; diff --git a/dlls/dmloader/container.c b/dlls/dmloader/container.c index dbdaa0e8445..9fd1438e6f1 100644 --- a/dlls/dmloader/container.c +++ b/dlls/dmloader/container.c @@ -86,7 +86,7 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicContainer (LPCGUID lpcGUID, LPDIRECTMUSIC { IDirectMusicContainerImpl* dmcon; - if (IsEqualIID (lpcGUID, &IID_IDirectMusicBand)) { + if (IsEqualIID (lpcGUID, &IID_IDirectMusicContainer)) { dmcon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerImpl)); if (NULL == dmcon) { *ppDMCon = (LPDIRECTMUSICCONTAINER) NULL; diff --git a/dlls/dmloader/loader.c b/dlls/dmloader/loader.c index fd30c1cc38b..3fa1c5e058c 100644 --- a/dlls/dmloader/loader.c +++ b/dlls/dmloader/loader.c @@ -224,7 +224,7 @@ HRESULT WINAPI IDirectMusicLoader8Impl_SetSearchDirectory (LPDIRECTMUSICLOADER8 { ICOM_THIS(IDirectMusicLoader8Impl,iface); - TRACE("(%p, %s, %p, %d)\n", This, debugstr_guid(rguidClass), pwzPath, fClear); + TRACE("(%p, %s, %s, %d)\n", This, debugstr_guid(rguidClass), debugstr_w(pwzPath), fClear); if (0 == strncmpW(This->wzSearchPath, pwzPath, MAX_PATH)) { return S_FALSE; } diff --git a/dlls/dmloader/loaderstream.c b/dlls/dmloader/loaderstream.c index cbc3a6179ee..397baeb9516 100644 --- a/dlls/dmloader/loaderstream.c +++ b/dlls/dmloader/loaderstream.c @@ -37,18 +37,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmloader); */ HRESULT WINAPI ILoaderStream_Attach (ILoaderStream* This, LPCWSTR wzFile, IDirectMusicLoader *pLoader) { - TRACE("(%p, %s, %p)\n", This, debugstr_w(wzFile), pLoader); - ILoaderStream_Detach (This); - This->hFile = CreateFileW (wzFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + TRACE("(%p, %s, %p)\n", This, debugstr_w(wzFile), pLoader); + ILoaderStream_Detach (This); + This->hFile = CreateFileW (wzFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (This->hFile == INVALID_HANDLE_VALUE) { - TRACE(": failed\n"); + TRACE(": failed\n"); return E_FAIL; } - /* create IDirectMusicGetLoader */ - (LPDIRECTMUSICLOADER)This->pLoader = pLoader; + /* create IDirectMusicGetLoader */ + (LPDIRECTMUSICLOADER) This->pLoader = pLoader; strncpyW (This->wzFileName, wzFile, MAX_PATH); - TRACE(": succeeded\n"); - + TRACE(": succeeded\n"); return S_OK; } diff --git a/include/dsound.h b/include/dsound.h index 96da76f6399..82f0e647790 100644 --- a/include/dsound.h +++ b/include/dsound.h @@ -189,6 +189,7 @@ typedef struct _DSCAPS #define DSBCAPS_CTRLPAN 0x00000040 #define DSBCAPS_CTRLVOLUME 0x00000080 #define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 +#define DSBCAPS_CTRLFX 0x00000200 #define DSBCAPS_CTRLDEFAULT 0x000000E0 /* Pan + volume + frequency. */ #define DSBCAPS_CTRLALL 0x000001F0 /* All control capabilities */ #define DSBCAPS_STICKYFOCUS 0x00004000