diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-04-08 00:19:52 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-04-08 00:19:52 +0000 |
commit | a74253606f4f5556e58cb12336d8900dd73226cc (patch) | |
tree | e1d00794e53c2a271bdec455aba808e565e825cf | |
parent | 025228f957b9212f889168a61497b6b3470fca20 (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
-rw-r--r-- | src/modules/module-alsa-sink.c | 15 | ||||
-rw-r--r-- | src/modules/module-alsa-source.c | 14 |
2 files changed, 25 insertions, 4 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) diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c index 14b35eb8..2ee16190 100644 --- a/src/modules/module-alsa-source.c +++ b/src/modules/module-alsa-source.c @@ -228,7 +228,12 @@ static int source_set_hw_volume_cb(pa_source *s) { assert(u && u->mixer_elem); if (snd_mixer_selem_has_capture_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_capture_volume_all(u->mixer_elem, vol); if (err < 0) @@ -237,7 +242,12 @@ static int source_set_hw_volume_cb(pa_source *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_capture_volume(u->mixer_elem, i, vol); if (err < 0) |