diff options
author | Eric Laurent <elaurent@google.com> | 2014-11-20 23:25:44 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-11-20 23:25:44 +0000 |
commit | 30dee177d25bf75f8b3fb8a70573de2c04306759 (patch) | |
tree | 77a908537a54a717aed896a185b0990b9a18ec3a /services/soundtrigger/SoundTriggerHwService.cpp | |
parent | d48f1b68b2b824ffcfdbf6aa67ad4696020a8a11 (diff) | |
parent | 8052d933822e51dec3b096cb5fc8a9fbdc076bdc (diff) | |
download | frameworks_av-30dee177d25bf75f8b3fb8a70573de2c04306759.zip frameworks_av-30dee177d25bf75f8b3fb8a70573de2c04306759.tar.gz frameworks_av-30dee177d25bf75f8b3fb8a70573de2c04306759.tar.bz2 |
am 8052d933: Merge "SoundTrigger: allow sound model reloading" into lmp-mr1-dev
* commit '8052d933822e51dec3b096cb5fc8a9fbdc076bdc':
SoundTrigger: allow sound model reloading
Diffstat (limited to 'services/soundtrigger/SoundTriggerHwService.cpp')
-rw-r--r-- | services/soundtrigger/SoundTriggerHwService.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/services/soundtrigger/SoundTriggerHwService.cpp b/services/soundtrigger/SoundTriggerHwService.cpp index b5aaee3..d3b67f6 100644 --- a/services/soundtrigger/SoundTriggerHwService.cpp +++ b/services/soundtrigger/SoundTriggerHwService.cpp @@ -535,6 +535,16 @@ status_t SoundTriggerHwService::Module::loadSoundModel(const sp<IMemory>& modelM (struct sound_trigger_sound_model *)modelMemory->pointer(); AutoMutex lock(mLock); + + if (mModels.size() >= mDescriptor.properties.max_sound_models) { + if (mModels.size() == 0) { + return INVALID_OPERATION; + } + ALOGW("loadSoundModel() max number of models exceeded %d making room for a new one", + mDescriptor.properties.max_sound_models); + unloadSoundModel_l(mModels.valueAt(0)->mHandle); + } + status_t status = mHwDevice->load_sound_model(mHwDevice, sound_model, SoundTriggerHwService::soundModelCallback, @@ -566,6 +576,11 @@ status_t SoundTriggerHwService::Module::unloadSoundModel(sound_model_handle_t ha } AutoMutex lock(mLock); + return unloadSoundModel_l(handle); +} + +status_t SoundTriggerHwService::Module::unloadSoundModel_l(sound_model_handle_t handle) +{ ssize_t index = mModels.indexOfKey(handle); if (index < 0) { return BAD_VALUE; @@ -574,6 +589,7 @@ status_t SoundTriggerHwService::Module::unloadSoundModel(sound_model_handle_t ha mModels.removeItem(handle); if (model->mState == Model::STATE_ACTIVE) { mHwDevice->stop_recognition(mHwDevice, model->mHandle); + model->mState = Model::STATE_IDLE; } AudioSystem::releaseSoundTriggerSession(model->mCaptureSession); return mHwDevice->unload_sound_model(mHwDevice, handle); |