diff options
author | Valentin Manea <valy@mrs.ro> | 2017-05-01 22:32:36 +0300 |
---|---|---|
committer | Chih-Wei Huang <cwhuang@linux.org.tw> | 2017-05-02 17:43:41 +0800 |
commit | ce9a1b1c6983dbb91c592643d1d90d64786bbcbe (patch) | |
tree | 51ffb184a57ce69f466643f2dd14fc081bf90217 | |
parent | 4f5006abcb66e923cabc4644b613db8d2c93a2bb (diff) | |
download | platform_hardware_libaudio-marshmallow-x86.tar.gz platform_hardware_libaudio-marshmallow-x86.tar.bz2 platform_hardware_libaudio-marshmallow-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.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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)); |