hardware/libaudio
Revisão | 7b7bf0207ad99efc5d287d64bc7aac6dd3402640 (tree) |
---|---|
Hora | 2017-09-13 17:10:29 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
audio_hw: allow to set sound card by properties
To manually specify the audio in and out device nodes, set the
properties like:
Audio in: hal.audio.in=pcmC1D0c
Audio out: hal.audio.out=pcmC1D3p
@@ -187,7 +187,17 @@ struct snd_pcm_info *select_card(unsigned int device, unsigned int flags) | ||
187 | 187 | if (!cached_info[d] && !cached_info[d + 2]) { |
188 | 188 | struct dirent **namelist; |
189 | 189 | char path[PATH_MAX] = "/dev/snd/"; |
190 | - int n = scandir(path, &namelist, NULL, alphasort); | |
190 | + char prop[PROPERTY_VALUE_MAX]; | |
191 | + int n; | |
192 | + if (property_get(d ? "hal.audio.in" : "hal.audio.out", prop, NULL)) { | |
193 | + ALOGI("using %s from property", prop); | |
194 | + namelist = malloc(sizeof(struct dirent *)); | |
195 | + namelist[0] = calloc(1, sizeof(struct dirent)); | |
196 | + strncpy(namelist[0]->d_name, prop, sizeof(namelist[0]->d_name) - 1); | |
197 | + n = 1; | |
198 | + } else { | |
199 | + n = scandir(path, &namelist, NULL, alphasort); | |
200 | + } | |
191 | 201 | if (n >= 0) { |
192 | 202 | int i, fd; |
193 | 203 | for (i = 0; i < n; i++) { |