diff options
author | Eric Laurent <elaurent@google.com> | 2015-09-24 00:22:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-09-24 00:22:57 +0000 |
commit | 45fd99a31d09f247c72f456a9d569d7326a95894 (patch) | |
tree | b06f4ce59dc97d24a1ed5f40614653f5ab95926d /services/audiopolicy/managerdefault/AudioPolicyManager.cpp | |
parent | 047d97b2d046374e2a25c81a984d9cde23f5d781 (diff) | |
parent | 64265b2fb8f5be63b6c2ad4fcbec9acf74705bc4 (diff) | |
download | frameworks_av-45fd99a31d09f247c72f456a9d569d7326a95894.zip frameworks_av-45fd99a31d09f247c72f456a9d569d7326a95894.tar.gz frameworks_av-45fd99a31d09f247c72f456a9d569d7326a95894.tar.bz2 |
Merge "audio policy: fix preemtible capture race" into mnc-dr-dev
Diffstat (limited to 'services/audiopolicy/managerdefault/AudioPolicyManager.cpp')
-rw-r--r-- | services/audiopolicy/managerdefault/AudioPolicyManager.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp index dfb477d..8419ed5 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp @@ -1485,10 +1485,15 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, // If the already active input uses AUDIO_SOURCE_HOTWORD then it is closed, // otherwise the active input continues and the new input cannot be started. sp<AudioInputDescriptor> activeDesc = mInputs.valueFor(activeInput); - if (activeDesc->mInputSource == AUDIO_SOURCE_HOTWORD) { + if ((activeDesc->mInputSource == AUDIO_SOURCE_HOTWORD) && + !activeDesc->hasPreemptedSession(session)) { ALOGW("startInput(%d) preempting low-priority input %d", input, activeInput); - stopInput(activeInput, activeDesc->mSessions.itemAt(0)); - releaseInput(activeInput, activeDesc->mSessions.itemAt(0)); + audio_session_t activeSession = activeDesc->mSessions.itemAt(0); + SortedVector<audio_session_t> sessions = activeDesc->getPreemptedSessions(); + sessions.add(activeSession); + inputDesc->setPreemptedSessions(sessions); + stopInput(activeInput, activeSession); + releaseInput(activeInput, activeSession); } else { ALOGE("startInput(%d) failed: other input %d already started", input, activeInput); return INVALID_OPERATION; @@ -1592,6 +1597,7 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input, if (mInputs.activeInputsCount() == 0) { SoundTrigger::setCaptureState(false); } + inputDesc->clearPreemptedSessions(); } return NO_ERROR; } |