diff options
author | Tanu Kaskinen <tanu.kaskinen@digia.com> | 2011-03-11 13:41:28 +0200 |
---|---|---|
committer | Tanu Kaskinen <tanu.kaskinen@digia.com> | 2011-03-11 13:41:28 +0200 |
commit | 5715b2af3091f9be9a656dfa9b8cb778caf1c03e (patch) | |
tree | 402316370dbb59220a5513517074df17aa21d96b | |
parent | 064780d9dea6a79c4c3adb07f530e2e6d5c68c0f (diff) | |
download | pulseaudio-panda-5715b2af3091f9be9a656dfa9b8cb778caf1c03e.tar.gz pulseaudio-panda-5715b2af3091f9be9a656dfa9b8cb778caf1c03e.tar.bz2 pulseaudio-panda-5715b2af3091f9be9a656dfa9b8cb778caf1c03e.zip |
alsa-mixer: When figuring out the max_dB of a path, use only channels that are used by the path elements.
Without this, p->max_dB could never be less than 0 dB, because the loop at the
end of pa_alsa_path_probe() would reset p->max_dB to 0 as soon as the loop
encountered a channel that wasn't touched by any element.
There was a similar issue for p->min_dB too (it could never be more than 0 dB),
which is also fixed by this patch.
-rw-r--r-- | src/modules/alsa/alsa-mixer.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 41997a79..3eef5f9c 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -2400,6 +2400,7 @@ int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, pa_bool_t ignore_dB) { pa_alsa_element *e; double min_dB[PA_CHANNEL_POSITION_MAX], max_dB[PA_CHANNEL_POSITION_MAX]; pa_channel_position_t t; + pa_channel_position_mask_t path_volume_channels = 0; pa_assert(p); pa_assert(m); @@ -2436,6 +2437,7 @@ int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, pa_bool_t ignore_dB) { if (PA_CHANNEL_POSITION_MASK(t) & e->merged_mask) { min_dB[t] = e->min_dB; max_dB[t] = e->max_dB; + path_volume_channels |= PA_CHANNEL_POSITION_MASK(t); } p->has_dB = TRUE; @@ -2446,6 +2448,7 @@ int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, pa_bool_t ignore_dB) { if (PA_CHANNEL_POSITION_MASK(t) & e->merged_mask) { min_dB[t] += e->min_dB; max_dB[t] += e->max_dB; + path_volume_channels |= PA_CHANNEL_POSITION_MASK(t); } } else { /* Hmm, there's another element before us @@ -2484,11 +2487,13 @@ int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, pa_bool_t ignore_dB) { p->max_dB = -INFINITY; for (t = 0; t < PA_CHANNEL_POSITION_MAX; t++) { - if (p->min_dB > min_dB[t]) - p->min_dB = min_dB[t]; + if (path_volume_channels & PA_CHANNEL_POSITION_MASK(t)) { + if (p->min_dB > min_dB[t]) + p->min_dB = min_dB[t]; - if (p->max_dB < max_dB[t]) - p->max_dB = max_dB[t]; + if (p->max_dB < max_dB[t]) + p->max_dB = max_dB[t]; + } } return 0; |