Don't use integers to describe volume internally in QSoundEffect.
The public api takes floating point values and so does most of the back- ends. Conversion should be done in the back-ends that expect other value types to avoid unnecessary float -> int -> float conversions. Change-Id: I0ee1bfbe350f985294c20f897ffa3bd55288b4c9 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
1cf737648b
commit
0fd995ac8b
@@ -265,7 +265,7 @@ int QSoundEffect::loopsRemaining() const
|
||||
*/
|
||||
qreal QSoundEffect::volume() const
|
||||
{
|
||||
return qreal(d->volume()) / 100;
|
||||
return d->volume();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -273,15 +273,15 @@ qreal QSoundEffect::volume() const
|
||||
*/
|
||||
void QSoundEffect::setVolume(qreal volume)
|
||||
{
|
||||
if (volume < 0 || volume > 1) {
|
||||
if (volume < qreal(0.0) || volume > qreal(1.0)) {
|
||||
qWarning("SoundEffect: volume should be between 0.0 and 1.0");
|
||||
return;
|
||||
}
|
||||
int iVolume = qRound(volume * 100);
|
||||
if (d->volume() == iVolume)
|
||||
|
||||
if (qFuzzyCompare(d->volume(), volume))
|
||||
return;
|
||||
|
||||
d->setVolume(iVolume);
|
||||
d->setVolume(volume);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user