diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-06-11 14:29:21 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-06-16 10:03:21 +0200 |
commit | ad69da4ee504c4cb6a6a34344c5a80720d6db620 (patch) | |
tree | 0578d2373ee0db1e78a7e359d611cbaef3e752f1 | |
parent | 5ad88be6f078aa16f3d2821a7589c8d1c1a12671 (diff) |
Add a QAudioDevice property to QSoundEffect
Without it, the QML SoundEffect can't target a non default
device.
Change-Id: I114a1e712cdc4ff1bfdc4b131db97cbe4d6eb90f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
-rw-r--r-- | src/multimedia/audio/qsoundeffect.cpp | 14 | ||||
-rw-r--r-- | src/multimedia/audio/qsoundeffect.h | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/multimedia/audio/qsoundeffect.cpp b/src/multimedia/audio/qsoundeffect.cpp index ffd47e28c..80fcef9c6 100644 --- a/src/multimedia/audio/qsoundeffect.cpp +++ b/src/multimedia/audio/qsoundeffect.cpp @@ -483,6 +483,20 @@ void QSoundEffect::setLoopCount(int loopCount) emit loopCountChanged(); } +QAudioDevice QSoundEffect::audioDevice() +{ + return d->m_audioDevice; +} + +void QSoundEffect::setAudioDevice(const QAudioDevice &device) +{ + if (d->m_audioDevice == device) + return; + // ### recreate the QAudioSink if needed + d->m_audioDevice = device; + emit audioDeviceChanged(); +} + /*! \qmlproperty int QtMultimedia::SoundEffect::loopsRemaining diff --git a/src/multimedia/audio/qsoundeffect.h b/src/multimedia/audio/qsoundeffect.h index 60a7323a5..5b806b382 100644 --- a/src/multimedia/audio/qsoundeffect.h +++ b/src/multimedia/audio/qsoundeffect.h @@ -64,6 +64,7 @@ class Q_MULTIMEDIA_EXPORT QSoundEffect : public QObject Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) Q_PROPERTY(bool playing READ isPlaying NOTIFY playingChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) + Q_PROPERTY(QAudioDevice audioDevice READ audioDevice WRITE setAudioDevice NOTIFY audioDeviceChanged) public: enum Loop @@ -94,6 +95,9 @@ public: int loopsRemaining() const; void setLoopCount(int loopCount); + QAudioDevice audioDevice(); + void setAudioDevice(const QAudioDevice &device); + float volume() const; void setVolume(float volume); @@ -114,6 +118,7 @@ Q_SIGNALS: void loadedChanged(); void playingChanged(); void statusChanged(); + void audioDeviceChanged(); public Q_SLOTS: void play(); |