Explorar el Código

LibAudio: Clear callbacks and disconnect PulseAudioStream in destructor

If we don't clear the callbacks, they may be called after our functions
are deleted.

Disconnecting the stream also doesn't appear to be done automatically
when calling `pa_stream_unref()` for the last time, so let's do that.
Zaggy1024 hace 2 años
padre
commit
515b255fa4
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      Userland/Libraries/LibAudio/PulseAudioWrappers.cpp

+ 7 - 0
Userland/Libraries/LibAudio/PulseAudioWrappers.cpp

@@ -266,11 +266,18 @@ ErrorOr<NonnullRefPtr<PulseAudioStream>> PulseAudioContext::create_stream(Output
         wait_for_signal();
         wait_for_signal();
     }
     }
 
 
+    pa_stream_set_state_callback(stream, nullptr, nullptr);
+
     return stream_wrapper;
     return stream_wrapper;
 }
 }
 
 
 PulseAudioStream::~PulseAudioStream()
 PulseAudioStream::~PulseAudioStream()
 {
 {
+    auto locker = m_context->main_loop_locker();
+    pa_stream_set_write_callback(m_stream, nullptr, nullptr);
+    pa_stream_set_underflow_callback(m_stream, nullptr, nullptr);
+    pa_stream_set_started_callback(m_stream, nullptr, nullptr);
+    pa_stream_disconnect(m_stream);
     pa_stream_unref(m_stream);
     pa_stream_unref(m_stream);
 }
 }