aboutsummaryrefslogtreecommitdiff
path: root/audio/paaudio.c
diff options
context:
space:
mode:
authorKővágó, Zoltán <dirty.ice.hu@gmail.com>2019-10-13 21:58:01 +0200
committerGerd Hoffmann <kraxel@redhat.com>2019-10-18 08:14:05 +0200
commitcecc1e79bf9ad9a0e2d3ce513d4f71792a0985f6 (patch)
treee9f8f7dff995a409a5ec35258b1e013a805c09fb /audio/paaudio.c
parent337e8de6fbaa61b7dd14e6c29836673132891642 (diff)
audio: support more than two channels in volume setting
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 5d3dd2ee3baaa62805e79c3901abb7415ae32461.1570996490.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/paaudio.c')
-rw-r--r--audio/paaudio.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/audio/paaudio.c b/audio/paaudio.c
index 77cd0bc0d0..292c8c9ff4 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -532,20 +532,22 @@ static void qpa_fini_in (HWVoiceIn *hw)
}
}
-static void qpa_volume_out(HWVoiceOut *hw, struct mixeng_volume *vol)
+static void qpa_volume_out(HWVoiceOut *hw, Volume *vol)
{
PAVoiceOut *pa = (PAVoiceOut *) hw;
pa_operation *op;
pa_cvolume v;
PAConnection *c = pa->g->conn;
+ int i;
#ifdef PA_CHECK_VERSION /* macro is present in 0.9.16+ */
pa_cvolume_init (&v); /* function is present in 0.9.13+ */
#endif
- v.channels = 2;
- v.values[0] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->l) / UINT32_MAX;
- v.values[1] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->r) / UINT32_MAX;
+ v.channels = vol->channels;
+ for (i = 0; i < vol->channels; ++i) {
+ v.values[i] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->vol[i]) / 255;
+ }
pa_threaded_mainloop_lock(c->mainloop);
@@ -572,20 +574,22 @@ static void qpa_volume_out(HWVoiceOut *hw, struct mixeng_volume *vol)
pa_threaded_mainloop_unlock(c->mainloop);
}
-static void qpa_volume_in(HWVoiceIn *hw, struct mixeng_volume *vol)
+static void qpa_volume_in(HWVoiceIn *hw, Volume *vol)
{
PAVoiceIn *pa = (PAVoiceIn *) hw;
pa_operation *op;
pa_cvolume v;
PAConnection *c = pa->g->conn;
+ int i;
#ifdef PA_CHECK_VERSION
pa_cvolume_init (&v);
#endif
- v.channels = 2;
- v.values[0] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->l) / UINT32_MAX;
- v.values[1] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->r) / UINT32_MAX;
+ v.channels = vol->channels;
+ for (i = 0; i < vol->channels; ++i) {
+ v.values[i] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->vol[i]) / 255;
+ }
pa_threaded_mainloop_lock(c->mainloop);