From 685a971fe7f5fe32ce1622800563866f9efbc7a0 Mon Sep 17 00:00:00 2001 From: Hiroaki Hayashi Date: Thu, 18 Jul 2019 19:50:47 +0900 Subject: [PATCH] Treat AUDIO_SOURCE_DEFAULT as AUDIO_SOURCE_MIC AUDIO_SOURCE_DEFAULT is translated to AUDIO_SOURCE_MIC in AudioPolicyManager. That means AUDIO_SOURCE_DEFAULT should behave as same as AUDIO_SOURCE_MIC. In this commit, argument for addInputEffects() is translated for avoid different behavior between AUDIO_SOURCE_DEFAULT and AUDIO_SOURCE_MIC. This means same preprocessing effects are applied for both Sources. Bug: 137898521 Test: Add pre-processing effect for AUDIO_SOURCE_MIC then check if it works for AUDIO_SOURCE_DEFAULT as well Change-Id: I3df1bcc7309dc535a721113cc4465b20733b4058 Merged-In: I3df1bcc7309dc535a721113cc4465b20733b4058 --- .../service/AudioPolicyInterfaceImpl.cpp | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp index 47a103b0bd..c1190be343 100644 --- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp +++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp @@ -351,12 +351,17 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, return NO_INIT; } + audio_source_t inputSource = attr->source; + if (inputSource == AUDIO_SOURCE_DEFAULT) { + inputSource = AUDIO_SOURCE_MIC; + } + // already checked by client, but double-check in case the client wrapper is bypassed - if ((attr->source < AUDIO_SOURCE_DEFAULT) - || (attr->source >= AUDIO_SOURCE_CNT - && attr->source != AUDIO_SOURCE_HOTWORD - && attr->source != AUDIO_SOURCE_FM_TUNER - && attr->source != AUDIO_SOURCE_ECHO_REFERENCE)) { + if ((inputSource < AUDIO_SOURCE_DEFAULT) + || (inputSource >= AUDIO_SOURCE_CNT + && inputSource != AUDIO_SOURCE_HOTWORD + && inputSource != AUDIO_SOURCE_FM_TUNER + && inputSource != AUDIO_SOURCE_ECHO_REFERENCE)) { return BAD_VALUE; } @@ -385,16 +390,16 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, } bool canCaptureOutput = captureAudioOutputAllowed(pid, uid); - if ((attr->source == AUDIO_SOURCE_VOICE_UPLINK || - attr->source == AUDIO_SOURCE_VOICE_DOWNLINK || - attr->source == AUDIO_SOURCE_VOICE_CALL || - attr->source == AUDIO_SOURCE_ECHO_REFERENCE) && + if ((inputSource == AUDIO_SOURCE_VOICE_UPLINK || + inputSource == AUDIO_SOURCE_VOICE_DOWNLINK || + inputSource == AUDIO_SOURCE_VOICE_CALL || + inputSource == AUDIO_SOURCE_ECHO_REFERENCE) && !canCaptureOutput) { return PERMISSION_DENIED; } bool canCaptureHotword = captureHotwordAllowed(opPackageName, pid, uid); - if ((attr->source == AUDIO_SOURCE_HOTWORD) && !canCaptureHotword) { + if ((inputSource == AUDIO_SOURCE_HOTWORD) && !canCaptureHotword) { return BAD_VALUE; } @@ -459,7 +464,7 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, if (audioPolicyEffects != 0) { // create audio pre processors according to input source - status_t status = audioPolicyEffects->addInputEffects(*input, attr->source, session); + status_t status = audioPolicyEffects->addInputEffects(*input, inputSource, session); if (status != NO_ERROR && status != ALREADY_EXISTS) { ALOGW("Failed to add effects on input %d", *input); }