[PATCH v3 0/1] MR10886: dsound: Remove unused DSOUND_renderers list and lock.
Follow-up to !10735, as suggested by @Mystral. With device sharing removed, the global DSOUND_renderers list is no longer used for lookups. Devices were still added to and removed from the list, but nothing read from it. Remove the list, the critical section protecting it, and the entry field from DirectSoundDevice. -- v3: dsound: Remove unused DSOUND_renderers list and lock. https://gitlab.winehq.org/wine/wine/-/merge_requests/10886
From: Jon Koops <jonkoops@gmail.com> With device sharing removed, the global DSOUND_renderers list is no longer used for lookups. Devices were still added to and removed from the list, but nothing read from it. Remove the list, the critical section protecting it, and the entry field from DirectSoundDevice. Signed-off-by: Jon Koops <jonkoops@gmail.com> --- dlls/dsound/dsound.c | 11 ----------- dlls/dsound/dsound_main.c | 12 ------------ dlls/dsound/dsound_private.h | 4 ---- 3 files changed, 27 deletions(-) diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c index b5c53829a5b..032dff7bc48 100644 --- a/dlls/dsound/dsound.c +++ b/dlls/dsound/dsound.c @@ -203,10 +203,6 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device) if (device->mta_cookie) CoDecrementMTAUsage(device->mta_cookie); - EnterCriticalSection(&DSOUND_renderers_lock); - list_remove(&device->entry); - LeaveCriticalSection(&DSOUND_renderers_lock); - /* It is allowed to release this object even when buffers are playing */ if (device->buffers) { WARN("%d secondary buffers not released\n", device->nrofbuffers); @@ -272,13 +268,10 @@ static HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGU if(FAILED(hr)) return hr; - EnterCriticalSection(&DSOUND_renderers_lock); - hr = DirectSoundDevice_Create(&device); if(FAILED(hr)){ WARN("DirectSoundDevice_Create failed\n"); IMMDevice_Release(mmdevice); - LeaveCriticalSection(&DSOUND_renderers_lock); return hr; } @@ -291,7 +284,6 @@ static HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGU if (FAILED(hr)) { free(device); - LeaveCriticalSection(&DSOUND_renderers_lock); IMMDevice_Release(mmdevice); WARN("DSOUND_ReopenDevice failed: %08lx\n", hr); return hr; @@ -328,9 +320,6 @@ static HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGU SetThreadPriority(device->thread, THREAD_PRIORITY_TIME_CRITICAL); *ppDevice = device; - list_add_tail(&DSOUND_renderers, &device->entry); - - LeaveCriticalSection(&DSOUND_renderers_lock); return hr; } diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index 8936b437ba2..e2b9b81beef 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -63,16 +63,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound); -struct list DSOUND_renderers = LIST_INIT(DSOUND_renderers); -CRITICAL_SECTION DSOUND_renderers_lock; -static CRITICAL_SECTION_DEBUG DSOUND_renderers_lock_debug = -{ - 0, 0, &DSOUND_renderers_lock, - { &DSOUND_renderers_lock_debug.ProcessLocksList, &DSOUND_renderers_lock_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": DSOUND_renderers_lock") } -}; -CRITICAL_SECTION DSOUND_renderers_lock = { &DSOUND_renderers_lock_debug, -1, 0, 0, 0, 0 }; - /* Some applications expect the GUID pointers emitted from DirectSoundCaptureEnumerate to remain * valid at least until the next time DirectSoundCaptureEnumerate is called, so we store them in * these dynamically allocated arrays. */ @@ -789,8 +779,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)hInstDLL, &hInstDLL); break; case DLL_PROCESS_DETACH: - if (lpvReserved) break; - DeleteCriticalSection(&DSOUND_renderers_lock); break; } return TRUE; diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index 75279dacf87..2fc37b0ef7e 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -106,7 +106,6 @@ struct DirectSoundDevice IAudioRenderClient *render; HANDLE sleepev, thread; - struct list entry; }; /* reference counted buffer memory for duplicated buffer memory */ @@ -251,9 +250,6 @@ HRESULT IDirectSoundCaptureImpl_Create(IUnknown *outer_unk, REFIID riid, void ** #define STATE_CAPTURING 2 #define STATE_STOPPING 3 -extern CRITICAL_SECTION DSOUND_renderers_lock; -extern struct list DSOUND_renderers; - extern GUID *DSOUND_renderer_guids; extern GUID *DSOUND_capture_guids; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10886
Jon Koops (@jonkoops) commented about dlls/dsound/dsound_main.c:
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)hInstDLL, &hInstDLL); break; case DLL_PROCESS_DETACH: - if (lpvReserved) break; - DeleteCriticalSection(&DSOUND_renderers_lock);
I removed this code since it is essentially a no-op, however I did not remove the `case` statement (which is also a no-op), because existing code in the project seems to prefer keeping the `DLL_PROCESS_DETACH` case around, even if it doesn't do anything. Let me know if this should be pruned further. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10886#note_139715
participants (2)
-
Jon Koops -
Jon Koops (@jonkoops)