From: Rémi Bernon rbernon@codeweavers.com
Final Fantasy VIII does this, more or less, and needs Init to succeed. --- dlls/dmime/tests/dmime.c | 88 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+)
diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index 1266c5d053b..8a7eeea38cb 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -1809,6 +1809,93 @@ static void test_parsedescriptor(void) } }
+static void test_performance_init(void) +{ + DMUS_PORTPARAMS params = + { + .dwSize = sizeof(params), + .dwValidParams = DMUS_PORTPARAMS_EFFECTS, + .dwEffectFlags = 1, + }; + IDirectMusicPerformance8 *performance; + IDirectSound *dsound, *tmp_dsound; + IDirectMusicPort *port; + IDirectMusic *dmusic; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound, (void **)&dsound); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectSound_Initialize(dsound, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectSound_SetCooperativeLevel(dsound, GetDesktopWindow(), DSSCL_PRIORITY); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic, (void **)&dmusic); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusic_CreatePort(dmusic, &CLSID_DirectMusicSynth, ¶ms, &port, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPort_Activate(port, TRUE); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPort_SetNumChannelGroups(port, 1); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicPerformance8, (void **)&performance); + ok(hr == S_OK, "got %#lx\n", hr); + + /* Init with a different dsound succeeds even if port is active already */ + + hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound, (void **)&tmp_dsound); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectSound_Initialize(tmp_dsound, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectSound_SetCooperativeLevel(tmp_dsound, GetDesktopWindow(), DSSCL_PRIORITY); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_Init(performance, &dmusic, tmp_dsound, 0); + todo_wine ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_AddPort(performance, NULL); + todo_wine ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + IDirectSound_Release(tmp_dsound); + + + /* InitAudio also works fine */ + + tmp_dsound = NULL; + hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &tmp_dsound, NULL, + DMUS_APATH_SHARED_STEREOPLUSREVERB, 0, 0, NULL); + todo_wine ok(hr == S_OK, "got %#lx\n", hr); + ok(tmp_dsound != dsound, "got %p\n", tmp_dsound); + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + if (tmp_dsound) IDirectSound_Release(tmp_dsound); + + + /* Init twice fails */ + + hr = IDirectMusicPerformance8_Init(performance, NULL, NULL, 0); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_Init(performance, NULL, NULL, 0); + ok(hr == DMUS_E_ALREADY_INITED, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_InitAudio(performance, NULL, NULL, NULL, 0, 0, 0, NULL); + ok(hr == DMUS_E_ALREADY_INITED, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + + + IDirectMusicPerformance8_Release(performance); + + IDirectMusicPort_Release(port); + IDirectMusic_Release(dmusic); + + IDirectSound_Release(dsound); +} + static void test_performance_tool(void) { IDirectMusicPerformance *performance; @@ -3176,6 +3263,7 @@ START_TEST(dmime) test_segment_param(); test_track(); test_parsedescriptor(); + test_performance_init(); test_performance_tool(); test_performance_graph(); test_performance_time();