瀏覽代碼

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.
Zaggy1024 1 年之前
父節點
當前提交
2de3cee8ea
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      Userland/Libraries/LibAudio/PulseAudioWrappers.cpp

+ 5 - 2
Userland/Libraries/LibAudio/PulseAudioWrappers.cpp

@@ -105,8 +105,11 @@ PulseAudioContext::PulseAudioContext(pa_threaded_mainloop* main_loop, pa_mainloo
 
 
 PulseAudioContext::~PulseAudioContext()
 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_stop(m_main_loop);
     pa_threaded_mainloop_free(m_main_loop);
     pa_threaded_mainloop_free(m_main_loop);
 }
 }