[patch] alsa mixer doesn't handle joined channels

It reports: "Mixer has no channels". But there are one:
% amixer sget Master
Simple mixer control 'Master',0
Capabilities: pvolume pvolume-joined
Playback channels: Mono
Limits: Playback 0 - 255
Mono: Playback 137 [54%] [-29.50dB]

Index: alsa.c
===================================================================
--- alsa.c (revision 2249)
+++ alsa.c (working copy)
@@ -203,31 +203,37 @@

handle_mixer_events (mixer_handle);

- for (i = 0; i < SND_MIXER_SCHN_LAST; i++)
- if (snd_mixer_selem_has_playback_channel(elem,
- 1 << i)) {
- long vol;
-
- nchannels++;
- if ((err = snd_mixer_selem_get_playback_volume(
- elem,
- 1 << i,
- &vol)) < 0) {
- error ("Can't read mixer: %s",
- snd_strerror(err));
- return -1;
-
- }
- /*logit ("Vol %d: %ld", i, vol);*/
- volume += vol;
- }
+ if (snd_mixer_selem_has_playback_volume_joined(elem)) {
+ if (snd_mixer_selem_get_playback_volume(elem, 0, &volume) != 0)
+ logit ("Can't read joined mixer channel");
+ }
+ else {
+ for (i = 0; i < SND_MIXER_SCHN_LAST; i++)
+ if (snd_mixer_selem_has_playback_channel(elem,
+ 1 << i)) {
+ long vol;
+
+ nchannels++;
+ if ((err = snd_mixer_selem_get_playback_volume(
+ elem,
+ 1 << i,
+ &vol)) < 0) {
+ error ("Can't read mixer: %s",
+ snd_strerror(err));
+ return -1;
+
+ }
+ /*logit ("Vol %d: %ld", i, vol);*/
+ volume += vol;
+ }

- if (nchannels > 0)
- volume /= nchannels;
- else {
- logit ("Mixer has no channels");
- volume = -1;
- }
+ if (nchannels > 0)
+ volume /= nchannels;
+ else {
+ logit ("Mixer has no channels");
+ volume = -1;
+ }
+ }

/*logit ("Max: %ld, Min: %ld", mixer_max, mixer_min);*/
return volume;

Although this patch was obsoleted by r2318, its spirit lives on in r2897.