diff options
author | Chih-Wei Huang <cwhuang@linux.org.tw> | 2017-09-13 16:10:29 +0800 |
---|---|---|
committer | Chih-Wei Huang <cwhuang@linux.org.tw> | 2017-09-13 16:10:29 +0800 |
commit | 7b7bf0207ad99efc5d287d64bc7aac6dd3402640 (patch) | |
tree | 37ca43d9fb152f160d1a2028f3538de585ff07ab | |
parent | ce9a1b1c6983dbb91c592643d1d90d64786bbcbe (diff) | |
download | platform_hardware_libaudio-7b7bf0207ad99efc5d287d64bc7aac6dd3402640.tar.gz platform_hardware_libaudio-7b7bf0207ad99efc5d287d64bc7aac6dd3402640.tar.bz2 platform_hardware_libaudio-7b7bf0207ad99efc5d287d64bc7aac6dd3402640.zip |
audio_hw: allow to set sound card by propertiesandroid-x86-7.1-r1
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
-rw-r--r-- | audio_hw.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -187,7 +187,17 @@ struct snd_pcm_info *select_card(unsigned int device, unsigned int flags) if (!cached_info[d] && !cached_info[d + 2]) { struct dirent **namelist; char path[PATH_MAX] = "/dev/snd/"; - int n = scandir(path, &namelist, NULL, alphasort); + char prop[PROPERTY_VALUE_MAX]; + int n; + if (property_get(d ? "hal.audio.in" : "hal.audio.out", prop, NULL)) { + ALOGI("using %s from property", prop); + namelist = malloc(sizeof(struct dirent *)); + namelist[0] = calloc(1, sizeof(struct dirent)); + strncpy(namelist[0]->d_name, prop, sizeof(namelist[0]->d_name) - 1); + n = 1; + } else { + n = scandir(path, &namelist, NULL, alphasort); + } if (n >= 0) { int i, fd; for (i = 0; i < n; i++) { |