Clamp volume in QMediaRecorder and QSoundEffect

Change-Id: Ie61c33592873b7e5a2ed1b8ccf3386b20edb2cef
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
This commit is contained in:
Yoann Lopes
2016-07-08 15:28:34 +02:00
parent 81a48edb54
commit 91d12e6242
2 changed files with 4 additions and 6 deletions

View File

@@ -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;

View File

@@ -563,9 +563,11 @@ void QMediaRecorder::setVolume(qreal volume)
{
Q_D(QMediaRecorder);
if (d->control)
if (d->control) {
volume = qMax(qreal(0.0), volume);
d->control->setVolume(volume);
}
}
/*!
Returns a list of supported container formats.