Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b9e52cd authored by Chris Thornton's avatar Chris Thornton Committed by Android (Google) Code Review
Browse files

Merge "Use new stop_all_recogntions when changing sound trigger state." into nyc-dev

parents 029aaa68 efcf16c9
Loading
Loading
Loading
Loading
+13 −2
Original line number Original line Diff line number Diff line
@@ -70,7 +70,8 @@ void SoundTriggerHwService::onFirstRef()
              SOUND_TRIGGER_HARDWARE_MODULE_ID, HW_MODULE_PREFIX, strerror(-rc));
              SOUND_TRIGGER_HARDWARE_MODULE_ID, HW_MODULE_PREFIX, strerror(-rc));
        return;
        return;
    }
    }
    if (dev->common.version != SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT) {
    if (dev->common.version < SOUND_TRIGGER_DEVICE_API_VERSION_1_0 ||
        dev->common.version > SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT) {
        ALOGE("wrong sound trigger hw device version %04x", dev->common.version);
        ALOGE("wrong sound trigger hw device version %04x", dev->common.version);
        return;
        return;
    }
    }
@@ -808,10 +809,20 @@ void SoundTriggerHwService::Module::setCaptureState_l(bool active)
            goto exit;
            goto exit;
        }
        }


        const bool supports_stop_all =
            (mHwDevice->common.version >= SOUND_TRIGGER_DEVICE_API_VERSION_1_1 &&
             mHwDevice->stop_all_recognitions);

        if (supports_stop_all) {
            mHwDevice->stop_all_recognitions(mHwDevice);
        }

        for (size_t i = 0; i < mModels.size(); i++) {
        for (size_t i = 0; i < mModels.size(); i++) {
            sp<Model> model = mModels.valueAt(i);
            sp<Model> model = mModels.valueAt(i);
            if (model->mState == Model::STATE_ACTIVE) {
            if (model->mState == Model::STATE_ACTIVE) {
                if (!supports_stop_all) {
                    mHwDevice->stop_recognition(mHwDevice, model->mHandle);
                    mHwDevice->stop_recognition(mHwDevice, model->mHandle);
                }
                // keep model in ACTIVE state so that event is processed by onCallbackEvent()
                // keep model in ACTIVE state so that event is processed by onCallbackEvent()
                if (model->mType == SOUND_MODEL_TYPE_KEYPHRASE) {
                if (model->mType == SOUND_MODEL_TYPE_KEYPHRASE) {
                    struct sound_trigger_phrase_recognition_event event;
                    struct sound_trigger_phrase_recognition_event event;