Mercurial > mplayer.hg
comparison libao2/ao_alsa.c @ 13434:2df414ae2d2a
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.
author | reimar |
---|---|
date | Wed, 22 Sep 2004 14:12:53 +0000 |
parents | aba44b58dea7 |
children | 07dc40f25068 |
comparison
equal
deleted
inserted
replaced
13433:0aca41a3e2ec | 13434:2df414ae2d2a |
---|---|
99 snd_mixer_elem_t *elem; | 99 snd_mixer_elem_t *elem; |
100 snd_mixer_selem_id_t *sid; | 100 snd_mixer_selem_id_t *sid; |
101 | 101 |
102 static char *mix_name = "PCM"; | 102 static char *mix_name = "PCM"; |
103 static char *card = "default"; | 103 static char *card = "default"; |
104 static int mix_index = 0; | |
104 | 105 |
105 long pmin, pmax; | 106 long pmin, pmax; |
106 long get_vol, set_vol; | 107 long get_vol, set_vol; |
107 float f_multi; | 108 float f_multi; |
108 | 109 |
109 if(mixer_channel) mix_name = mixer_channel; | 110 if(mixer_channel) { |
111 char *test_mix_index; | |
112 | |
113 mix_name = strdup(mixer_channel); | |
114 if (test_mix_index = strchr(mix_name, ',')){ | |
115 *test_mix_index = 0; | |
116 test_mix_index++; | |
117 mix_index = strtol(test_mix_index, &test_mix_index, 0); | |
118 | |
119 if (*test_mix_index){ | |
120 mp_msg(MSGT_AO,MSGL_ERR, | |
121 "alsa-control: invalid mixer index. Defaulting to 0\n"); | |
122 mix_index = 0 ; | |
123 } | |
124 } | |
125 } | |
110 if(mixer_device) card = mixer_device; | 126 if(mixer_device) card = mixer_device; |
111 | 127 |
112 if(ao_data.format == AFMT_AC3) | 128 if(ao_data.format == AFMT_AC3) |
113 return CONTROL_TRUE; | 129 return CONTROL_TRUE; |
114 | 130 |
115 //allocate simple id | 131 //allocate simple id |
116 snd_mixer_selem_id_alloca(&sid); | 132 snd_mixer_selem_id_alloca(&sid); |
117 | 133 |
118 //sets simple-mixer index and name | 134 //sets simple-mixer index and name |
119 snd_mixer_selem_id_set_index(sid, 0); | 135 snd_mixer_selem_id_set_index(sid, mix_index); |
120 snd_mixer_selem_id_set_name(sid, mix_name); | 136 snd_mixer_selem_id_set_name(sid, mix_name); |
137 | |
138 if (mixer_channel) { | |
139 free(mix_name); | |
140 mix_name = NULL; | |
141 } | |
121 | 142 |
122 if ((err = snd_mixer_open(&handle, 0)) < 0) { | 143 if ((err = snd_mixer_open(&handle, 0)) < 0) { |
123 mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: mixer open error: %s\n", snd_strerror(err)); | 144 mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: mixer open error: %s\n", snd_strerror(err)); |
124 return CONTROL_ERROR; | 145 return CONTROL_ERROR; |
125 } | 146 } |