OSDN Git Service

sound trigger: stop recognition on sound model unload
authorEric Laurent <elaurent@google.com>
Mon, 9 Jun 2014 23:20:05 +0000 (16:20 -0700)
committerEric Laurent <elaurent@google.com>
Mon, 9 Jun 2014 23:20:05 +0000 (16:20 -0700)
Force a stop recognition command to the HAL when
unloading a sound model and recognition is still active.

Change-Id: I7379a64a37bbc3eeea08e0e1d59e427de9544a10

services/soundtrigger/SoundTriggerHwService.cpp

index f09e79e..fa59388 100644 (file)
@@ -367,8 +367,12 @@ status_t SoundTriggerHwService::Module::unloadSoundModel(sound_model_handle_t ha
     if (index < 0) {
         return BAD_VALUE;
     }
+    sp<Model> model = mModels.valueAt(index);
     mModels.removeItem(handle);
-
+    if (model->mState == Model::STATE_ACTIVE) {
+        mHwDevice->stop_recognition(mHwDevice, model->mHandle);
+        model->deallocateMemory();
+    }
     return mHwDevice->unload_sound_model(mHwDevice, handle);
 }