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

Commit 6e189b19 authored by mike dooley's avatar mike dooley
Browse files

Converting sound trigger v2.2 getModelState to be asynchronous

Test: built android with checkbuild flag

Change-Id: Ic12dbfe46aae08666ab02a1a8ee0dbb5c2d9381f
Bug-Id: 70206501
parent fd1c9982
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -40,8 +40,7 @@ public:
    virtual status_t startRecognition(sound_model_handle_t handle,
                                      const sp<IMemory>& dataMemory) = 0;
    virtual status_t stopRecognition(sound_model_handle_t handle) = 0;
    virtual status_t getModelState(sound_model_handle_t handle,
                                   sp<IMemory>& eventMemory) = 0;
    virtual status_t getModelState(sound_model_handle_t handle) = 0;

};

+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public:

            status_t startRecognition(sound_model_handle_t handle, const sp<IMemory>& dataMemory);
            status_t stopRecognition(sound_model_handle_t handle);
            status_t getModelState(sound_model_handle_t handle, sp<IMemory>& eventMemory);
            status_t getModelState(sound_model_handle_t handle);

            // BpSoundTriggerClient
            virtual void onRecognitionEvent(const sp<IMemory>& eventMemory);
+3 −15
Original line number Diff line number Diff line
@@ -356,8 +356,7 @@ int SoundTriggerHalHidl::stopAllRecognitions()
    return hidlReturn;
}

int SoundTriggerHalHidl::getModelState(sound_model_handle_t handle,
                                       struct sound_trigger_recognition_event** event)
int SoundTriggerHalHidl::getModelState(sound_model_handle_t handle)
{
    sp<ISoundTriggerHw> soundtrigger = getService();
    if (soundtrigger == 0) {
@@ -377,24 +376,13 @@ int SoundTriggerHalHidl::getModelState(sound_model_handle_t handle,
    }

    int ret = NO_ERROR;
    Return<void> hidlReturn;
    Return<int32_t> hidlReturn(0);
    {
        AutoMutex lock(mHalLock);
        hidlReturn = soundtrigger_2_2->getModelState(
            model->mHalHandle,
            [&](int r, const V2_0_ISoundTriggerHwCallback::RecognitionEvent& halEvent) {
              ret = r;
              if (ret != 0) {
                  ALOGE("getModelState returned error code %d", ret);
              } else {
                  *event = convertRecognitionEventFromHal(&halEvent);
              }
            });
        hidlReturn = soundtrigger_2_2->getModelState(model->mHalHandle);
    }
    if (!hidlReturn.isOk()) {
        ALOGE("getModelState error %s", hidlReturn.description().c_str());
        free(*event);
        *event = nullptr;
        ret = FAILED_TRANSACTION;
    }
    return ret;
+4 −4
Original line number Diff line number Diff line
@@ -96,12 +96,12 @@ public:
        virtual int stopAllRecognitions();

        /* Get the current state of a given model.
         * Returns 0 or an error code. If successful it also sets indicated the event pointer
         * and expectes that the caller will free the memory.
         * Returns 0 or an error code. If successful the state will be returned asynchronously
         * via a recognition event in the callback method that was registered in the
         * startRecognition() method.
         * Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_2 or above.
         */
        virtual int getModelState(sound_model_handle_t handle,
                                  struct sound_trigger_recognition_event** event);
        virtual int getModelState(sound_model_handle_t handle);

        // ISoundTriggerHwCallback
        virtual ::android::hardware::Return<void> recognitionCallback(
+4 −4
Original line number Diff line number Diff line
@@ -72,12 +72,12 @@ public:
        virtual int stopAllRecognitions() = 0;

        /* Get the current state of a given model.
         * Returns 0 or an error code. If successful it also sets indicated the event pointer
         * and expectes that the caller will free the memory.
         * Returns 0 or an error code. If successful the state will be returned asynchronously
         * via a recognition event in the callback method that was registered in the
         * startRecognition() method.
         * Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_2 or above.
         */
        virtual int getModelState(sound_model_handle_t handle,
                                  struct sound_trigger_recognition_event** event) = 0;
        virtual int getModelState(sound_model_handle_t handle) = 0;

protected:
        SoundTriggerHalInterface() {}
Loading