Ticket #69: final

File final, 2.6 KB (added by eyager@…, 15 years ago)

Revised patch libao2/ao_alsa.c

Line 
1Index: DOCS/man/en/mplayer.1
2===================================================================
3RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
4retrieving revision 1.717
5diff -u -r1.717 mplayer.1
6--- DOCS/man/en/mplayer.1       12 Sep 2004 22:43:17 -0000      1.717
7+++ DOCS/man/en/mplayer.1       14 Sep 2004 14:04:08 -0000
8@@ -1665,7 +1665,7 @@
9 For ALSA this is the mixer name.
10 .
11 .TP
12-.B \-mixer-channel <mixer line> (\-ao oss and \-ao alsa only)
13+.B \-mixer-channel <mixer line>[,mixer index] (\-ao oss and \-ao alsa only)
14 This option will tell MPlayer to use a different channel for controlling
15 volume than the default PCM.
16 Options for OSS include
17@@ -1674,6 +1674,11 @@
18 /usr/\:include/\:linux/\:soundcard.h.
19 For ALSA you can use the names e.g.\& alsamixer displays, like
20 .B Master, Line, PCM.
21+.br
22+.I NOTE: 
23+ALSA mixer channel names followed by a number must be specified in the <name,number>
24+format, i.e. a channel labled 'PCM 1' in alsamixer must be converted to
25+.B PCM,1.
26 .
27 .TP
28 .B \-nowaveheader (\-ao pcm only)
29Index: libao2/ao_alsa.c
30===================================================================
31RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
32retrieving revision 1.7
33diff -u -r1.7 ao_alsa.c
34--- libao2/ao_alsa.c    30 Jul 2004 16:15:05 -0000      1.7
35+++ libao2/ao_alsa.c    14 Sep 2004 14:04:16 -0000
36@@ -101,12 +101,30 @@
37 
38       static char *mix_name = "PCM";
39       static char *card = "default";
40+      static char *parsed_mixer_channel;
41+      static int mix_index;
42 
43       long pmin, pmax;
44       long get_vol, set_vol;
45       float f_multi;
46 
47-      if(mixer_channel) mix_name = mixer_channel;
48+      if(mixer_channel){
49+        char *test_mix_index;
50+
51+        parsed_mixer_channel = strdup(mixer_channel);
52+        mix_name = strcpy(parsed_mixer_channel, mixer_channel);
53+
54+        if (test_mix_index = strchr(mix_name, ',')){
55+               *test_mix_index = 0;
56+               test_mix_index++ ;
57+               mix_index = strtol(test_mix_index, &test_mix_index, 0);
58+
59+               if (*test_mix_index){
60+                 mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: invalid mixer index. Defaulting to 0\n");
61+                 mix_index = 0 ;
62+               }
63+        }
64+      }
65       if(mixer_device) card = mixer_device;
66 
67       if(ao_data.format == AFMT_AC3)
68@@ -114,11 +132,13 @@
69 
70       //allocate simple id
71       snd_mixer_selem_id_alloca(&sid);
72-       
73+
74       //sets simple-mixer index and name
75-      snd_mixer_selem_id_set_index(sid, 0);
76+      snd_mixer_selem_id_set_index(sid, mix_index);
77       snd_mixer_selem_id_set_name(sid, mix_name);
78 
79+      if (mixer_channel) free(parsed_mixer_channel);
80+
81       if ((err = snd_mixer_open(&handle, 0)) < 0) {
82        mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: mixer open error: %s\n", snd_strerror(err));
83        return CONTROL_ERROR;