Ticket #69: patch.2

File patch.2, 1.9 KB (added by eyager@…, 22 years ago)

Revised patch to libao2/ao_alsa.c and manpage for mixer index support.

Line 
1Index: DOCS/man/en/mplayer.1
2===================================================================
3RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
4retrieving revision 1.688
5diff -u -r1.688 mplayer.1
6--- DOCS/man/en/mplayer.1 28 Aug 2004 20:36:34 -0000 1.688
7+++ DOCS/man/en/mplayer.1 4 Sep 2004 22:16:20 -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
17Index: libao2/ao_alsa.c
18===================================================================
19RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
20retrieving revision 1.7
21diff -u -r1.7 ao_alsa.c
22--- libao2/ao_alsa.c 30 Jul 2004 16:15:05 -0000 1.7
23+++ libao2/ao_alsa.c 4 Sep 2004 22:16:23 -0000
24@@ -101,12 +101,26 @@
25
26 static char *mix_name = "PCM";
27 static char *card = "default";
28+ static int mix_index = 0;
29
30 long pmin, pmax;
31 long get_vol, set_vol;
32 float f_multi;
33
34- if(mixer_channel) mix_name = mixer_channel;
35+ if(mixer_channel){
36+ char *test_mix_index;
37+ mix_name = mixer_channel;
38+
39+ if (test_mix_index = strchr(mix_name, ',')){
40+ *test_mix_index = 0;
41+ test_mix_index++ ;
42+ mix_index = strtol(test_mix_index, &test_mix_index, 0);
43+
44+ if (test_mix_index){
45+ mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: non numeric or null mixer index. Defaulting to 0\n");
46+ }
47+ }
48+ }
49 if(mixer_device) card = mixer_device;
50
51 if(ao_data.format == AFMT_AC3)
52@@ -116,7 +130,7 @@
53 snd_mixer_selem_id_alloca(&sid);
54
55 //sets simple-mixer index and name
56- snd_mixer_selem_id_set_index(sid, 0);
57+ snd_mixer_selem_id_set_index(sid, mix_index);
58 snd_mixer_selem_id_set_name(sid, mix_name);
59
60 if ((err = snd_mixer_open(&handle, 0)) < 0) {