Android-x86
Fork
Spenden

  • R/O
  • HTTP
  • SSH
  • HTTPS

hardware-libaudio: Commit

hardware/libaudio


Commit MetaInfo

Revision3ac75230e3ea49f9c8bbae5f1f48a2442ad907cd (tree)
Zeit2016-08-15 22:23:39
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

audio_hw: cache HDMI audio interface

Now we cache the HDMI audio interface as well to avoid misusing them.

We are near to fully support HDMI audio. What missed is the events
to trigger the switching between primary speaker and HDMI.

Ändern Zusammenfassung

Diff

--- a/audio_hw.c
+++ b/audio_hw.c
@@ -179,20 +179,21 @@ static void release_buffer(struct resampler_buffer_provider *buffer_provider,
179179
180180 struct snd_pcm_info *select_card(unsigned int device __unused, unsigned int flags)
181181 {
182- static struct snd_pcm_info *cached_info[2];
182+ static struct snd_pcm_info *cached_info[4];
183+ struct snd_pcm_info *info;
183184 int d = !!(flags & PCM_IN);
184- if (!cached_info[d]) {
185+ if (!cached_info[d] && !cached_info[d + 2]) {
185186 struct dirent **namelist;
186187 char path[PATH_MAX] = "/dev/snd/";
187188 int n = scandir(path, &namelist, NULL, alphasort);
188189 if (n >= 0) {
189190 int i, fd;
190- struct snd_pcm_info *info = malloc(sizeof(*info));
191191 for (i = 0; i < n; i++) {
192192 struct dirent *de = namelist[i];
193- if (!cached_info[d] && !strncmp(de->d_name, "pcmC", 4)) {
193+ if (!strncmp(de->d_name, "pcmC", 4)) {
194194 strcpy(path + 9, de->d_name);
195195 if ((fd = open(path, O_RDWR)) >= 0) {
196+ info = malloc(sizeof(*info));
196197 if (!ioctl(fd, SNDRV_PCM_IOCTL_INFO, info)) {
197198 if (info->stream == d && /* ignore IntelHDMI */
198199 !strstr((const char *)info->id, "IntelHDMI")) {
@@ -200,10 +201,17 @@ struct snd_pcm_info *select_card(unsigned int device __unused, unsigned int flag
200201 d ? "in" : "out", path,
201202 info->card, info->device, info->id,
202203 info->name, info->subname, info->stream);
203- cached_info[d] = info;
204+ int hdmi = (!!strstr((const char *)info->id, "HDMI")) * 2;
205+ if (cached_info[d + hdmi]) {
206+ ALOGD("ignore %s", de->d_name);
207+ free(info);
208+ } else {
209+ cached_info[d + hdmi] = info;
210+ }
204211 }
205212 } else {
206213 ALOGV("can't get info of %s", path);
214+ free(info);
207215 }
208216 close(fd);
209217 }
@@ -211,12 +219,11 @@ struct snd_pcm_info *select_card(unsigned int device __unused, unsigned int flag
211219 free(de);
212220 }
213221 free(namelist);
214- if (!cached_info[d]) {
215- free(info);
216- }
217222 }
218223 }
219- return cached_info[d];
224+ info = cached_info[d] ? cached_info[d] : cached_info[d + 2];
225+ ALOGI_IF(info, "choose pcmC%dD%d%c", info->card, info->device, d ? 'c' : 'p');
226+ return info;
220227 }
221228
222229 struct pcm *my_pcm_open(unsigned int device, unsigned int flags, struct pcm_config *config)
Show on old repository browser