[Mplayer-cvslog] CVS: main/libao2 ao_alsa.c,1.7,1.8

Reimar Döffinger CVS syncmail at mplayerhq.hu
Wed Sep 22 16:12:56 CEST 2004


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libao2
In directory mail:/var2/tmp/cvs-serv83/libao2

Modified Files:
	ao_alsa.c 
Log Message:
allow to select an alsa mixer channel index.
Patch by Eric Yagerlener [eyager (at) chartermi (dot) net].
Applied with slight modifications, see also bugzilla bug #69.


Index: ao_alsa.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ao_alsa.c	30 Jul 2004 16:15:05 -0000	1.7
+++ ao_alsa.c	22 Sep 2004 14:12:53 -0000	1.8
@@ -101,12 +101,28 @@
 
       static char *mix_name = "PCM";
       static char *card = "default";
+      static int mix_index = 0;
 
       long pmin, pmax;
       long get_vol, set_vol;
       float f_multi;
 
-      if(mixer_channel) mix_name = mixer_channel;
+      if(mixer_channel) {
+	 char *test_mix_index;
+
+	 mix_name = strdup(mixer_channel);
+	 if (test_mix_index = strchr(mix_name, ',')){
+		*test_mix_index = 0;
+		test_mix_index++;
+		mix_index = strtol(test_mix_index, &test_mix_index, 0);
+
+		if (*test_mix_index){
+		  mp_msg(MSGT_AO,MSGL_ERR,
+		    "alsa-control: invalid mixer index. Defaulting to 0\n");
+		  mix_index = 0 ;
+		}
+	 }
+      }
       if(mixer_device) card = mixer_device;
 
       if(ao_data.format == AFMT_AC3)
@@ -116,9 +132,14 @@
       snd_mixer_selem_id_alloca(&sid);
 	
       //sets simple-mixer index and name
-      snd_mixer_selem_id_set_index(sid, 0);
+      snd_mixer_selem_id_set_index(sid, mix_index);
       snd_mixer_selem_id_set_name(sid, mix_name);
 
+      if (mixer_channel) {
+	free(mix_name);
+	mix_name = NULL;
+      }
+
       if ((err = snd_mixer_open(&handle, 0)) < 0) {
 	mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: mixer open error: %s\n", snd_strerror(err));
 	return CONTROL_ERROR;




More information about the MPlayer-cvslog mailing list