From 0fd995ac8b58b460f0740699cee9a221a66f6b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Mon, 25 Nov 2013 14:17:51 +0100 Subject: 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 --- src/multimedia/audio/qsoundeffect_qaudio_p.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/multimedia/audio/qsoundeffect_qaudio_p.cpp') diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp index 2de1b0067..aed8a7aea 100644 --- a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp +++ b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp @@ -175,20 +175,20 @@ void QSoundEffectPrivate::setLoopCount(int loopCount) d->m_runningCount = loopCount; } -int QSoundEffectPrivate::volume() const +qreal QSoundEffectPrivate::volume() const { if (d->m_audioOutput && !d->m_muted) - return d->m_audioOutput->volume()*100.0f; + return d->m_audioOutput->volume(); return d->m_volume; } -void QSoundEffectPrivate::setVolume(int volume) +void QSoundEffectPrivate::setVolume(qreal volume) { d->m_volume = volume; if (d->m_audioOutput && !d->m_muted) - d->m_audioOutput->setVolume(volume/100.0f); + d->m_audioOutput->setVolume(volume); emit volumeChanged(); } @@ -203,7 +203,7 @@ void QSoundEffectPrivate::setMuted(bool muted) if (muted && d->m_audioOutput) d->m_audioOutput->setVolume(0); else if (!muted && d->m_audioOutput && d->m_muted) - d->m_audioOutput->setVolume(d->m_volume/100.0f); + d->m_audioOutput->setVolume(d->m_volume); d->m_muted = muted; emit mutedChanged(); @@ -314,7 +314,7 @@ PrivateSoundSource::PrivateSoundSource(QSoundEffectPrivate* s): m_audioOutput(0), m_sample(0), m_muted(false), - m_volume(100), + m_volume(1.0), m_sampleReady(false), m_offset(0) { @@ -337,7 +337,7 @@ void PrivateSoundSource::sampleReady() m_audioOutput = new QAudioOutput(m_sample->format()); connect(m_audioOutput,SIGNAL(stateChanged(QAudio::State)), this, SLOT(stateChanged(QAudio::State))); if (!m_muted) - m_audioOutput->setVolume(m_volume/100.0f); + m_audioOutput->setVolume(m_volume); else m_audioOutput->setVolume(0); } -- cgit v1.2.3