aboutsummaryrefslogtreecommitdiff
path: root/audio/audio.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/audio.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/audio.c')
-rw-r--r--audio/audio.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/audio/audio.c b/audio/audio.c
index d616a4af98..f1c145dfcd 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1892,30 +1892,44 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque)
void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol)
{
+ Volume vol = { .mute = mute, .channels = 2, .vol = { lvol, rvol } };
+ audio_set_volume_out(sw, &vol);
+}
+
+void audio_set_volume_out(SWVoiceOut *sw, Volume *vol)
+{
if (sw) {
HWVoiceOut *hw = sw->hw;
- sw->vol.mute = mute;
- sw->vol.l = nominal_volume.l * lvol / 255;
- sw->vol.r = nominal_volume.r * rvol / 255;
+ sw->vol.mute = vol->mute;
+ sw->vol.l = nominal_volume.l * vol->vol[0] / 255;
+ sw->vol.r = nominal_volume.l * vol->vol[vol->channels > 1 ? 1 : 0] /
+ 255;
if (hw->pcm_ops->volume_out) {
- hw->pcm_ops->volume_out(hw, &sw->vol);
+ hw->pcm_ops->volume_out(hw, vol);
}
}
}
void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol)
{
+ Volume vol = { .mute = mute, .channels = 2, .vol = { lvol, rvol } };
+ audio_set_volume_in(sw, &vol);
+}
+
+void audio_set_volume_in(SWVoiceIn *sw, Volume *vol)
+{
if (sw) {
HWVoiceIn *hw = sw->hw;
- sw->vol.mute = mute;
- sw->vol.l = nominal_volume.l * lvol / 255;
- sw->vol.r = nominal_volume.r * rvol / 255;
+ sw->vol.mute = vol->mute;
+ sw->vol.l = nominal_volume.l * vol->vol[0] / 255;
+ sw->vol.r = nominal_volume.r * vol->vol[vol->channels > 1 ? 1 : 0] /
+ 255;
if (hw->pcm_ops->volume_in) {
- hw->pcm_ops->volume_in(hw, &sw->vol);
+ hw->pcm_ops->volume_in(hw, vol);
}
}
}