• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/libaudio


Commit MetaInfo

修订版ce9a1b1c6983dbb91c592643d1d90d64786bbcbe (tree)
时间2017-05-02 18:43:41
作者Valentin Manea <valy@mrs....>
CommiterChih-Wei Huang

Log Message

select_card: only open PCM devices with the same type as requested

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.

更改概述

差异

--- a/audio_hw.c
+++ b/audio_hw.c
@@ -183,6 +183,7 @@ struct snd_pcm_info *select_card(unsigned int device, unsigned int flags)
183183 static struct snd_pcm_info *cached_info[4];
184184 struct snd_pcm_info *info;
185185 int d = !!(flags & PCM_IN);
186+ char e = d ? 'c' : 'p';
186187 if (!cached_info[d] && !cached_info[d + 2]) {
187188 struct dirent **namelist;
188189 char path[PATH_MAX] = "/dev/snd/";
@@ -191,7 +192,7 @@ struct snd_pcm_info *select_card(unsigned int device, unsigned int flags)
191192 int i, fd;
192193 for (i = 0; i < n; i++) {
193194 struct dirent *de = namelist[i];
194- if (!strncmp(de->d_name, "pcmC", 4)) {
195+ if (!strncmp(de->d_name, "pcmC", 4) && de->d_name[strlen(de->d_name) - 1] == e) {
195196 strcpy(path + 9, de->d_name);
196197 if ((fd = open(path, O_RDWR)) >= 0) {
197198 info = malloc(sizeof(*info));