summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2024-03-01 18:56:03 +0100
committerArtem Dyomin <artem.dyomin@qt.io>2024-03-03 17:32:38 +0000
commit9853f5be3891e3fa36a03a469bf70bb8acd96fc3 (patch)
tree311069bdbff6da24524723c3d0c07893b8d33a28 /src/multimedia
parentaf4c7a761f15a211457c27e10ae260d8652a21f9 (diff)
Fix pulse audio sink flakiness
The problem is pulse audio sometimes calls the draining callback after deleting the audiosink, which causes memory corruption. Also, not deleted operation is a memory leak. We have to cancel the draining operation to prevent the callback. Pick-to: 6.7 6.6 6.5 Change-Id: Id0f25034308eb57bae58eb519e8077f0002fcd9d Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/pulseaudio/qpulseaudiosink.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/multimedia/pulseaudio/qpulseaudiosink.cpp b/src/multimedia/pulseaudio/qpulseaudiosink.cpp
index ff526e1b1..53d45e0c3 100644
--- a/src/multimedia/pulseaudio/qpulseaudiosink.cpp
+++ b/src/multimedia/pulseaudio/qpulseaudiosink.cpp
@@ -392,6 +392,10 @@ void QPulseAudioSink::close()
pa_stream_set_overflow_callback(m_stream, nullptr, nullptr);
pa_stream_set_latency_update_callback(m_stream, nullptr, nullptr);
+ if (auto prevOp = exchangeDrainOperation(nullptr))
+ // cancel draining operation to prevent calling draining callback after closing.
+ pa_operation_cancel(prevOp.get());
+
PAOperationUPtr operation(pa_stream_flush(m_stream, outputStreamFlushComplete, nullptr));
pa_stream_disconnect(m_stream);