summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qsoundeffect.cpp
diff options
context:
space:
mode:
authorOtto Ryynänen <otto.ryynanen@qt.io>2018-05-23 09:10:34 +0300
committerOtto Ryynänen <otto.ryynanen@qt.io>2018-10-30 09:18:56 +0000
commit3ee6d65377cb563d49d81c3adac0523e4ae8a0b9 (patch)
treed06d1378c5679315aa6e9d53626f14f17341f04f /src/multimedia/audio/qsoundeffect.cpp
parent023c48830386566042497bfac2a01c713bc5423b (diff)
Add a support for selecting the output device used by QSoundEffect
The QSoundEffect can be forced to use a specific audio output device. This is useful on a system with multiple output devices as individual QSoundeffects can use separate output devices. Due to way QAudioOutput (alternate implementation behind QSoundEffect) is implemented, QAudioDeviceInfo is used as a method of defining the output device to be used. Task-number: QTBUG-63596 Change-Id: Ibfb9894fec914726faee4e31c42ab08832693cf6 Reviewed-by: VaL Doroshchuk <valentyn.doroshchuk@qt.io>
Diffstat (limited to 'src/multimedia/audio/qsoundeffect.cpp')
-rw-r--r--src/multimedia/audio/qsoundeffect.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/multimedia/audio/qsoundeffect.cpp b/src/multimedia/audio/qsoundeffect.cpp
index f093373ce..09085dca9 100644
--- a/src/multimedia/audio/qsoundeffect.cpp
+++ b/src/multimedia/audio/qsoundeffect.cpp
@@ -111,20 +111,34 @@ QT_BEGIN_NAMESPACE
sound effects.
*/
+static QSoundEffectPrivate *initPrivate(QSoundEffect *self, QSoundEffectPrivate *d)
+{
+ QObject::connect(d, &QSoundEffectPrivate::loopsRemainingChanged, self, &QSoundEffect::loopsRemainingChanged);
+ QObject::connect(d, &QSoundEffectPrivate::volumeChanged, self, &QSoundEffect::volumeChanged);
+ QObject::connect(d, &QSoundEffectPrivate::mutedChanged, self, &QSoundEffect::mutedChanged);
+ QObject::connect(d, &QSoundEffectPrivate::loadedChanged, self, &QSoundEffect::loadedChanged);
+ QObject::connect(d, &QSoundEffectPrivate::playingChanged, self, &QSoundEffect::playingChanged);
+ QObject::connect(d, &QSoundEffectPrivate::statusChanged, self, &QSoundEffect::statusChanged);
+ QObject::connect(d, &QSoundEffectPrivate::categoryChanged, self, &QSoundEffect::categoryChanged);
+
+ return d;
+}
/*!
Creates a QSoundEffect with the given \a parent.
*/
-QSoundEffect::QSoundEffect(QObject *parent) :
- QObject(parent)
+QSoundEffect::QSoundEffect(QObject *parent)
+ : QObject(parent)
+ , d(initPrivate(this, new QSoundEffectPrivate(this)))
+{
+}
+
+/*!
+ Creates a QSoundEffect with the given \a audioDevice and \a parent.
+*/
+QSoundEffect::QSoundEffect(const QAudioDeviceInfo &audioDevice, QObject *parent)
+ : QObject(parent)
+ , d(initPrivate(this, new QSoundEffectPrivate(audioDevice, this)))
{
- d = new QSoundEffectPrivate(this);
- connect(d, &QSoundEffectPrivate::loopsRemainingChanged, this, &QSoundEffect::loopsRemainingChanged);
- connect(d, &QSoundEffectPrivate::volumeChanged, this, &QSoundEffect::volumeChanged);
- connect(d, &QSoundEffectPrivate::mutedChanged, this, &QSoundEffect::mutedChanged);
- connect(d, &QSoundEffectPrivate::loadedChanged, this, &QSoundEffect::loadedChanged);
- connect(d, &QSoundEffectPrivate::playingChanged, this, &QSoundEffect::playingChanged);
- connect(d, &QSoundEffectPrivate::statusChanged, this, &QSoundEffect::statusChanged);
- connect(d, &QSoundEffectPrivate::categoryChanged, this, &QSoundEffect::categoryChanged);
}
/*!