summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qsoundeffect_pulse_p.cpp
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@digia.com>2013-11-25 14:17:51 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-28 14:12:22 +0100
commit0fd995ac8b58b460f0740699cee9a221a66f6b56 (patch)
treee06e560fb8329c7d1726c1c97f6384e1e2567fd6 /src/multimedia/audio/qsoundeffect_pulse_p.cpp
parent1cf737648b2c5cf9636e6be814b4879b67d7e0a0 (diff)
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>
Diffstat (limited to 'src/multimedia/audio/qsoundeffect_pulse_p.cpp')
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
index 328a3b0b3..8bac6c998 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
@@ -382,7 +382,7 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
m_muted(false),
m_playQueued(false),
m_stopping(false),
- m_volume(100),
+ m_volume(1.0),
m_loopCount(1),
m_runningCount(0),
m_reloadCategory(false),
@@ -517,12 +517,12 @@ void QSoundEffectPrivate::setLoopCount(int loopCount)
m_loopCount = loopCount;
}
-int QSoundEffectPrivate::volume() const
+qreal QSoundEffectPrivate::volume() const
{
return m_volume;
}
-void QSoundEffectPrivate::setVolume(int volume)
+void QSoundEffectPrivate::setVolume(qreal volume)
{
m_volume = volume;
emit volumeChanged();
@@ -537,7 +537,7 @@ void QSoundEffectPrivate::updateVolume()
pa_cvolume volume;
volume.channels = m_pulseSpec.channels;
if (pulseDaemon()->context())
- pa_operation_unref(pa_context_set_sink_input_volume(pulseDaemon()->context(), m_sinkInputId, pulseDaemon()->calcVolume(&volume, m_volume), setvolume_callback, m_ref->getRef()));
+ pa_operation_unref(pa_context_set_sink_input_volume(pulseDaemon()->context(), m_sinkInputId, pulseDaemon()->calcVolume(&volume, qRound(m_volume * 100)), setvolume_callback, m_ref->getRef()));
Q_ASSERT(pa_cvolume_valid(&volume));
#ifdef QT_PA_DEBUG
qDebug() << this << "updateVolume =" << pa_cvolume_max(&volume);