From: Jon Koops <jonkoops@gmail.com> On Windows, two separate DirectSoundCreate calls produce independent primary buffers, each with their own capability flags. Test this by creating a primary buffer with DSBCAPS_CTRL3D on one IDirectSound object, then creating a primary buffer with DSBCAPS_CTRLVOLUME on another, and verifying that each buffer retains its own flags and that GetVolume succeeds on the second. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41047 Signed-off-by: Jon Koops <jonkoops@gmail.com> --- dlls/dsound/tests/dsound.c | 56 ++++++++++++++++++++++++++++++++++++ dlls/dsound/tests/dsound8.c | 57 +++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c index a7d6fa0fc3b..9fb46c1fdef 100644 --- a/dlls/dsound/tests/dsound.c +++ b/dlls/dsound/tests/dsound.c @@ -2192,6 +2192,61 @@ static void test_implicit_mta(void) ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type); } +static void test_primary_independent(void) +{ + DSBUFFERDESC bufdesc = {.dwSize = sizeof(bufdesc)}; + IDirectSoundBuffer *primary1, *primary2; + IDirectSound *dso1, *dso2; + DSBCAPS caps; + HRESULT hr; + LONG vol; + + hr = DirectSoundCreate(NULL, &dso1, NULL); + ok(hr == DS_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL, + "DirectSoundCreate() failed: %08lx\n", hr); + if (FAILED(hr)) + return; + + hr = DirectSoundCreate(NULL, &dso2, NULL); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + hr = IDirectSound_SetCooperativeLevel(dso1, get_hwnd(), DSSCL_PRIORITY); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + hr = IDirectSound_SetCooperativeLevel(dso2, get_hwnd(), DSSCL_PRIORITY); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + /* Create a primary buffer on dso1 with CTRL3D but without CTRLVOLUME */ + bufdesc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D; + hr = IDirectSound_CreateSoundBuffer(dso1, &bufdesc, &primary1, NULL); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + /* Create a primary buffer on dso2 with CTRLVOLUME */ + bufdesc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME; + hr = IDirectSound_CreateSoundBuffer(dso2, &bufdesc, &primary2, NULL); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + /* Check whether the two IDirectSound objects share a primary buffer */ + todo_wine ok(primary1 != primary2, + "Two IDirectSound objects should have independent primary buffers\n"); + + /* GetVolume on dso2's primary buffer should succeed */ + hr = IDirectSoundBuffer_GetVolume(primary2, &vol); + todo_wine ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + /* Verify dso2's primary buffer has CTRLVOLUME */ + memset(&caps, 0, sizeof(caps)); + caps.dwSize = sizeof(caps); + hr = IDirectSoundBuffer_GetCaps(primary2, &caps); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + todo_wine ok(caps.dwFlags & DSBCAPS_CTRLVOLUME, "Unexpected dwFlags %#lx.\n", caps.dwFlags); + + IDirectSoundBuffer_Release(primary2); + IDirectSoundBuffer_Release(primary1); + IDirectSound_Release(dso2); + IDirectSound_Release(dso1); +} + START_TEST(dsound) { CoInitialize(NULL); @@ -2201,6 +2256,7 @@ START_TEST(dsound) IDirectSound_tests(); dsound_tests(); test_hw_buffers(); + test_primary_independent(); CoUninitialize(); } diff --git a/dlls/dsound/tests/dsound8.c b/dlls/dsound/tests/dsound8.c index d0e3b4d6a41..ded85c84a3c 100644 --- a/dlls/dsound/tests/dsound8.c +++ b/dlls/dsound/tests/dsound8.c @@ -1931,6 +1931,61 @@ static void test_implicit_mta(void) ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type); } +static void test_primary_independent(void) +{ + DSBUFFERDESC bufdesc = {.dwSize = sizeof(bufdesc)}; + IDirectSoundBuffer *primary1, *primary2; + IDirectSound8 *dso1, *dso2; + DSBCAPS caps; + HRESULT hr; + LONG vol; + + hr = DirectSoundCreate8(NULL, &dso1, NULL); + ok(hr == DS_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL, + "DirectSoundCreate8() failed: %08lx\n", hr); + if (FAILED(hr)) + return; + + hr = DirectSoundCreate8(NULL, &dso2, NULL); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + hr = IDirectSound8_SetCooperativeLevel(dso1, get_hwnd(), DSSCL_PRIORITY); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + hr = IDirectSound8_SetCooperativeLevel(dso2, get_hwnd(), DSSCL_PRIORITY); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + /* Create a primary buffer on dso1 with CTRL3D but without CTRLVOLUME */ + bufdesc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D; + hr = IDirectSound8_CreateSoundBuffer(dso1, &bufdesc, &primary1, NULL); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + /* Create a primary buffer on dso2 with CTRLVOLUME */ + bufdesc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME; + hr = IDirectSound8_CreateSoundBuffer(dso2, &bufdesc, &primary2, NULL); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + /* Check whether the two IDirectSound objects share a primary buffer */ + todo_wine ok(primary1 != primary2, + "Two IDirectSound objects should have independent primary buffers\n"); + + /* GetVolume on dso2's primary buffer should succeed */ + hr = IDirectSoundBuffer_GetVolume(primary2, &vol); + todo_wine ok(hr == DS_OK, "Got hr %#lx.\n", hr); + + /* Verify dso2's primary buffer has CTRLVOLUME */ + memset(&caps, 0, sizeof(caps)); + caps.dwSize = sizeof(caps); + hr = IDirectSoundBuffer_GetCaps(primary2, &caps); + ok(hr == DS_OK, "Got hr %#lx.\n", hr); + todo_wine ok(caps.dwFlags & DSBCAPS_CTRLVOLUME, "Unexpected dwFlags %#lx.\n", caps.dwFlags); + + IDirectSoundBuffer_Release(primary2); + IDirectSoundBuffer_Release(primary1); + IDirectSound8_Release(dso2); + IDirectSound8_Release(dso1); +} + START_TEST(dsound8) { DWORD cookie; @@ -1956,5 +2011,7 @@ START_TEST(dsound8) CoRevokeClassObject(cookie); + test_primary_independent(); + CoUninitialize(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10735