Michael Stefaniuc : dmusic/tests: Expand the dsound refcount testing with the port.

Alexandre Julliard julliard at winehq.org
Wed May 10 17:23:17 CDT 2017


Module: wine
Branch: master
Commit: 251d1c0b86c8b26602f97e0ac6a7ee5bcf67f8ba
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=251d1c0b86c8b26602f97e0ac6a7ee5bcf67f8ba

Author: Michael Stefaniuc <mstefani at winehq.org>
Date:   Wed May 10 14:43:58 2017 +0200

dmusic/tests: Expand the dsound refcount testing with the port.

Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dmusic/tests/dmusic.c | 70 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 68 insertions(+), 2 deletions(-)

diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c
index 8473a40..1d1f948 100644
--- a/dlls/dmusic/tests/dmusic.c
+++ b/dlls/dmusic/tests/dmusic.c
@@ -132,9 +132,16 @@ static void test_setdsound(void)
 {
     IDirectMusic *dmusic;
     IDirectSound *dsound, *dsound2;
+    DMUS_PORTPARAMS params;
+    IDirectMusicPort *port = NULL;
     HRESULT hr;
     ULONG ref;
 
+    params.dwSize = sizeof(params);
+    params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS | DMUS_PORTPARAMS_AUDIOCHANNELS;
+    params.dwChannelGroups = 1;
+    params.dwAudioChannels = 2;
+
     /* Old dsound without SetCooperativeLevel() */
     hr = DirectSoundCreate(NULL, &dsound, NULL);
     if (hr == DSERR_NODRIVER ) {
@@ -147,6 +154,9 @@ static void test_setdsound(void)
     ok(hr == S_OK, "DirectMusic create failed: %08x\n", hr);
     hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL);
     ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
+    hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &params, &port, NULL);
+    ok(hr == S_OK, "CreatePort returned: %x\n", hr);
+    IDirectMusicPort_Release(port);
     IDirectMusic_Release(dmusic);
     IDirectSound_Release(dsound);
 
@@ -162,9 +172,23 @@ static void test_setdsound(void)
     ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
     ref = get_refcount(dsound);
     todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
+    hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &params, &port, NULL);
+    ok(hr == S_OK, "CreatePort returned: %x\n", hr);
+    ref = get_refcount(dsound);
+    todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
+    hr = IDirectMusicPort_Activate(port, TRUE);
+    ok(hr == S_OK, "Port Activate returned: %x\n", hr);
+    ref = get_refcount(dsound);
+    todo_wine ok(ref == 4, "dsound ref count got %d expected 4\n", ref);
 
     /* Releasing dsound from dmusic */
     hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL);
+    todo_wine ok(hr == DMUS_E_DSOUND_ALREADY_SET, "SetDirectSound failed: %08x\n", hr);
+    hr = IDirectMusicPort_Activate(port, FALSE);
+    ok(hr == S_OK, "Port Activate returned: %x\n", hr);
+    ref = get_refcount(dsound);
+    todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
+    hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL);
     ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
     ref = get_refcount(dsound);
     ok(ref == 1, "dsound ref count got %d expected 1\n", ref);
@@ -189,9 +213,51 @@ static void test_setdsound(void)
     ref = get_refcount(dsound2);
     todo_wine ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref);
 
+    /* Replacing the dsound in the port */
+    hr = IDirectMusicPort_SetDirectSound(port, dsound, NULL);
+    ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
+    ref = get_refcount(dsound);
+    todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
+    ref = get_refcount(dsound2);
+    todo_wine ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref);
+    /* Setting the dsound again on the port will mess with the parent dmusic */
+    hr = IDirectMusicPort_SetDirectSound(port, dsound, NULL);
+    ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
+    ref = get_refcount(dsound);
+    todo_wine ok(ref == 3, "dsound ref count got %d expected 3\n", ref);
+    ref = get_refcount(dsound2);
+    ok(ref == 1, "dsound2 ref count got %d expected 1\n", ref);
+    IDirectSound_AddRef(dsound2); /* Crash prevention */
+    hr = IDirectMusicPort_Activate(port, TRUE);
+    ok(hr == S_OK, "Activate returned: %x\n", hr);
+    ref = get_refcount(dsound);
+    todo_wine ok(ref == 4, "dsound ref count got %d expected 4\n", ref);
+    ref = get_refcount(dsound2);
+    ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref);
+    hr = IDirectMusicPort_Activate(port, TRUE);
+    todo_wine ok(hr == S_FALSE, "Activate returned: %x\n", hr);
+    ref = get_refcount(dsound);
+    todo_wine ok(ref == 4, "dsound ref count got %d expected 4\n", ref);
+    ref = get_refcount(dsound2);
+    ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref);
+
+    /* Deactivating the port messes with the dsound refcount in the parent dmusic */
+    hr = IDirectMusicPort_Activate(port, FALSE);
+    ok(hr == S_OK, "Port Activate returned: %x\n", hr);
+    ref = get_refcount(dsound);
+    todo_wine ok(ref == 3, "dsound ref count got %d expected 3\n", ref);
+    ref = get_refcount(dsound2);
+    todo_wine ok(ref == 1, "dsound2 ref count got %d expected 1\n", ref);
+    hr = IDirectMusicPort_Activate(port, FALSE);
+    todo_wine ok(hr == S_FALSE, "Port Activate returned: %x\n", hr);
+    ref = get_refcount(dsound);
+    todo_wine ok(ref == 3, "dsound ref count got %d expected 3\n", ref);
+    ref = get_refcount(dsound2);
+    todo_wine ok(ref == 1, "dsound2 ref count got %d expected 1\n", ref);
+
+    IDirectMusicPort_Release(port);
     IDirectMusic_Release(dmusic);
-    IDirectSound_Release(dsound);
-    IDirectSound_Release(dsound2);
+    while (IDirectSound_Release(dsound));
 }
 
 static void test_dmbuffer(void)




More information about the wine-cvs mailing list