[MPlayer-dev-eng] [PATCH] use playback_switch with alsa for muting

Matthias Lederhofer matled at gmx.net
Fri Nov 18 17:03:35 CET 2005


> Overcomplicated, try the attached patch.

Ok, that is right.

> Anyway, I am a bit unsure about this, but what about any other
> channels? Since it is called FRONT_LEFT, I guess there also is
> REAR_LEFT or so?

Well, the part just above the patch in ao_alsa.c calls also only
snd_mixer_selem_set_playback_volume for 0 and 1 (front left and front
right), so I guess people with more channels have already at this
point problems.

In your patch the values for snd_mixer_selem_set_playback_switch have
to be inverted and I have put the call for the right channel in the
else part of the if. Now it works fine.
-------------- next part --------------
Index: libao2/ao_alsa.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
retrieving revision 1.20
diff -u -r1.20 ao_alsa.c
--- libao2/ao_alsa.c	25 Aug 2005 21:46:32 -0000	1.20
+++ libao2/ao_alsa.c	18 Nov 2005 16:00:22 -0000
@@ -197,6 +197,17 @@
 	}
 	mp_msg(MSGT_AO,MSGL_DBG2,"right=%li, pmin=%li, pmax=%li, mult=%f\n", 
 	       set_vol, pmin, pmax, f_multi);
+
+	if (snd_mixer_selem_has_playback_switch(elem)) {
+	  int lmute = (vol->left == 0.0);
+	  int rmute = (vol->right == 0.0);
+	  if (snd_mixer_selem_has_playback_switch_joined(elem)) {
+	    lmute = rmute = lmute & rmute;
+	  } else {
+	    snd_mixer_selem_set_playback_switch(elem, SND_MIXER_SCHN_FRONT_RIGHT, !rmute);
+	  }
+	  snd_mixer_selem_set_playback_switch(elem, SND_MIXER_SCHN_FRONT_LEFT, !lmute);
+	}
       }
       else {
 	snd_mixer_selem_get_playback_volume(elem, 0, &get_vol);


More information about the MPlayer-dev-eng mailing list