summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@qt.io>2016-07-08 15:28:34 +0200
committerYoann Lopes <yoann.lopes@qt.io>2016-09-27 15:32:24 +0000
commit91d12e6242bac85f0ea59db2d98235792f82dd44 (patch)
treea614e452245314fe3cf226f8a00ccd14d2f94096
parent81a48edb548a9ad86414b3a115d718c932c11058 (diff)
Clamp volume in QMediaRecorder and QSoundEffect
Change-Id: Ie61c33592873b7e5a2ed1b8ccf3386b20edb2cef Reviewed-by: Christian Stromme <christian.stromme@qt.io>
-rw-r--r--src/multimedia/audio/qsoundeffect.cpp6
-rw-r--r--src/multimedia/recording/qmediarecorder.cpp4
2 files changed, 4 insertions, 6 deletions
diff --git a/src/multimedia/audio/qsoundeffect.cpp b/src/multimedia/audio/qsoundeffect.cpp
index 865d4075..61b29411 100644
--- a/src/multimedia/audio/qsoundeffect.cpp
+++ b/src/multimedia/audio/qsoundeffect.cpp
@@ -273,11 +273,7 @@ qreal QSoundEffect::volume() const
*/
void QSoundEffect::setVolume(qreal volume)
{
- if (volume < qreal(0.0) || volume > qreal(1.0)) {
- qWarning("SoundEffect: volume should be between 0.0 and 1.0");
- return;
- }
-
+ volume = qBound(qreal(0.0), volume, qreal(1.0));
if (qFuzzyCompare(d->volume(), volume))
return;
diff --git a/src/multimedia/recording/qmediarecorder.cpp b/src/multimedia/recording/qmediarecorder.cpp
index e1c01e38..1d5d7cb6 100644
--- a/src/multimedia/recording/qmediarecorder.cpp
+++ b/src/multimedia/recording/qmediarecorder.cpp
@@ -563,8 +563,10 @@ void QMediaRecorder::setVolume(qreal volume)
{
Q_D(QMediaRecorder);
- if (d->control)
+ if (d->control) {
+ volume = qMax(qreal(0.0), volume);
d->control->setVolume(volume);
+ }
}
/*!