Ticket #69: patch.3

File patch.3, 3.2 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.701
5diff -u -r1.701 mplayer.1
6--- DOCS/man/en/mplayer.1       6 Sep 2004 11:03:51 -0000       1.701
7+++ DOCS/man/en/mplayer.1       6 Sep 2004 15:04:55 -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    6 Sep 2004 15:04:59 -0000
24@@ -101,12 +101,32 @@
25 
26       static char *mix_name = "PCM";
27       static char *card = "default";
28-
29+      static char *parsed_mixer_channel;
30+      static int mix_index;
31+     
32+     
33       long pmin, pmax;
34       long get_vol, set_vol;
35       float f_multi;
36 
37-      if(mixer_channel) mix_name = mixer_channel;
38+      if(mixer_channel){
39+        char *test_mix_index;
40+       
41+        parsed_mixer_channel = malloc(strlen(mixer_channel) + 1);
42+        mix_name = strcpy(parsed_mixer_channel, mixer_channel);
43+                       
44+        if (test_mix_index = strchr(mix_name, ',')){
45+               *test_mix_index = 0;
46+               test_mix_index++ ;
47+               mix_index = strtol(test_mix_index, &test_mix_index, 0);
48+
49+               if (*test_mix_index){
50+                 mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: invalid mixer index. Defaulting to 0\n");
51+                 mix_index = 0 ;
52+               }
53+               
54+        }
55+      }
56       if(mixer_device) card = mixer_device;
57 
58       if(ao_data.format == AFMT_AC3)
59@@ -116,9 +136,11 @@
60       snd_mixer_selem_id_alloca(&sid);
61       
62       //sets simple-mixer index and name
63-      snd_mixer_selem_id_set_index(sid, 0);
64+      snd_mixer_selem_id_set_index(sid, mix_index);
65       snd_mixer_selem_id_set_name(sid, mix_name);
66 
67+      if (mixer_channel) free(parsed_mixer_channel);
68+     
69       if ((err = snd_mixer_open(&handle, 0)) < 0) {
70        mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: mixer open error: %s\n", snd_strerror(err));
71        return CONTROL_ERROR;
72Index: libao2/ao_alsa1x.c
73===================================================================
74RCS file: /cvsroot/mplayer/main/libao2/ao_alsa1x.c,v
75retrieving revision 1.44
76diff -u -r1.44 ao_alsa1x.c
77--- libao2/ao_alsa1x.c  6 Apr 2004 17:55:36 -0000       1.44
78+++ libao2/ao_alsa1x.c  6 Sep 2004 15:05:01 -0000
79@@ -103,6 +103,7 @@
80 
81       static char *mix_name = NULL;
82       static char *card = NULL;
83+      static int *index = "0";
84 
85       long pmin, pmax;
86       long get_vol, set_vol;
87@@ -123,6 +124,8 @@
88         }
89       }
90 
91+      if(mixer_index) index = mixer_index;
92+     
93       if(ao_data.format == AFMT_AC3)
94        return CONTROL_TRUE;
95 
96@@ -130,7 +133,7 @@
97       snd_mixer_selem_id_alloca(&sid);
98       
99       //sets simple-mixer index and name
100-      snd_mixer_selem_id_set_index(sid, 0);
101+      snd_mixer_selem_id_set_index(sid, index);
102       snd_mixer_selem_id_set_name(sid, mix_name);
103 
104       if ((err = snd_mixer_open(&handle, 0)) < 0) {