diff options
author | mike dooley <mdooley@google.com> | 2018-11-07 15:51:56 +0100 |
---|---|---|
committer | mike dooley <mdooley@google.com> | 2018-11-09 10:41:27 +0100 |
commit | 74a792ecc78d40e2224159f1fd2d2cb0a488e459 (patch) | |
tree | 92f72d82064200b194c11bd6f677352bdd66e6fa /soundtrigger | |
parent | efb5f951c5a283c009691080365122b026be7a74 (diff) | |
download | platform_hardware_interfaces-74a792ecc78d40e2224159f1fd2d2cb0a488e459.tar.gz platform_hardware_interfaces-74a792ecc78d40e2224159f1fd2d2cb0a488e459.tar.bz2 platform_hardware_interfaces-74a792ecc78d40e2224159f1fd2d2cb0a488e459.zip |
Converting sound trigger v2.2 getModelState to be asynchronous
Test: built android with checkbuild flag
Change-Id: I68bebde980d2c3a76765cee4c70e213f4430dec1
Bug-Id: 70206501
Diffstat (limited to 'soundtrigger')
-rw-r--r-- | soundtrigger/2.2/ISoundTriggerHw.hal | 18 | ||||
-rw-r--r-- | soundtrigger/2.2/default/SoundTriggerHw.cpp | 29 | ||||
-rw-r--r-- | soundtrigger/2.2/default/SoundTriggerHw.h | 2 | ||||
-rw-r--r-- | soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp | 13 |
4 files changed, 19 insertions, 43 deletions
diff --git a/soundtrigger/2.2/ISoundTriggerHw.hal b/soundtrigger/2.2/ISoundTriggerHw.hal index fcb5087ade..a26896a0f4 100644 --- a/soundtrigger/2.2/ISoundTriggerHw.hal +++ b/soundtrigger/2.2/ISoundTriggerHw.hal @@ -16,25 +16,27 @@ package android.hardware.soundtrigger@2.2; -import @2.0::ISoundTriggerHwCallback.RecognitionEvent; import @2.0::SoundModelHandle; import @2.1::ISoundTriggerHw; /** - * SoundTrigger HAL interface. Used for hardware recognition of hotwords. + * SoundTrigger HAL interface. Used for hardware recognition of hotwords + * and other sounds. */ interface ISoundTriggerHw extends @2.1::ISoundTriggerHw { /** * Get the state of a given model. - * The model state is returned as a RecognitionEvent. - * @param modelHandle The handle of the sound model to use for recognition + * The model state is returned asynchronously as a RecognitionEvent via + * the callback that was registered in StartRecognition(). + * @param modelHandle The handle of the sound model whose state is being + * queried. * @return retval Operation completion status: 0 in case of success, * -ENOSYS in case of invalid model handle, * -ENOMEM in case of memory allocation failure, - * -ENODEV in case of initialization error. - * @return state RecognitionEvent in case of success + * -ENODEV in case of initialization error, + * -EINVAL in case where a recognition event is already + * being processed. */ - getModelState(SoundModelHandle modelHandle) - generates (int32_t retval, @2.0::ISoundTriggerHwCallback.RecognitionEvent state); + getModelState(SoundModelHandle modelHandle) generates (int32_t retval); }; diff --git a/soundtrigger/2.2/default/SoundTriggerHw.cpp b/soundtrigger/2.2/default/SoundTriggerHw.cpp index ffdf9fb569..9d930aca7e 100644 --- a/soundtrigger/2.2/default/SoundTriggerHw.cpp +++ b/soundtrigger/2.2/default/SoundTriggerHw.cpp @@ -690,45 +690,26 @@ void SoundTriggerHw::SoundModelClient_2_1::soundModelCallback( // Begin V2_2 implementation -Return<void> SoundTriggerHw::getModelState(int32_t modelHandle, getModelState_cb hidl_cb) { - int ret = 0; - V2_0::ISoundTriggerHwCallback::RecognitionEvent event; - struct sound_trigger_recognition_event* halEvent = NULL; +Return<int32_t> SoundTriggerHw::getModelState(int32_t modelHandle) { sp<SoundModelClient> client; if (mHwDevice == NULL) { - ret = -ENODEV; - goto exit; + return -ENODEV; } { AutoMutex lock(mLock); client = mClients.valueFor(modelHandle); if (client == 0) { - ret = -ENOSYS; - goto exit; + return -ENOSYS; } } if (mHwDevice->get_model_state == NULL) { ALOGE("Failed to get model state from device, no such method"); - ret = -ENODEV; - goto exit; - } - - // Get the state from the device (as a recognition event) - halEvent = mHwDevice->get_model_state(mHwDevice, client->getHalHandle()); - if (halEvent == NULL) { - ALOGE("Failed to get model state from device"); - ret = -ENODEV; - goto exit; + return -ENODEV; } - convertRecognitionEventFromHal(&event, halEvent); - -exit: - hidl_cb(ret, event); - free(halEvent); - return Void(); + return mHwDevice->get_model_state(mHwDevice, client->getHalHandle()); } // Methods from ::android::hidl::base::V1_0::IBase follow. diff --git a/soundtrigger/2.2/default/SoundTriggerHw.h b/soundtrigger/2.2/default/SoundTriggerHw.h index 876b990a5d..6676318b24 100644 --- a/soundtrigger/2.2/default/SoundTriggerHw.h +++ b/soundtrigger/2.2/default/SoundTriggerHw.h @@ -82,7 +82,7 @@ struct SoundTriggerHw : public ISoundTriggerHw { int32_t cookie) override; // Methods from V2_2::ISoundTriggerHw follow. - Return<void> getModelState(int32_t modelHandle, getModelState_cb _hidl_cb) override; + Return<int32_t> getModelState(int32_t modelHandle) override; SoundTriggerHw(); diff --git a/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp b/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp index a473c3779b..0f37816e47 100644 --- a/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp +++ b/soundtrigger/2.2/vts/functional/VtsHalSoundtriggerV2_2TargetTest.cpp @@ -74,21 +74,14 @@ class SoundTriggerHidlTest : public ::testing::VtsHalHidlTargetTestBase { * Test ISoundTriggerHw::getModelState() method * * Verifies that: - * - the implementation returns -EINVAL with invalid model handle + * - the implementation returns -ENOSYS with invalid model handle * */ TEST_F(SoundTriggerHidlTest, GetModelStateInvalidModel) { - int ret = android::OK; - ::android::hardware::soundtrigger::V2_0::ISoundTriggerHwCallback::RecognitionEvent event; SoundModelHandle handle = 0; - Return<void> hidlReturn = - mSoundTriggerHal->getModelState(handle, [&](int32_t retval, auto res) { - ret = retval; - event = res; - }); - + Return<int32_t> hidlReturn = mSoundTriggerHal->getModelState(handle); EXPECT_TRUE(hidlReturn.isOk()); - EXPECT_EQ(-ENOSYS, ret); + EXPECT_EQ(-ENOSYS, hidlReturn); } int main(int argc, char** argv) { |