OSDN Git Service

audio_hw: allow to set sound card by properties android-x86-7.1-r1
authorChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 13 Sep 2017 08:10:29 +0000 (16:10 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 13 Sep 2017 08:10:29 +0000 (16:10 +0800)
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

audio_hw.c

index b7f8887..a83353a 100644 (file)
@@ -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++) {