Fix volume change error on mono stream for soundeffect(pulseaudio)
authorLing Hu <ling.hu@nokia.com>
Wed, 28 Sep 2011 02:15:51 +0000 (12:15 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 17 Nov 2011 05:47:27 +0000 (06:47 +0100)
(Cherry-picked from 663df44fc8563c548c26a7ae21927b09664c28f2)

Change-Id: I005071bc1a8b2eae4d0660042fc8986d61804c47
Reviewed-by: Michael Goddard
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
src/multimedia/effects/qsoundeffect_pulse_p.cpp

index 4570f8f..f2483a9 100644 (file)
@@ -129,8 +129,9 @@ public:
 
     inline pa_cvolume * calcVolume(pa_cvolume *dest, int soundEffectVolume)
     {
-        dest->channels = 2;
-        dest->values[0] = dest->values[1] = m_vol * soundEffectVolume / 100;
+        pa_volume_t v = m_vol * soundEffectVolume / 100;
+        for (int i = 0; i < dest->channels; ++i)
+            dest->values[i] = v;
         return dest;
     }
 
@@ -394,6 +395,7 @@ void QSoundEffectPrivate::updateVolume()
         return;
     PulseDaemonLocker locker;
     pa_cvolume volume;
+    volume.channels = m_pulseSpec.channels;
     pa_operation_unref(pa_context_set_sink_input_volume(daemon()->context(), m_sinkInputId, daemon()->calcVolume(&volume, m_volume), setvolume_callback, this));
     Q_ASSERT(pa_cvolume_valid(&volume));
 #ifdef QT_PA_DEBUG