From 9853f5be3891e3fa36a03a469bf70bb8acd96fc3 Mon Sep 17 00:00:00 2001 From: Artem Dyomin Date: Fri, 1 Mar 2024 18:56:03 +0100 Subject: Fix pulse audio sink flakiness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Qt CI Bot Reviewed-by: Jøger Hansegård --- src/multimedia/pulseaudio/qpulseaudiosink.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/multimedia') 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); -- cgit v1.2.3