diff options
author | Eric Laurent <elaurent@google.com> | 2015-01-06 08:47:05 -0800 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2015-01-06 08:55:25 -0800 |
commit | c447ded04f11169e9b96b31cd196b2c4ffa9f31c (patch) | |
tree | 77fedcbb54431d1d432d9bdcc58791ec5418c413 /services/audiopolicy | |
parent | 3190e67d5c80c1e39e3be91784110af1180cd182 (diff) | |
download | frameworks_av-c447ded04f11169e9b96b31cd196b2c4ffa9f31c.zip frameworks_av-c447ded04f11169e9b96b31cd196b2c4ffa9f31c.tar.gz frameworks_av-c447ded04f11169e9b96b31cd196b2c4ffa9f31c.tar.bz2 |
fix record from default input source
Commit caf7f48a0e broke capture from default
input source on some devices: the input source is now specified as part of
the audio attributes and the default source was not remapped to mic source.
Bug: 18736417.
Change-Id: I3f5da33cdb56f959aaef68ed1952342babc63aa0
Diffstat (limited to 'services/audiopolicy')
-rw-r--r-- | services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp | 19 | ||||
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.cpp | 20 |
2 files changed, 26 insertions, 13 deletions
diff --git a/services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp b/services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp index 4bc3c7f..b8846c6 100644 --- a/services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp +++ b/services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp @@ -241,14 +241,21 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, if (mpAudioPolicy == NULL) { return NO_INIT; } + + audio_source_t inputSource = attr->source; + // already checked by client, but double-check in case the client wrapper is bypassed - if (attr->source >= AUDIO_SOURCE_CNT && attr->source != AUDIO_SOURCE_HOTWORD && - attr->source != AUDIO_SOURCE_FM_TUNER) { + if (inputSource >= AUDIO_SOURCE_CNT && inputSource != AUDIO_SOURCE_HOTWORD && + inputSource != AUDIO_SOURCE_FM_TUNER) { return BAD_VALUE; } - if (((attr->source == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed()) || - ((attr->source == AUDIO_SOURCE_FM_TUNER) && !captureFmTunerAllowed())) { + if (inputSource == AUDIO_SOURCE_DEFAULT) { + inputSource = AUDIO_SOURCE_MIC; + } + + if (((inputSource == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed()) || + ((inputSource == AUDIO_SOURCE_FM_TUNER) && !captureFmTunerAllowed())) { return BAD_VALUE; } @@ -256,7 +263,7 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, { Mutex::Autolock _l(mLock); // the audio_in_acoustics_t parameter is ignored by get_input() - *input = mpAudioPolicy->get_input(mpAudioPolicy, attr->source, samplingRate, + *input = mpAudioPolicy->get_input(mpAudioPolicy, inputSource, samplingRate, format, channelMask, (audio_in_acoustics_t) 0); audioPolicyEffects = mAudioPolicyEffects; } @@ -266,7 +273,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); } diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index 8d1b3bb..0349327 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -1440,10 +1440,16 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, // handle legacy remote submix case where the address was not always specified String8 address = String8(""); bool isSoundTrigger = false; - audio_source_t halInputSource = attr->source; + audio_source_t inputSource = attr->source; + audio_source_t halInputSource; AudioMix *policyMix = NULL; - if (attr->source == AUDIO_SOURCE_REMOTE_SUBMIX && + if (inputSource == AUDIO_SOURCE_DEFAULT) { + inputSource = AUDIO_SOURCE_MIC; + } + halInputSource = inputSource; + + if (inputSource == AUDIO_SOURCE_REMOTE_SUBMIX && strncmp(attr->tags, "addr=", strlen("addr=")) == 0) { device = AUDIO_DEVICE_IN_REMOTE_SUBMIX; address = String8(attr->tags + strlen("addr=")); @@ -1459,9 +1465,9 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, policyMix = &mPolicyMixes[index]->mMix; *inputType = API_INPUT_MIX_EXT_POLICY_REROUTE; } else { - device = getDeviceAndMixForInputSource(attr->source, &policyMix); + device = getDeviceAndMixForInputSource(inputSource, &policyMix); if (device == AUDIO_DEVICE_NONE) { - ALOGW("getInputForAttr() could not find device for source %d", attr->source); + ALOGW("getInputForAttr() could not find device for source %d", inputSource); return BAD_VALUE; } if (policyMix != NULL) { @@ -1483,7 +1489,7 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, *inputType = API_INPUT_LEGACY; } // adapt channel selection to input source - switch (attr->source) { + switch (inputSource) { case AUDIO_SOURCE_VOICE_UPLINK: channelMask = AUDIO_CHANNEL_IN_VOICE_UPLINK; break; @@ -1496,7 +1502,7 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, default: break; } - if (attr->source == AUDIO_SOURCE_HOTWORD) { + if (inputSource == AUDIO_SOURCE_HOTWORD) { ssize_t index = mSoundTriggerSessions.indexOfKey(session); if (index >= 0) { *input = mSoundTriggerSessions.valueFor(session); @@ -1559,7 +1565,7 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, } sp<AudioInputDescriptor> inputDesc = new AudioInputDescriptor(profile); - inputDesc->mInputSource = attr->source; + inputDesc->mInputSource = inputSource; inputDesc->mRefCount = 0; inputDesc->mOpenRefCount = 1; inputDesc->mSamplingRate = samplingRate; |