From 34f253e19d5687ccc383c52b5baa6d37ac9d4571 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 13 Dec 2013 15:37:50 +0100 Subject: [PATCH] PulseAudio: fix crash when failing to create a context. Don't try to call a function on a null PulseAudio context. If pa_context_new() fails, we now try again to connect to the pulse audio daemon later. Task-number: QTBUG-35456 Change-Id: I0b848d3f25f57651ab31b9eca7ceb1bc9df2f682 Reviewed-by: Christian Stromme --- src/multimedia/audio/qsoundeffect_pulse_p.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp index 8bac6c99..23e8d727 100644 --- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp +++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp @@ -183,16 +183,17 @@ private Q_SLOTS: lock(); m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtPulseAudio:%1")).arg(::getpid()).toLatin1().constData()); - pa_context_set_state_callback(m_context, context_state_callback, this); - if (m_context == 0) { qWarning("PulseAudioService: Unable to create new pulseaudio context"); pa_threaded_mainloop_unlock(m_mainLoop); pa_threaded_mainloop_free(m_mainLoop); m_mainLoop = 0; + onContextFailed(); return; } + pa_context_set_state_callback(m_context, context_state_callback, this); + 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);