diff options
author | David Henningsson <david.henningsson@canonical.com> | 2011-01-05 12:36:59 +0100 |
---|---|---|
committer | Colin Guthrie <cguthrie@mandriva.org> | 2011-02-25 15:54:48 +0000 |
commit | ade0a6f88464d8aecf83982d400ccfc402341920 (patch) | |
tree | 3c3aba23edbf771bd51f69d80108e4faa8058431 /src/modules | |
parent | b0f72311cf49e25ea05279e3a978bb4db54dd332 (diff) |
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 <david.henningsson@canonical.com>
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/alsa/alsa-mixer.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 967140bf..e1113881 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -804,6 +804,7 @@ 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 @@ -811,11 +812,11 @@ static int element_set_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann * strangely and doesn't fail the call */ if (snd_mixer_selem_has_playback_channel(me, c)) { if (write_to_hw) { - 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 { long alsa_val; - if ((r = snd_mixer_selem_ask_playback_dB_vol(me, value, +1, &alsa_val)) >= 0) + if ((r = snd_mixer_selem_ask_playback_dB_vol(me, value, rounding, &alsa_val)) >= 0) r = snd_mixer_selem_ask_playback_vol_dB(me, alsa_val, &value); } } else @@ -823,11 +824,11 @@ static int element_set_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann } else { if (snd_mixer_selem_has_capture_channel(me, c)) { if (write_to_hw) { - 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 { long alsa_val; - if ((r = snd_mixer_selem_ask_capture_dB_vol(me, value, +1, &alsa_val)) >= 0) + if ((r = snd_mixer_selem_ask_capture_dB_vol(me, value, rounding, &alsa_val)) >= 0) r = snd_mixer_selem_ask_capture_vol_dB(me, alsa_val, &value); } } else @@ -2214,6 +2215,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; @@ -2250,10 +2252,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; } |