Commit 493660a5 authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- Some fixes on DirectSound init (need SetCooperativeLevel as seen in

msdn) on IDirectMusicPerformance8::InitAudio. - Some fixes in IDirectMusicPerformance8ImplCreateStandardAudioPath (not perfect yet, need to understand/fix the channel init/use). - Fix typo on CreateDirectMusicContainer. - Add missing define in dsound.h. - Better traces on IDirectMusicLoader8::SetSearchDirectory.
parent 4f20d165
...@@ -78,6 +78,17 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 ifac ...@@ -78,6 +78,17 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 ifac
IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound); IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound);
} else { } else {
DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->pDirectSound, NULL); 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) if (!This->pDirectSound)
return DSERR_NODRIVER; return DSERR_NODRIVER;
} }
...@@ -523,6 +534,7 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 ...@@ -523,6 +534,7 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8
DMUS_AUDIOPARAMS* pParams) DMUS_AUDIOPARAMS* pParams)
{ {
IDirectSound* dsound; 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); FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
...@@ -550,11 +562,21 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 ...@@ -550,11 +562,21 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8
if (NULL != pParams) { if (NULL != pParams) {
memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS)); memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS));
} else { } 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) 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 ...@@ -593,17 +615,24 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORM
return S_OK; 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) HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath)
{ {
IDirectMusicAudioPathImpl *default_path; IDirectMusicAudioPathImpl *default_path;
DSBUFFERDESC desc; DSBUFFERDESC desc;
WAVEFORMATEX format; WAVEFORMATEX format;
LPDIRECTSOUNDBUFFER8 buffer; LPDIRECTSOUNDBUFFER8 buffer;
HRESULT hr = S_OK;
ICOM_THIS(IDirectMusicPerformance8Impl,iface); ICOM_THIS(IDirectMusicPerformance8Impl,iface);
FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath); 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)); default_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl));
if (NULL == default_path) { if (NULL == default_path) {
*ppNewPath = (LPDIRECTMUSICAUDIOPATH) NULL; *ppNewPath = (LPDIRECTMUSICAUDIOPATH) NULL;
...@@ -623,7 +652,7 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSI ...@@ -623,7 +652,7 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSI
format.cbSize = 0; format.cbSize = 0;
desc.dwSize = sizeof(desc); desc.dwSize = sizeof(desc);
desc.dwFlags = 0; desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS;
desc.dwBufferBytes = DSBSIZE_MIN; desc.dwBufferBytes = DSBSIZE_MIN;
desc.dwReserved = 0; desc.dwReserved = 0;
desc.lpwfxFormat = &format; desc.lpwfxFormat = &format;
...@@ -631,22 +660,35 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSI ...@@ -631,22 +660,35 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSI
switch(dwType) { switch(dwType) {
case DMUS_APATH_DYNAMIC_3D: case DMUS_APATH_DYNAMIC_3D:
desc.dwFlags |= DSBCAPS_CTRL3D; desc.dwFlags |= DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE;
break; break;
case DMUS_APATH_DYNAMIC_MONO: case DMUS_APATH_DYNAMIC_MONO:
desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
break; 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: case DMUS_APATH_DYNAMIC_STEREO:
desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
format.nChannels = 2; format.nChannels = 2;
format.nBlockAlign *= 2; format.nBlockAlign *= 2;
format.nAvgBytesPerSec *=2; format.nAvgBytesPerSec *=2;
break; break;
default: default:
HeapFree(GetProcessHeap(), 0, default_path);
*ppNewPath = NULL;
return E_INVALIDARG;
break; break;
} }
/* FIXME: Should we create one secondary buffer for each PChannel? */ /* 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; default_path->pDSBuffer = (IDirectSoundBuffer*) buffer;
/* Update description for creating primary buffer */ /* Update description for creating primary buffer */
...@@ -654,8 +696,13 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSI ...@@ -654,8 +696,13 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSI
desc.dwBufferBytes = 0; desc.dwBufferBytes = 0;
desc.lpwfxFormat = NULL; 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; default_path->pPrimary = (IDirectSoundBuffer*) buffer;
*ppNewPath = (LPDIRECTMUSICAUDIOPATH) default_path; *ppNewPath = (LPDIRECTMUSICAUDIOPATH) default_path;
......
...@@ -86,7 +86,7 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicContainer (LPCGUID lpcGUID, LPDIRECTMUSIC ...@@ -86,7 +86,7 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicContainer (LPCGUID lpcGUID, LPDIRECTMUSIC
{ {
IDirectMusicContainerImpl* dmcon; IDirectMusicContainerImpl* dmcon;
if (IsEqualIID (lpcGUID, &IID_IDirectMusicBand)) { if (IsEqualIID (lpcGUID, &IID_IDirectMusicContainer)) {
dmcon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerImpl)); dmcon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerImpl));
if (NULL == dmcon) { if (NULL == dmcon) {
*ppDMCon = (LPDIRECTMUSICCONTAINER) NULL; *ppDMCon = (LPDIRECTMUSICCONTAINER) NULL;
......
...@@ -224,7 +224,7 @@ HRESULT WINAPI IDirectMusicLoader8Impl_SetSearchDirectory (LPDIRECTMUSICLOADER8 ...@@ -224,7 +224,7 @@ HRESULT WINAPI IDirectMusicLoader8Impl_SetSearchDirectory (LPDIRECTMUSICLOADER8
{ {
ICOM_THIS(IDirectMusicLoader8Impl,iface); 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)) { if (0 == strncmpW(This->wzSearchPath, pwzPath, MAX_PATH)) {
return S_FALSE; return S_FALSE;
} }
......
...@@ -45,10 +45,9 @@ HRESULT WINAPI ILoaderStream_Attach (ILoaderStream* This, LPCWSTR wzFile, IDirec ...@@ -45,10 +45,9 @@ HRESULT WINAPI ILoaderStream_Attach (ILoaderStream* This, LPCWSTR wzFile, IDirec
return E_FAIL; return E_FAIL;
} }
/* create IDirectMusicGetLoader */ /* create IDirectMusicGetLoader */
(LPDIRECTMUSICLOADER)This->pLoader = pLoader; (LPDIRECTMUSICLOADER) This->pLoader = pLoader;
strncpyW (This->wzFileName, wzFile, MAX_PATH); strncpyW (This->wzFileName, wzFile, MAX_PATH);
TRACE(": succeeded\n"); TRACE(": succeeded\n");
return S_OK; return S_OK;
} }
......
...@@ -189,6 +189,7 @@ typedef struct _DSCAPS ...@@ -189,6 +189,7 @@ typedef struct _DSCAPS
#define DSBCAPS_CTRLPAN 0x00000040 #define DSBCAPS_CTRLPAN 0x00000040
#define DSBCAPS_CTRLVOLUME 0x00000080 #define DSBCAPS_CTRLVOLUME 0x00000080
#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 #define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100
#define DSBCAPS_CTRLFX 0x00000200
#define DSBCAPS_CTRLDEFAULT 0x000000E0 /* Pan + volume + frequency. */ #define DSBCAPS_CTRLDEFAULT 0x000000E0 /* Pan + volume + frequency. */
#define DSBCAPS_CTRLALL 0x000001F0 /* All control capabilities */ #define DSBCAPS_CTRLALL 0x000001F0 /* All control capabilities */
#define DSBCAPS_STICKYFOCUS 0x00004000 #define DSBCAPS_STICKYFOCUS 0x00004000
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment