From 53538ff9492c5889db3bcbbbe17bc270d1e83cb1 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Wed, 5 Jul 2017 12:45:00 +0200 Subject: PulseAudio: fix a pthread_mutex crash in error path QSoundEffect (pulseaudio) uses a workaround for stability issues: although the pulseaudio mainloop mutex is recursive, it utilizes a separate lock counting. This is not the best solution, but it is a part of a larger set of changes which improved the stability in CI under heavy load. QSoundEffect always calls pa_threaded_mainloop_lock/unlock() from the same thread so the additional lock counting works in normal situation even though it doesn't use atomic types. However if pa_context_connect() fails, pa_threaded_mainloop_unlock() is called without regard to current lock count. This leads to random double-unlock aborts if pa_context_connect() fails more than once (e.g. after the reconnect scheduled from onContextFailed()). Fix this by always using the PulseDaemon wrappers around pa_threaded_mainloop_lock/unlock(). Task-number: QTBUG-61725 Change-Id: I41eb9a76892a6646fd5620ef8f686473b339464f Reviewed-by: Christian Stromme --- src/multimedia/audio/qsoundeffect_pulse_p.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp index 3a3806155..1e9204598 100644 --- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp +++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp @@ -181,7 +181,7 @@ private Q_SLOTS: if (m_context == 0) { qWarning("PulseAudioService: Unable to create new pulseaudio context"); - pa_threaded_mainloop_unlock(m_mainLoop); + unlock(); pa_threaded_mainloop_free(m_mainLoop); m_mainLoop = 0; onContextFailed(); @@ -193,7 +193,7 @@ private Q_SLOTS: if (pa_context_connect(m_context, 0, (pa_context_flags_t)0, 0) < 0) { qWarning("PulseAudioService: pa_context_connect() failed"); pa_context_unref(m_context); - pa_threaded_mainloop_unlock(m_mainLoop); + unlock(); pa_threaded_mainloop_free(m_mainLoop); m_mainLoop = 0; m_context = 0; -- cgit v1.2.1