[pulseaudio-discuss] [PATCH] alsa-mixer: Make sure that SND_MIXER_SCHN_UNKNOWN isn't used when indexing e->masks.
Tanu Kaskinen
tanu.kaskinen at digia.com
Wed Mar 23 03:03:43 PDT 2011
SND_MIXER_SCHN_UNKNOWN is defined as -1, so that's not a good array index...
---
src/modules/alsa/alsa-mixer.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index b425ce5..c9adbb0 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -1490,8 +1490,13 @@ static int element_probe(pa_alsa_element *e, snd_mixer_t *m) {
e->n_channels = 1;
if (!e->override_map) {
- for (p = PA_CHANNEL_POSITION_FRONT_LEFT; p < PA_CHANNEL_POSITION_MAX; p++)
+ for (p = PA_CHANNEL_POSITION_FRONT_LEFT; p < PA_CHANNEL_POSITION_MAX; p++) {
+ if (alsa_channel_ids[p] == SND_MIXER_SCHN_UNKNOWN)
+ continue;
+
e->masks[alsa_channel_ids[p]][e->n_channels-1] = 0;
+ }
+
e->masks[SND_MIXER_SCHN_MONO][e->n_channels-1] = PA_CHANNEL_POSITION_MASK_ALL;
}
@@ -1531,8 +1536,12 @@ static int element_probe(pa_alsa_element *e, snd_mixer_t *m) {
}
e->merged_mask = 0;
- for (p = PA_CHANNEL_POSITION_FRONT_LEFT; p < PA_CHANNEL_POSITION_MAX; p++)
+ for (p = PA_CHANNEL_POSITION_FRONT_LEFT; p < PA_CHANNEL_POSITION_MAX; p++) {
+ if (alsa_channel_ids[p] == SND_MIXER_SCHN_UNKNOWN)
+ continue;
+
e->merged_mask |= e->masks[alsa_channel_ids[p]][e->n_channels-1];
+ }
}
}
}
--
1.7.4.1
More information about the pulseaudio-discuss
mailing list