From 91d12e6242bac85f0ea59db2d98235792f82dd44 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 8 Jul 2016 15:28:34 +0200 Subject: Clamp volume in QMediaRecorder and QSoundEffect Change-Id: Ie61c33592873b7e5a2ed1b8ccf3386b20edb2cef Reviewed-by: Christian Stromme --- src/multimedia/audio/qsoundeffect.cpp | 6 +----- src/multimedia/recording/qmediarecorder.cpp | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/multimedia/audio/qsoundeffect.cpp b/src/multimedia/audio/qsoundeffect.cpp index 865d40753..61b294114 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 e1c01e387..1d5d7cb6f 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); + } } /*! -- cgit v1.2.1