summaryrefslogtreecommitdiffstats
path: root/services/soundtrigger
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-11-20 10:10:20 -0800
committerEric Laurent <elaurent@google.com>2014-11-20 14:27:00 -0800
commit02eb47cf18793effe9fc7ab34e1b0fe9ea6635bc (patch)
tree2e133219ce8c75a56dc19ba73795f7e6dab69370 /services/soundtrigger
parentec9459c63d1c2969505ffdc4a100646fd07223bd (diff)
downloadframeworks_av-02eb47cf18793effe9fc7ab34e1b0fe9ea6635bc.zip
frameworks_av-02eb47cf18793effe9fc7ab34e1b0fe9ea6635bc.tar.gz
frameworks_av-02eb47cf18793effe9fc7ab34e1b0fe9ea6635bc.tar.bz2
SoundTrigger: allow sound model reloading
Allow reloading a sound model without unloading it before. Bug: 18308781. Change-Id: I31c83b81a03ee1c1e80f4339ca62e6d06fb1a33b
Diffstat (limited to 'services/soundtrigger')
-rw-r--r--services/soundtrigger/SoundTriggerHwService.cpp16
-rw-r--r--services/soundtrigger/SoundTriggerHwService.h3
2 files changed, 19 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);
diff --git a/services/soundtrigger/SoundTriggerHwService.h b/services/soundtrigger/SoundTriggerHwService.h
index d05dacd..2619a5f 100644
--- a/services/soundtrigger/SoundTriggerHwService.h
+++ b/services/soundtrigger/SoundTriggerHwService.h
@@ -141,6 +141,9 @@ public:
private:
+ status_t unloadSoundModel_l(sound_model_handle_t handle);
+
+
Mutex mLock;
wp<SoundTriggerHwService> mService;
struct sound_trigger_hw_device* mHwDevice;