dmime: Add proper error handling to InitAudio().
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
62bf20783c
commit
3505137d24
|
@ -877,25 +877,23 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio(IDirectMusicPerform
|
||||||
(void **)&This->dmusic);
|
(void **)&This->dmusic);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
if (dmusic)
|
} else {
|
||||||
*dmusic = (IDirectMusic *)This->dmusic;
|
|
||||||
} else
|
|
||||||
This->dmusic = (IDirectMusic8 *)*dmusic;
|
This->dmusic = (IDirectMusic8 *)*dmusic;
|
||||||
if (dmusic)
|
|
||||||
IDirectMusic8_AddRef(This->dmusic);
|
IDirectMusic8_AddRef(This->dmusic);
|
||||||
|
}
|
||||||
|
|
||||||
if (!dsound || !*dsound) {
|
if (!dsound || !*dsound) {
|
||||||
hr = DirectSoundCreate8(NULL, (IDirectSound8 **)&This->dsound, NULL);
|
hr = DirectSoundCreate8(NULL, (IDirectSound8 **)&This->dsound, NULL);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
goto error;
|
||||||
IDirectSound_SetCooperativeLevel(This->dsound, hwnd ? hwnd : GetForegroundWindow(),
|
hr = IDirectSound_SetCooperativeLevel(This->dsound, hwnd ? hwnd : GetForegroundWindow(),
|
||||||
DSSCL_PRIORITY);
|
DSSCL_PRIORITY);
|
||||||
if (dsound)
|
if (FAILED(hr))
|
||||||
*dsound = This->dsound;
|
goto error;
|
||||||
} else
|
} else {
|
||||||
This->dsound = *dsound;
|
This->dsound = *dsound;
|
||||||
if (dsound)
|
|
||||||
IDirectSound_AddRef(This->dsound);
|
IDirectSound_AddRef(This->dsound);
|
||||||
|
}
|
||||||
|
|
||||||
if (!params) {
|
if (!params) {
|
||||||
This->params.dwSize = sizeof(DMUS_AUDIOPARAMS);
|
This->params.dwSize = sizeof(DMUS_AUDIOPARAMS);
|
||||||
|
@ -909,12 +907,34 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio(IDirectMusicPerform
|
||||||
} else
|
} else
|
||||||
This->params = *params;
|
This->params = *params;
|
||||||
|
|
||||||
if (default_path_type)
|
if (default_path_type) {
|
||||||
hr = IDirectMusicPerformance8_CreateStandardAudioPath(iface, default_path_type,
|
hr = IDirectMusicPerformance8_CreateStandardAudioPath(iface, default_path_type,
|
||||||
num_channels, FALSE, &This->pDefaultPath);
|
num_channels, FALSE, &This->pDefaultPath);
|
||||||
|
if (FAILED(hr))
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dsound && !*dsound) {
|
||||||
|
*dsound = This->dsound;
|
||||||
|
IDirectSound_AddRef(*dsound);
|
||||||
|
}
|
||||||
|
if (dmusic && !*dmusic) {
|
||||||
|
*dmusic = (IDirectMusic *)This->dmusic;
|
||||||
|
IDirectMusic_AddRef(*dmusic);
|
||||||
|
}
|
||||||
PostMessageToProcessMsgThread(This, PROCESSMSG_START);
|
PostMessageToProcessMsgThread(This, PROCESSMSG_START);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (This->dsound) {
|
||||||
|
IDirectSound_Release(This->dsound);
|
||||||
|
This->dsound = NULL;
|
||||||
|
}
|
||||||
|
if (This->dmusic) {
|
||||||
|
IDirectMusic8_Release(This->dmusic);
|
||||||
|
This->dmusic = NULL;
|
||||||
|
}
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue