Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17f32a27 authored by Eric Laurent's avatar Eric Laurent Committed by Android Git Automerger
Browse files

am b915a420: am 57221635: am 5886252a: Merge "audio policy: fix...

am b915a420: am 57221635: am 5886252a: Merge "audio policy: fix isSourceActive() for hotword" into lmp-mr1-dev

* commit 'b915a420':
  audio policy: fix isSourceActive() for hotword
parents 486a7135 b915a420
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -2055,13 +2055,24 @@ 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;