summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Wei Huang <cwhuang@linux.org.tw>2017-09-13 16:10:29 +0800
committerChih-Wei Huang <cwhuang@linux.org.tw>2017-09-13 16:10:29 +0800
commit7b7bf0207ad99efc5d287d64bc7aac6dd3402640 (patch)
tree37ca43d9fb152f160d1a2028f3538de585ff07ab
parentce9a1b1c6983dbb91c592643d1d90d64786bbcbe (diff)
downloadplatform_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.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/audio_hw.c b/audio_hw.c
index b7f8887..a83353a 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -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++) {