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.
This commit is contained in:
Zaggy1024 2023-08-06 01:55:55 -05:00 committed by Andrew Kaster
parent 2de3cee8ea
commit 515b255fa4

View file

@ -266,11 +266,18 @@ ErrorOr<NonnullRefPtr<PulseAudioStream>> PulseAudioContext::create_stream(Output
wait_for_signal();
}
pa_stream_set_state_callback(stream, nullptr, nullptr);
return stream_wrapper;
}
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);
}