]> code.delx.au - pulseaudio/commitdiff
alsa: Fix SND_MIXER_SCHN_LAST related stuff.
authorTanu Kaskinen <tanu.kaskinen@digia.com>
Mon, 26 Mar 2012 11:35:30 +0000 (14:35 +0300)
committerTanu Kaskinen <tanuk@iki.fi>
Wed, 28 Mar 2012 14:32:04 +0000 (17:32 +0300)
Valid channel id range is from 0 to SND_MIXER_SCHN_LAST,
inclusive, so the size of the masks array in pa_alsa_element
has to be SND_MIXER_SCHN_LAST + 1. Similar "too small"
arrays were also in alsa-sink's and alsa-source's userdata,
but actually those arrays were not used at all so they were
removed.

element_is_subset() in alsa-mixer.c skipped the last channel
id when iterating the element masks array; that's now fixed
as well.

Thanks to David Henningsson for spotting the too small
arrays in alsa-sink and alsa-source and the
element_is_subset() problem.

src/modules/alsa/alsa-mixer.c
src/modules/alsa/alsa-mixer.h
src/modules/alsa/alsa-sink.c
src/modules/alsa/alsa-source.c

index ba31c79db044a2d1d134ccdd0f77941fd23bc33b..abb12ee0891cad7ed88bde99c290c2a823c998aa 100644 (file)
@@ -1577,7 +1577,7 @@ static int element_probe(pa_alsa_element *e, snd_mixer_t *m) {
                          *
                          * The definition of e->masks is
                          *
-                         *     pa_channel_position_mask_t masks[SND_MIXER_SCHN_LAST][2];
+                         *     pa_channel_position_mask_t masks[SND_MIXER_SCHN_LAST + 1][2];
                          *
                          * Since the array size is fixed at 2, we obviously
                          * don't support elements with more than two
@@ -3105,7 +3105,7 @@ static pa_bool_t element_is_subset(pa_alsa_element *a, pa_alsa_element *b, snd_m
             /* If override-maps are different, they're not subsets */
             if (a->n_channels != b->n_channels)
                 return FALSE;
-            for (s = 0; s < SND_MIXER_SCHN_LAST; s++)
+            for (s = 0; s <= SND_MIXER_SCHN_LAST; s++)
                 if (a->masks[s][a->n_channels-1] != b->masks[s][b->n_channels-1]) {
                     pa_log_debug("Element %s is not a subset - mask a: 0x%" PRIx64 ", mask b: 0x%" PRIx64 ", at channel %d",
                         a->alsa_name, a->masks[s][a->n_channels-1], b->masks[s][b->n_channels-1], s);
index 59bd3fbe0af05b4dc747ea40e4f295ebd698e71e..fdcff7692982bcd263cd092e8045bd719eb3c497 100644 (file)
@@ -145,7 +145,7 @@ struct pa_alsa_element {
     long volume_limit; /* -1 for no configured limit */
     double min_dB, max_dB;
 
-    pa_channel_position_mask_t masks[SND_MIXER_SCHN_LAST][2];
+    pa_channel_position_mask_t masks[SND_MIXER_SCHN_LAST + 1][2];
     unsigned n_channels;
 
     pa_channel_position_mask_t merged_mask;
index c88f4cff8d41488ee230012074bf39c7c45be464..ea5188c9e3c1f9f851e65b7d13b3b767f3a387dc 100644 (file)
@@ -140,8 +140,6 @@ struct userdata {
 
     pa_rtpoll_item *alsa_rtpoll_item;
 
-    snd_mixer_selem_channel_id_t mixer_map[SND_MIXER_SCHN_LAST];
-
     pa_smoother *smoother;
     uint64_t write_count;
     uint64_t since_start;
index 3e593403b2233fffdd5f80d46a9d41bf0895aa93..2680302c498109f3526a821174242534d86cd5a0 100644 (file)
@@ -127,8 +127,6 @@ struct userdata {
 
     pa_rtpoll_item *alsa_rtpoll_item;
 
-    snd_mixer_selem_channel_id_t mixer_map[SND_MIXER_SCHN_LAST];
-
     pa_smoother *smoother;
     uint64_t read_count;
     pa_usec_t smoother_interval;