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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user