summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qsoundeffect_pulse_p.cpp
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2012-04-13 13:51:09 +1000
committerQt by Nokia <qt-info@nokia.com>2012-04-16 10:56:34 +0200
commit5f7b64346db43a6aa3ea2bbc15c63d4864f4d005 (patch)
tree845838026bba3e5236999abcab7f0bd9b39d6ec3 /src/multimedia/audio/qsoundeffect_pulse_p.cpp
parent8441d2e32e3bae40640a1584d1d1d1e82980d718 (diff)
Expose the audio category information for streams.
QAudioOutput and QSoundEffect now have a category property so that system volume mixing or processing can be applied. Initially just pulseaudio supports this but Windows Vista etc should also work. Change-Id: I6855b08367e5a055ac7dfcffd644c98bfd7c5a4e Reviewed-by: Ling Hu <ling.hu@nokia.com>
Diffstat (limited to 'src/multimedia/audio/qsoundeffect_pulse_p.cpp')
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.cpp44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
index 609e668fd..3b9278c7d 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
@@ -351,7 +351,8 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
m_volume(100),
m_loopCount(1),
m_runningCount(0),
- m_sample(0) ,
+ m_sample(0),
+ m_reloadCategory(false),
m_position(0)
{
m_ref = new QSoundEffectRef(this);
@@ -373,6 +374,32 @@ void QSoundEffectPrivate::release()
this->deleteLater();
}
+QString QSoundEffectPrivate::category() const
+{
+ return m_category;
+}
+
+void QSoundEffectPrivate::setCategory(const QString &category)
+{
+ if (m_category != category) {
+ m_category = category;
+ if (m_playing || m_playQueued) {
+ // Currently playing, we need to disconnect when
+ // playback stops
+ m_reloadCategory = true;
+ } else if (m_pulseStream) {
+ // We have to disconnect and reconnect
+ unloadPulseStream();
+ createPulseStream();
+ } else {
+ // Well, next time we create the pulse stream
+ // it should be set
+ }
+
+ emit categoryChanged();
+ }
+}
+
QSoundEffectPrivate::~QSoundEffectPrivate()
{
m_ref->release();
@@ -700,6 +727,7 @@ void QSoundEffectPrivate::unloadPulseStream()
pa_stream_unref(m_pulseStream);
disconnect(pulseDaemon(), SIGNAL(volumeChanged()), this, SLOT(updateVolume()));
m_pulseStream = 0;
+ m_reloadCategory = false; // category will be reloaded when we connect anyway
}
}
@@ -808,11 +836,16 @@ void QSoundEffectPrivate::stop()
setPlaying(false);
PulseDaemonLocker locker;
m_stopping = true;
- if (m_pulseStream)
+ if (m_pulseStream) {
emptyStream();
+ if (m_reloadCategory) {
+ unloadPulseStream(); // upon play we reconnect anyway
+ }
+ }
setLoopsRemaining(0);
m_position = 0;
m_playQueued = false;
+ m_reloadCategory = false;
}
void QSoundEffectPrivate::underRun()
@@ -846,7 +879,12 @@ void QSoundEffectPrivate::createPulseStream()
#endif
pa_proplist *propList = pa_proplist_new();
- pa_proplist_sets(propList, PA_PROP_MEDIA_ROLE, "soundeffect");
+ if (m_category.isNull()) {
+ // Meant to be one of the strings "video", "music", "game", "event", "phone", "animation", "production", "a11y", "test"
+ pa_proplist_sets(propList, PA_PROP_MEDIA_ROLE, "game");
+ } else {
+ pa_proplist_sets(propList, PA_PROP_MEDIA_ROLE, m_category.toLatin1().constData());
+ }
pa_stream *stream = pa_stream_new_with_proplist(pulseDaemon()->context(), m_name.constData(), &m_pulseSpec, 0, propList);
pa_proplist_free(propList);