PulseAudio: make plugin more robust.

Handle more thoroughly error cases, such as when the PulseAudio daemon
does not respond or terminates while QAudioInput/QAudioOutput is
active, in which cases it used to crash or hang.

We now correctly emit the error signal and change the state when errors
occur.

Task-number: QTBUG-29742
Change-Id: I173d35aece60d96e578785e1522cf78b24dcb8b8
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
Yoann Lopes
2014-06-12 18:48:15 +02:00
parent 8da61153c9
commit 85f4b8177c
6 changed files with 353 additions and 259 deletions

View File

@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Toolkit.
@@ -74,12 +74,36 @@ public:
pa_threaded_mainloop *mainloop() { return m_mainLoop; }
pa_context *context() { return m_context; }
inline void lock()
{
if (m_mainLoop)
pa_threaded_mainloop_lock(m_mainLoop);
}
inline void unlock()
{
if (m_mainLoop)
pa_threaded_mainloop_unlock(m_mainLoop);
}
inline void wait(pa_operation *op)
{
while (m_mainLoop && pa_operation_get_state(op) == PA_OPERATION_RUNNING)
pa_threaded_mainloop_wait(m_mainLoop);
}
QList<QByteArray> availableDevices(QAudio::Mode mode) const;
Q_SIGNALS:
void contextFailed();
private Q_SLOTS:
void prepare();
void onContextFailed();
private:
void serverInfo();
void sinks();
void sources();
void updateDevices();
void release();
public:
QList<QByteArray> m_sinks;
@@ -93,6 +117,7 @@ private:
pa_mainloop_api *m_mainLoopApi;
pa_threaded_mainloop *m_mainLoop;
pa_context *m_context;
bool m_prepared;
};
QT_END_NAMESPACE