summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-08-05 10:38:25 +0200
committerSergio Ahumada <sergio.ahumada@digia.com>2013-08-05 10:38:25 +0200
commit06eab796bafa48c9e1a7e6c389bec84b8f42bd49 (patch)
tree0db18767a303250e13d8291748595912d73be9e6 /src
parentab29837c0efd4c07e17bbc8a4e49a592218d924a (diff)
parent2838a99c5abc78cb6ff1b4d4c5872ea4ddd5147e (diff)
Merge branch 'stable' into dev
Conflicts: .qmake.conf Change-Id: Id3427cb1a80956ba61373313c21b4b9aa007ea54
Diffstat (limited to 'src')
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.cpp54
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.h1
-rw-r--r--src/multimediawidgets/doc/src/qtmultimediawidgets-index.qdoc1
3 files changed, 47 insertions, 9 deletions
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
index b3318ec94..328a3b0b3 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
@@ -147,9 +147,20 @@ public:
Q_SIGNALS:
void contextReady();
+ void contextFailed();
void volumeChanged();
-private:
+private Q_SLOTS:
+ void onContextFailed()
+ {
+ release();
+
+ // Try to reconnect later
+ QTimer::singleShot(30000, this, SLOT(prepare()));
+
+ emit contextFailed();
+ }
+
void prepare()
{
m_vol = PA_VOLUME_NORM;
@@ -196,12 +207,23 @@ private:
m_prepared = true;
}
+private:
void release()
{
- if (!m_prepared) return;
- pa_context_unref(m_context);
- pa_threaded_mainloop_stop(m_mainLoop);
- pa_threaded_mainloop_free(m_mainLoop);
+ if (!m_prepared)
+ return;
+
+ if (m_context) {
+ pa_context_unref(m_context);
+ m_context = 0;
+ }
+
+ if (m_mainLoop) {
+ pa_threaded_mainloop_stop(m_mainLoop);
+ pa_threaded_mainloop_free(m_mainLoop);
+ m_mainLoop = 0;
+ }
+
m_prepared = false;
}
@@ -221,6 +243,9 @@ private:
#endif
QMetaObject::invokeMethod(self, "contextReady", Qt::QueuedConnection);
break;
+ case PA_CONTEXT_FAILED:
+ QMetaObject::invokeMethod(self, "onContextFailed", Qt::QueuedConnection);
+ break;
default:
break;
}
@@ -511,7 +536,8 @@ void QSoundEffectPrivate::updateVolume()
PulseDaemonLocker locker;
pa_cvolume volume;
volume.channels = m_pulseSpec.channels;
- pa_operation_unref(pa_context_set_sink_input_volume(pulseDaemon()->context(), m_sinkInputId, pulseDaemon()->calcVolume(&volume, m_volume), setvolume_callback, m_ref->getRef()));
+ if (pulseDaemon()->context())
+ pa_operation_unref(pa_context_set_sink_input_volume(pulseDaemon()->context(), m_sinkInputId, pulseDaemon()->calcVolume(&volume, m_volume), setvolume_callback, m_ref->getRef()));
Q_ASSERT(pa_cvolume_valid(&volume));
#ifdef QT_PA_DEBUG
qDebug() << this << "updateVolume =" << pa_cvolume_max(&volume);
@@ -535,7 +561,8 @@ void QSoundEffectPrivate::updateMuted()
if (m_sinkInputId < 0)
return;
PulseDaemonLocker locker;
- pa_operation_unref(pa_context_set_sink_input_mute(pulseDaemon()->context(), m_sinkInputId, m_muted, setmuted_callback, m_ref->getRef()));
+ if (pulseDaemon()->context())
+ pa_operation_unref(pa_context_set_sink_input_mute(pulseDaemon()->context(), m_sinkInputId, m_muted, setmuted_callback, m_ref->getRef()));
#ifdef QT_PA_DEBUG
qDebug() << this << "updateMuted = " << m_muted;
#endif
@@ -705,7 +732,7 @@ void QSoundEffectPrivate::sampleReady()
}
#endif
} else {
- if (pa_context_get_state(pulseDaemon()->context()) != PA_CONTEXT_READY) {
+ if (!pulseDaemon()->context() || pa_context_get_state(pulseDaemon()->context()) != PA_CONTEXT_READY) {
connect(pulseDaemon(), SIGNAL(contextReady()), SLOT(contextReady()));
return;
}
@@ -741,6 +768,7 @@ void QSoundEffectPrivate::unloadPulseStream()
pa_stream_disconnect(m_pulseStream);
pa_stream_unref(m_pulseStream);
disconnect(pulseDaemon(), SIGNAL(volumeChanged()), this, SLOT(updateVolume()));
+ disconnect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed()));
m_pulseStream = 0;
m_reloadCategory = false; // category will be reloaded when we connect anyway
}
@@ -895,6 +923,9 @@ void QSoundEffectPrivate::createPulseStream()
qDebug() << this << "createPulseStream";
#endif
+ if (!pulseDaemon()->context())
+ return;
+
pa_proplist *propList = pa_proplist_new();
if (m_category.isNull()) {
// Meant to be one of the strings "video", "music", "game", "event", "phone", "animation", "production", "a11y", "test"
@@ -906,6 +937,7 @@ void QSoundEffectPrivate::createPulseStream()
pa_proplist_free(propList);
connect(pulseDaemon(), SIGNAL(volumeChanged()), this, SLOT(updateVolume()));
+ connect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed()));
if (stream == 0) {
qWarning("QSoundEffect(pulseaudio): Failed to create stream");
@@ -947,6 +979,12 @@ void QSoundEffectPrivate::contextReady()
createPulseStream();
}
+void QSoundEffectPrivate::contextFailed()
+{
+ unloadPulseStream();
+ connect(pulseDaemon(), SIGNAL(contextReady()), this, SLOT(contextReady()));
+}
+
void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, void *userdata)
{
Q_UNUSED(length);
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.h b/src/multimedia/audio/qsoundeffect_pulse_p.h
index e43bd2fdf..4dc58f0b6 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.h
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.h
@@ -111,6 +111,7 @@ private Q_SLOTS:
void sampleReady();
void uploadSample();
void contextReady();
+ void contextFailed();
void underRun();
void prepare();
void streamReady();
diff --git a/src/multimediawidgets/doc/src/qtmultimediawidgets-index.qdoc b/src/multimediawidgets/doc/src/qtmultimediawidgets-index.qdoc
index 07fa63205..e722f4cb3 100644
--- a/src/multimediawidgets/doc/src/qtmultimediawidgets-index.qdoc
+++ b/src/multimediawidgets/doc/src/qtmultimediawidgets-index.qdoc
@@ -57,7 +57,6 @@ QT += multimediawidgets
\section2 Examples
\list
-\li \l{QML Camera Example}
\li \l{Camera Example}
\li \l{Media Player Example}
\li \l{Video Graphics Item Example}