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 <christian.stromme@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
e26f5093c6
commit
34f253e19d
@@ -183,16 +183,17 @@ private Q_SLOTS:
|
|||||||
lock();
|
lock();
|
||||||
m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtPulseAudio:%1")).arg(::getpid()).toLatin1().constData());
|
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) {
|
if (m_context == 0) {
|
||||||
qWarning("PulseAudioService: Unable to create new pulseaudio context");
|
qWarning("PulseAudioService: Unable to create new pulseaudio context");
|
||||||
pa_threaded_mainloop_unlock(m_mainLoop);
|
pa_threaded_mainloop_unlock(m_mainLoop);
|
||||||
pa_threaded_mainloop_free(m_mainLoop);
|
pa_threaded_mainloop_free(m_mainLoop);
|
||||||
m_mainLoop = 0;
|
m_mainLoop = 0;
|
||||||
|
onContextFailed();
|
||||||
return;
|
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) {
|
if (pa_context_connect(m_context, 0, (pa_context_flags_t)0, 0) < 0) {
|
||||||
qWarning("PulseAudioService: pa_context_connect() failed");
|
qWarning("PulseAudioService: pa_context_connect() failed");
|
||||||
pa_context_unref(m_context);
|
pa_context_unref(m_context);
|
||||||
|
|||||||
Reference in New Issue
Block a user