diff --git a/audiod/AudioDaemon.cpp b/audiod/AudioDaemon.cpp index 2c9b5d08..1a403300 100644 --- a/audiod/AudioDaemon.cpp +++ b/audiod/AudioDaemon.cpp @@ -1,5 +1,5 @@ /* AudioDaemon.cpp -Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. +Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -69,7 +69,7 @@ namespace android { { FILE *fp; int fd; - char *ptr, *saveptr; + char *ptr, *saveptr, *card_id = NULL; char buffer[128]; int line = 0; String8 path; @@ -84,9 +84,21 @@ namespace android { sndcardFdPair.clear(); memset(buffer, 0x0, sizeof(buffer)); while ((fgets(buffer, sizeof(buffer), fp) != NULL)) { - if (line % 2) + if (line++ % 2) continue; ptr = strtok_r(buffer, " [", &saveptr); + if (!ptr) + continue; + + card_id = strtok_r(saveptr+1, "]", &saveptr); + if (!card_id) + continue; + //Only consider sound cards associated with ADSP + if ((strncasecmp(card_id, "msm", 3) != 0) && + (strncasecmp(card_id, "apq", 3) != 0)) { + ALOGD("Skipping non-ADSP sound card %s", card_id); + continue; + } if (ptr) { path = "/proc/asound/card"; path += ptr; @@ -101,7 +113,6 @@ namespace android { sndcardFdPair.push_back(std::make_pair(sndcard, fd)); } } - line++; } ALOGV("%s: %d sound cards detected", __func__, sndcardFdPair.size()); diff --git a/hal/audio_extn/sndmonitor.c b/hal/audio_extn/sndmonitor.c index eecc448a..309a9a84 100644 --- a/hal/audio_extn/sndmonitor.c +++ b/hal/audio_extn/sndmonitor.c @@ -162,11 +162,6 @@ static int add_new_sndcard(int card, int fd) return 0; } -static int validate_snd_card(const char *id) -{ - return !strncasecmp(id, "msm", 3) ? 0 : -1; -} - static int enum_sndcards() { const char *cards = "/proc/asound/cards"; @@ -208,7 +203,8 @@ static int enum_sndcards() continue; // Only consider sound cards associated with ADSP - if (validate_snd_card((const char *)card_id) < 0) { + if ((strncasecmp(card_id, "msm", 3) != 0) && + (strncasecmp(card_id, "apq", 3) != 0)) { ALOGW("Skip over non-ADSP snd card %s", card_id); continue; }