Commit 2348e7a0 authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

Make Init and InitAudio return an error when no audio driver is

available. Fix crash in InitAudio when releasing the dsound object.
parent b15ff072
......@@ -80,6 +80,15 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 ifac
if (This->dmusic || This->dsound)
return DMUS_E_ALREADY_INITED;
if (NULL != pDirectSound) {
This->dsound = (IDirectSound*) pDirectSound;
IDirectSound_AddRef((LPDIRECTSOUND) This->dsound);
} else {
DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
if (!This->dsound)
return DSERR_NODRIVER;
}
if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
/* app creates it's own dmusic object and gives it to performance */
This->dmusic = (IDirectMusic8*) *ppDirectMusic;
......@@ -94,12 +103,6 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 ifac
}
}
if (NULL != pDirectSound) {
This->dsound = (IDirectSound*) pDirectSound;
IDirectSound_AddRef((LPDIRECTSOUND) This->dsound);
} else {
DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
}
return S_OK;
}
......@@ -532,6 +535,8 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8
DWORD dwFlags,
DMUS_AUDIOPARAMS* pParams)
{
IDirectSound* dsound;
ICOM_THIS(IDirectMusicPerformance8Impl,iface);
FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
......@@ -539,14 +544,16 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8
return DMUS_E_ALREADY_INITED;
if (NULL != ppDirectSound && NULL != *ppDirectSound) {
This->dsound = *ppDirectSound;
dsound = *ppDirectSound;
} else {
DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &dsound, NULL);
if (!dsound)
return DSERR_NODRIVER;
if (ppDirectSound)
*ppDirectSound = This->dsound;
*ppDirectSound = dsound;
}
IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, This->dsound, hWnd);
IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, dsound, hWnd);
/* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
if (!ppDirectSound)
......
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