From 2de3cee8eada9fc664e24fa81a538833e12cf900 Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Sun, 6 Aug 2023 01:52:18 -0500 Subject: [PATCH] LibAudio: Disconnect from and unref the PulseAudio context with lock We don't want to pull the stream out from under our PulseAudio main loop, so call these with the lock to ensure that nothing is touching them. The `pa_threaded_mainloop_stop()` call does not require lock as it sets a flag to tell the main loop to exit. --- Userland/Libraries/LibAudio/PulseAudioWrappers.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibAudio/PulseAudioWrappers.cpp b/Userland/Libraries/LibAudio/PulseAudioWrappers.cpp index 2eba33d199..d6c6bb339a 100644 --- a/Userland/Libraries/LibAudio/PulseAudioWrappers.cpp +++ b/Userland/Libraries/LibAudio/PulseAudioWrappers.cpp @@ -105,8 +105,11 @@ PulseAudioContext::PulseAudioContext(pa_threaded_mainloop* main_loop, pa_mainloo PulseAudioContext::~PulseAudioContext() { - pa_context_disconnect(m_context); - pa_context_unref(m_context); + { + auto locker = main_loop_locker(); + pa_context_disconnect(m_context); + pa_context_unref(m_context); + } pa_threaded_mainloop_stop(m_main_loop); pa_threaded_mainloop_free(m_main_loop); }