Clamp volume in QMediaRecorder and QSoundEffect
Change-Id: Ie61c33592873b7e5a2ed1b8ccf3386b20edb2cef Reviewed-by: Christian Stromme <christian.stromme@qt.io>
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user