dmime: Initialize dmusic in InitAudio().

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2017-05-12 16:11:24 +02:00 committed by Alexandre Julliard
parent 3505137d24
commit 14f899317a
2 changed files with 11 additions and 4 deletions

View file

@ -802,6 +802,7 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown(IDirectMusicPerform
This->dsound = NULL;
}
if (This->dmusic) {
IDirectMusic_SetDirectSound(This->dmusic, NULL, NULL);
IDirectMusic8_Release(This->dmusic);
This->dmusic = NULL;
}
@ -895,6 +896,10 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio(IDirectMusicPerform
IDirectSound_AddRef(This->dsound);
}
hr = IDirectMusic8_SetDirectSound(This->dmusic, This->dsound, NULL);
if (FAILED(hr))
goto error;
if (!params) {
This->params.dwSize = sizeof(DMUS_AUDIOPARAMS);
This->params.fInitNow = FALSE;
@ -910,8 +915,10 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio(IDirectMusicPerform
if (default_path_type) {
hr = IDirectMusicPerformance8_CreateStandardAudioPath(iface, default_path_type,
num_channels, FALSE, &This->pDefaultPath);
if (FAILED(hr))
if (FAILED(hr)) {
IDirectMusic8_SetDirectSound(This->dmusic, NULL, NULL);
goto error;
}
}
if (dsound && !*dsound) {

View file

@ -129,7 +129,7 @@ static HRESULT test_InitAudio(void)
hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &dsound, NULL, 0, 64, 0, NULL);
ok(hr == S_OK, "InitAudio failed: %08x\n", hr);
ref = get_refcount(dsound);
todo_wine ok(ref == 3, "dsound ref count got %d expected 3\n", ref);
ok(ref == 3, "dsound ref count got %d expected 3\n", ref);
ref = get_refcount(dmusic);
ok(ref == 2, "dmusic ref count got %d expected 2\n", ref);
destroy_performance(performance, NULL, NULL);
@ -171,7 +171,7 @@ static HRESULT test_InitAudio(void)
hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &dsound, NULL, 0, 64, 0, NULL);
ok(hr == S_OK, "InitAudio failed: %08x\n", hr);
ref = get_refcount(dsound);
ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
ref = get_refcount(dmusic);
ok(ref == 2, "dmusic ref count got %d expected 2\n", ref);
destroy_performance(performance, dmusic, dsound);
@ -185,7 +185,7 @@ static HRESULT test_InitAudio(void)
hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, NULL, NULL, 0, 64, 0, NULL);
ok(hr == S_OK, "InitAudio failed: %08x\n", hr);
ref = get_refcount(dsound);
ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
ref = get_refcount(dmusic);
ok(ref == 2, "dmusic ref count got %d expected 2\n", ref);
destroy_performance(performance, dmusic, dsound);