From 57030817e1a7c0b2dd7329a2b0a98d6c81d3d2da Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Wed, 5 Jan 2011 12:36:59 +0100 Subject: [PATCH 3/6] alsa-mixer: always round towards 0 dB Always round towards 0 dB. Also add a few debug comments to aid troubleshooting. Signed-off-by: David Henningsson --- src/modules/alsa/alsa-mixer.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 2c47319..b3fcbec 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -714,19 +714,20 @@ static int element_set_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann if (e->has_dB) { long value = to_alsa_dB(f); + int rounding = value > 0 ? -1 : +1; if (e->direction == PA_ALSA_DIRECTION_OUTPUT) { /* If we call set_play_volume() without checking first * if the channel is available, ALSA behaves ver * strangely and doesn't fail the call */ if (snd_mixer_selem_has_playback_channel(me, c)) { - if ((r = snd_mixer_selem_set_playback_dB(me, c, value, +1)) >= 0) + if ((r = snd_mixer_selem_set_playback_dB(me, c, value, rounding)) >= 0) r = snd_mixer_selem_get_playback_dB(me, c, &value); } else r = -1; } else { if (snd_mixer_selem_has_capture_channel(me, c)) { - if ((r = snd_mixer_selem_set_capture_dB(me, c, value, +1)) >= 0) + if ((r = snd_mixer_selem_set_capture_dB(me, c, value, rounding)) >= 0) r = snd_mixer_selem_get_capture_dB(me, c, &value); } else r = -1; @@ -2108,6 +2109,7 @@ int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, pa_bool_t ignore_dB) { pa_log_debug("Probe of element '%s' failed.", e->alsa_name); return -1; } + pa_log_debug("Probe of element '%s' succeeded (volume=%d, switch=%d, enumeration=%d).", e->alsa_name, e->volume_use, e->switch_use, e->enumeration_use); if (ignore_dB) e->has_dB = FALSE; @@ -2144,10 +2146,11 @@ int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, pa_bool_t ignore_dB) { pa_log_info("Zeroing volume of '%s' on path '%s'", e->alsa_name, p->name); } } - } else if (p->has_volume) + } else if (p->has_volume) { /* We can't use this volume, so let's ignore it */ e->volume_use = PA_ALSA_VOLUME_IGNORE; - + pa_log_info("Ignoring volume of '%s' on path '%s' (missing dB info)", e->alsa_name, p->name); + } p->has_volume = TRUE; } -- 1.7.1