- 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.
This commit is contained in:
Raphael Junqueira 2003-10-27 22:08:37 +00:00 committed by Alexandre Julliard
parent 4f20d16596
commit 493660a529
5 changed files with 69 additions and 22 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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