summaryrefslogtreecommitdiff
path: root/src/modules/module-alsa-sink.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-04-08 00:19:52 +0000
committerLennart Poettering <lennart@poettering.net>2006-04-08 00:19:52 +0000
commita74253606f4f5556e58cb12336d8900dd73226cc (patch)
treee1d00794e53c2a271bdec455aba808e565e825cf /src/modules/module-alsa-sink.c
parent025228f957b9212f889168a61497b6b3470fca20 (diff)
clip volume at PA_VOLUME_NORM for alsa devices
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@666 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/modules/module-alsa-sink.c')
-rw-r--r--src/modules/module-alsa-sink.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index f930e615..e2e593da 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -239,8 +239,14 @@ static int sink_set_hw_volume_cb(pa_sink *s) {
assert(u && u->mixer_elem);
if (snd_mixer_selem_has_playback_volume_joined(u->mixer_elem)) {
- vol = pa_cvolume_avg(&s->hw_volume) * (u->hw_volume_max - u->hw_volume_min) /
+ vol = pa_cvolume_avg(&s->hw_volume);
+
+ if (vol > PA_VOLUME_NORM)
+ vol = PA_VOLUME_NORM;
+
+ vol = (vol * (u->hw_volume_max - u->hw_volume_min)) /
PA_VOLUME_NORM + u->hw_volume_min;
+
err = snd_mixer_selem_set_playback_volume_all(u->mixer_elem, vol);
if (err < 0)
goto fail;
@@ -248,7 +254,12 @@ static int sink_set_hw_volume_cb(pa_sink *s) {
int i;
for (i = 0;i < s->hw_volume.channels;i++) {
- vol = s->hw_volume.values[i] * (u->hw_volume_max - u->hw_volume_min) /
+ vol = s->hw_volume.values[i];
+
+ if (vol > PA_VOLUME_NORM)
+ vol = PA_VOLUME_NORM;
+
+ vol = (vol * (u->hw_volume_max - u->hw_volume_min)) /
PA_VOLUME_NORM + u->hw_volume_min;
err = snd_mixer_selem_set_playback_volume(u->mixer_elem, i, vol);
if (err < 0)