diff options
author | Eric Laurent <elaurent@google.com> | 2014-12-19 11:16:32 -0800 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-12-19 12:01:31 -0800 |
commit | a34c9ce292ea984e92d8f70d2c056e5372c4f452 (patch) | |
tree | cea445f4cdb835a54814ea93da1d2452869800fd /services/audiopolicy | |
parent | 2cbe89a82d4167c5d5bcf3024edc22ab6874143a (diff) | |
download | frameworks_av-a34c9ce292ea984e92d8f70d2c056e5372c4f452.zip frameworks_av-a34c9ce292ea984e92d8f70d2c056e5372c4f452.tar.gz frameworks_av-a34c9ce292ea984e92d8f70d2c056e5372c4f452.tar.bz2 |
audio policy: fix isSourceActive() for hotword
Only condider AUDIO_SOURCE_HOTWORD equivalent to
AUDIO_SOURCE_VOICE_RECOGNITION if the active capture
was triggered by a hardware hotword recognition.
Also fix activeInputsCount().
Bug: 18802896.
Change-Id: I471aafcae29a76e9c323c6c0c314ef083991476b
Diffstat (limited to 'services/audiopolicy')
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index be7158f..34c677c 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -2055,12 +2055,23 @@ bool AudioPolicyManager::isSourceActive(audio_source_t source) const { for (size_t i = 0; i < mInputs.size(); i++) { const sp<AudioInputDescriptor> inputDescriptor = mInputs.valueAt(i); - if ((inputDescriptor->mInputSource == (int)source || - (source == AUDIO_SOURCE_VOICE_RECOGNITION && - inputDescriptor->mInputSource == AUDIO_SOURCE_HOTWORD)) - && (inputDescriptor->mRefCount > 0)) { + if (inputDescriptor->mRefCount == 0) { + continue; + } + if (inputDescriptor->mInputSource == (int)source) { return true; } + // AUDIO_SOURCE_HOTWORD is equivalent to AUDIO_SOURCE_VOICE_RECOGNITION only if it + // corresponds to an active capture triggered by a hardware hotword recognition + if ((source == AUDIO_SOURCE_VOICE_RECOGNITION) && + (inputDescriptor->mInputSource == AUDIO_SOURCE_HOTWORD)) { + // FIXME: we should not assume that the first session is the active one and keep + // activity count per session. Same in startInput(). + ssize_t index = mSoundTriggerSessions.indexOfKey(inputDescriptor->mSessions.itemAt(0)); + if (index >= 0) { + return true; + } + } } return false; } @@ -5296,7 +5307,7 @@ uint32_t AudioPolicyManager::activeInputsCount() const for (size_t i = 0; i < mInputs.size(); i++) { const sp<AudioInputDescriptor> desc = mInputs.valueAt(i); if (desc->mRefCount > 0) { - return count++; + count++; } } return count; |