Loading services/audiopolicy/managerdefault/AudioPolicyManager.cpp +46 −1 Original line number Diff line number Diff line Loading @@ -1815,6 +1815,40 @@ bool AudioPolicyManager::isConcurentCaptureAllowed(const sp<AudioInputDescriptor return true; } // FIXME: remove when concurrent capture is ready. This is a hack to work around bug b/63083537. bool AudioPolicyManager::soundTriggerSupportsConcurrentCapture() { if (!mHasComputedSoundTriggerSupportsConcurrentCapture) { bool soundTriggerSupportsConcurrentCapture = false; unsigned int numModules = 0; struct sound_trigger_module_descriptor* nModules = NULL; status_t status = SoundTrigger::listModules(nModules, &numModules); if (status == NO_ERROR && numModules != 0) { nModules = (struct sound_trigger_module_descriptor*) calloc( numModules, sizeof(struct sound_trigger_module_descriptor)); if (nModules == NULL) { // We failed to malloc the buffer, so just say no for now, and hope that we have more // ram the next time this function is called. ALOGE("Failed to allocate buffer for module descriptors"); return false; } status = SoundTrigger::listModules(nModules, &numModules); if (status == NO_ERROR) { soundTriggerSupportsConcurrentCapture = true; for (size_t i = 0; i < numModules; ++i) { soundTriggerSupportsConcurrentCapture &= nModules[i].properties.concurrent_capture; } } free(nModules); } mSoundTriggerSupportsConcurrentCapture = soundTriggerSupportsConcurrentCapture; mHasComputedSoundTriggerSupportsConcurrentCapture = true; } return mSoundTriggerSupportsConcurrentCapture; } status_t AudioPolicyManager::startInput(audio_io_handle_t input, audio_session_t session, Loading Loading @@ -1887,6 +1921,12 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, } } // We only need to check if the sound trigger session supports concurrent capture if the // input is also a sound trigger input. Otherwise, we should preempt any hotword stream // that's running. const bool allowConcurrentWithSoundTrigger = inputDesc->isSoundTrigger() ? soundTriggerSupportsConcurrentCapture() : false; // if capture is allowed, preempt currently active HOTWORD captures for (size_t i = 0; i < activeInputs.size(); i++) { sp<AudioInputDescriptor> activeDesc = activeInputs[i]; Loading @@ -1895,6 +1935,10 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, continue; } if (allowConcurrentWithSoundTrigger && activeDesc->isSoundTrigger()) { continue; } audio_source_t activeSource = activeDesc->inputSource(true); if (activeSource == AUDIO_SOURCE_HOTWORD) { AudioSessionCollection activeSessions = Loading Loading @@ -3491,7 +3535,8 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa mBeaconMuted(false), mTtsOutputAvailable(false), mMasterMono(false), mMusicEffectOutput(AUDIO_IO_HANDLE_NONE) mMusicEffectOutput(AUDIO_IO_HANDLE_NONE), mHasComputedSoundTriggerSupportsConcurrentCapture(false) { mUidCached = getuid(); mpClientInterface = clientInterface; Loading services/audiopolicy/managerdefault/AudioPolicyManager.h +4 −0 Original line number Diff line number Diff line Loading @@ -671,6 +671,10 @@ private: param.addInt(String8(AudioParameter::keyMonoOutput), (int)mMasterMono); mpClientInterface->setParameters(output, param.toString()); } bool soundTriggerSupportsConcurrentCapture(); bool mSoundTriggerSupportsConcurrentCapture; bool mHasComputedSoundTriggerSupportsConcurrentCapture; }; }; Loading
services/audiopolicy/managerdefault/AudioPolicyManager.cpp +46 −1 Original line number Diff line number Diff line Loading @@ -1815,6 +1815,40 @@ bool AudioPolicyManager::isConcurentCaptureAllowed(const sp<AudioInputDescriptor return true; } // FIXME: remove when concurrent capture is ready. This is a hack to work around bug b/63083537. bool AudioPolicyManager::soundTriggerSupportsConcurrentCapture() { if (!mHasComputedSoundTriggerSupportsConcurrentCapture) { bool soundTriggerSupportsConcurrentCapture = false; unsigned int numModules = 0; struct sound_trigger_module_descriptor* nModules = NULL; status_t status = SoundTrigger::listModules(nModules, &numModules); if (status == NO_ERROR && numModules != 0) { nModules = (struct sound_trigger_module_descriptor*) calloc( numModules, sizeof(struct sound_trigger_module_descriptor)); if (nModules == NULL) { // We failed to malloc the buffer, so just say no for now, and hope that we have more // ram the next time this function is called. ALOGE("Failed to allocate buffer for module descriptors"); return false; } status = SoundTrigger::listModules(nModules, &numModules); if (status == NO_ERROR) { soundTriggerSupportsConcurrentCapture = true; for (size_t i = 0; i < numModules; ++i) { soundTriggerSupportsConcurrentCapture &= nModules[i].properties.concurrent_capture; } } free(nModules); } mSoundTriggerSupportsConcurrentCapture = soundTriggerSupportsConcurrentCapture; mHasComputedSoundTriggerSupportsConcurrentCapture = true; } return mSoundTriggerSupportsConcurrentCapture; } status_t AudioPolicyManager::startInput(audio_io_handle_t input, audio_session_t session, Loading Loading @@ -1887,6 +1921,12 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, } } // We only need to check if the sound trigger session supports concurrent capture if the // input is also a sound trigger input. Otherwise, we should preempt any hotword stream // that's running. const bool allowConcurrentWithSoundTrigger = inputDesc->isSoundTrigger() ? soundTriggerSupportsConcurrentCapture() : false; // if capture is allowed, preempt currently active HOTWORD captures for (size_t i = 0; i < activeInputs.size(); i++) { sp<AudioInputDescriptor> activeDesc = activeInputs[i]; Loading @@ -1895,6 +1935,10 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, continue; } if (allowConcurrentWithSoundTrigger && activeDesc->isSoundTrigger()) { continue; } audio_source_t activeSource = activeDesc->inputSource(true); if (activeSource == AUDIO_SOURCE_HOTWORD) { AudioSessionCollection activeSessions = Loading Loading @@ -3491,7 +3535,8 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa mBeaconMuted(false), mTtsOutputAvailable(false), mMasterMono(false), mMusicEffectOutput(AUDIO_IO_HANDLE_NONE) mMusicEffectOutput(AUDIO_IO_HANDLE_NONE), mHasComputedSoundTriggerSupportsConcurrentCapture(false) { mUidCached = getuid(); mpClientInterface = clientInterface; Loading
services/audiopolicy/managerdefault/AudioPolicyManager.h +4 −0 Original line number Diff line number Diff line Loading @@ -671,6 +671,10 @@ private: param.addInt(String8(AudioParameter::keyMonoOutput), (int)mMasterMono); mpClientInterface->setParameters(output, param.toString()); } bool soundTriggerSupportsConcurrentCapture(); bool mSoundTriggerSupportsConcurrentCapture; bool mHasComputedSoundTriggerSupportsConcurrentCapture; }; };