From: Jon Koops <jonkoops@gmail.com> On Windows, each DirectSoundCreate call returns an IDirectSound object with its own independent primary buffer. Wine reuses a single DirectSoundDevice for all IDirectSound objects targeting the same audio endpoint, causing them to share a primary buffer. This breaks games that use multiple IDirectSound objects with different primary buffer flags. The device reuse was introduced in 2005 (commit a2f1fd3aca4) when dsound talked directly to waveOut, where opening the same hardware device twice would have caused conflicts. In 2011 (commit e786998daff) dsound was reimplemented on WASAPI, but the reuse was carried forward. Since Wine's dsound already uses WASAPI shared mode, which is designed for multiple audio clients on the same endpoint, the reuse is no longer necessary. Remove the device reuse lookup so that each DirectSoundCreate call creates a fresh DirectSoundDevice. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41047 Signed-off-by: Jon Koops <jonkoops@gmail.com> --- dlls/dsound/dsound.c | 17 ----------------- dlls/dsound/tests/dsound.c | 11 +++-------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c index c21090d95e2..b5c53829a5b 100644 --- a/dlls/dsound/dsound.c +++ b/dlls/dsound/dsound.c @@ -187,13 +187,6 @@ static HRESULT DirectSoundDevice_Create(DirectSoundDevice ** ppDevice) return DS_OK; } -static ULONG DirectSoundDevice_AddRef(DirectSoundDevice * device) -{ - ULONG ref = InterlockedIncrement(&(device->ref)); - TRACE("(%p) ref %ld\n", device, ref); - return ref; -} - static ULONG DirectSoundDevice_Release(DirectSoundDevice * device) { HRESULT hr; @@ -281,16 +274,6 @@ static HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGU EnterCriticalSection(&DSOUND_renderers_lock); - LIST_FOR_EACH_ENTRY(device, &DSOUND_renderers, DirectSoundDevice, entry){ - if(IsEqualGUID(&device->guid, &devGUID)){ - IMMDevice_Release(mmdevice); - DirectSoundDevice_AddRef(device); - *ppDevice = device; - LeaveCriticalSection(&DSOUND_renderers_lock); - return DS_OK; - } - } - hr = DirectSoundDevice_Create(&device); if(FAILED(hr)){ WARN("DirectSoundDevice_Create failed\n"); diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c index 4821701353c..d7d90758d13 100644 --- a/dlls/dsound/tests/dsound.c +++ b/dlls/dsound/tests/dsound.c @@ -2248,17 +2248,13 @@ static void test_primary_independent(void) goto RELEASE1; /* 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 */ - todo_wine - { - rc=IDirectSoundBuffer_GetVolume(primary2,&vol); - ok(rc==DS_OK, - "IDirectSoundBuffer_GetVolume(primary2) failed: %08lx\n",rc); - } + rc=IDirectSoundBuffer_GetVolume(primary2,&vol); + ok(rc==DS_OK, + "IDirectSoundBuffer_GetVolume(primary2) failed: %08lx\n",rc); /* Verify dso2's primary buffer has CTRLVOLUME */ ZeroMemory(&bufcaps, sizeof(bufcaps)); @@ -2266,7 +2262,6 @@ static void test_primary_independent(void) rc=IDirectSoundBuffer_GetCaps(primary2,&bufcaps); ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps(primary2) failed: %08lx\n",rc); if (rc==DS_OK) { - todo_wine ok(bufcaps.dwFlags & DSBCAPS_CTRLVOLUME, "primary2 should have DSBCAPS_CTRLVOLUME: %08lx\n",bufcaps.dwFlags); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10735