Commit 5644f4e7 authored by David Redondo's avatar David Redondo 🏎
Browse files

Always disconnect streams

When the stream creation is not finished, disconnecting will fail.
We have to defer disconnecting until the stream is ready.
Setting the callbacks to nullptr was treating a symptom, if the
stream is freed they are also unset.
BUG:439347
FIXED-IN:5.22.3


(cherry picked from commit 5a0d555f)
parent dc34b728
......@@ -58,7 +58,17 @@ void QPulseAudio::VolumeMonitor::setTarget(QPulseAudio::VolumeObject *target)
if (m_stream) {
pa_stream_set_read_callback(m_stream, nullptr, nullptr);
pa_stream_set_suspended_callback(m_stream, nullptr, nullptr);
pa_stream_disconnect(m_stream);
if (pa_stream_get_state(m_stream) == PA_STREAM_CREATING) {
pa_stream_set_state_callback(
m_stream,
[](pa_stream *s, void *) {
pa_stream_disconnect(s);
pa_stream_set_state_callback(s, nullptr, nullptr);
},
nullptr);
} else {
pa_stream_disconnect(m_stream);
}
pa_stream_unref(m_stream);
m_stream = nullptr;
Q_EMIT availableChanged();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment