summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValentin Manea <valy@mrs.ro>2017-05-01 22:32:36 +0300
committerChih-Wei Huang <cwhuang@linux.org.tw>2017-05-02 17:43:41 +0800
commitce9a1b1c6983dbb91c592643d1d90d64786bbcbe (patch)
tree51ffb184a57ce69f466643f2dd14fc081bf90217
parent4f5006abcb66e923cabc4644b613db8d2c93a2bb (diff)
downloadplatform_hardware_libaudio-lollipop-x86.tar.gz
platform_hardware_libaudio-lollipop-x86.tar.bz2
platform_hardware_libaudio-lollipop-x86.zip
select_card: only open PCM devices with the same type as requestedmarshmallow-x86lollipop-x86
Let select_card() only open /dev/snd/pcmCxp for playback and /dev/snd/pcmCxc for capture device. This way select_card won't try to open a device twice. In some cases the second query on a playback device(even though select_card is searching for a capture device) will block inside the kernel causing audio to stop working.
-rw-r--r--audio_hw.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/audio_hw.c b/audio_hw.c
index 7c2406f..b7f8887 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -183,6 +183,7 @@ struct snd_pcm_info *select_card(unsigned int device, unsigned int flags)
static struct snd_pcm_info *cached_info[4];
struct snd_pcm_info *info;
int d = !!(flags & PCM_IN);
+ char e = d ? 'c' : 'p';
if (!cached_info[d] && !cached_info[d + 2]) {
struct dirent **namelist;
char path[PATH_MAX] = "/dev/snd/";
@@ -191,7 +192,7 @@ struct snd_pcm_info *select_card(unsigned int device, unsigned int flags)
int i, fd;
for (i = 0; i < n; i++) {
struct dirent *de = namelist[i];
- if (!strncmp(de->d_name, "pcmC", 4)) {
+ if (!strncmp(de->d_name, "pcmC", 4) && de->d_name[strlen(de->d_name) - 1] == e) {
strcpy(path + 9, de->d_name);
if ((fd = open(path, O_RDWR)) >= 0) {
info = malloc(sizeof(*info));