|
|
|
@ -168,18 +168,23 @@ int SoundTriggerHalHidl::loadSoundModel(struct sound_trigger_sound_model *sound_
|
|
|
|
|
int ret;
|
|
|
|
|
SoundModelHandle halHandle;
|
|
|
|
|
sp<V2_1_ISoundTriggerHw> soundtrigger_2_1 = toService2_1(soundtrigger);
|
|
|
|
|
sp<V2_2_ISoundTriggerHw> soundtrigger_2_2 = toService2_2(soundtrigger);
|
|
|
|
|
if (sound_model->type == SOUND_MODEL_TYPE_KEYPHRASE) {
|
|
|
|
|
if (!soundtrigger_2_1) {
|
|
|
|
|
ISoundTriggerHw::PhraseSoundModel halSoundModel;
|
|
|
|
|
convertPhraseSoundModelToHal(&halSoundModel, sound_model);
|
|
|
|
|
AutoMutex lock(mHalLock);
|
|
|
|
|
hidlReturn = soundtrigger->loadPhraseSoundModel(
|
|
|
|
|
halSoundModel,
|
|
|
|
|
this, modelId, [&](int32_t retval, auto res) {
|
|
|
|
|
ret = retval;
|
|
|
|
|
halHandle = res;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
if (soundtrigger_2_2) {
|
|
|
|
|
V2_2_ISoundTriggerHw::PhraseSoundModel halSoundModel;
|
|
|
|
|
auto result = convertPhraseSoundModelToHal(&halSoundModel, sound_model);
|
|
|
|
|
if (result.first) {
|
|
|
|
|
AutoMutex lock(mHalLock);
|
|
|
|
|
hidlReturn = soundtrigger_2_2->loadPhraseSoundModel_2_1(
|
|
|
|
|
halSoundModel,
|
|
|
|
|
this, modelId, [&](int32_t retval, auto res) {
|
|
|
|
|
ret = retval;
|
|
|
|
|
halHandle = res;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
return NO_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
} else if (soundtrigger_2_1) {
|
|
|
|
|
V2_1_ISoundTriggerHw::PhraseSoundModel halSoundModel;
|
|
|
|
|
auto result = convertPhraseSoundModelToHal(&halSoundModel, sound_model);
|
|
|
|
|
if (result.first) {
|
|
|
|
@ -193,18 +198,32 @@ int SoundTriggerHalHidl::loadSoundModel(struct sound_trigger_sound_model *sound_
|
|
|
|
|
} else {
|
|
|
|
|
return NO_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!soundtrigger_2_1) {
|
|
|
|
|
ISoundTriggerHw::SoundModel halSoundModel;
|
|
|
|
|
convertSoundModelToHal(&halSoundModel, sound_model);
|
|
|
|
|
} else {
|
|
|
|
|
ISoundTriggerHw::PhraseSoundModel halSoundModel;
|
|
|
|
|
convertPhraseSoundModelToHal(&halSoundModel, sound_model);
|
|
|
|
|
AutoMutex lock(mHalLock);
|
|
|
|
|
hidlReturn = soundtrigger->loadSoundModel(halSoundModel,
|
|
|
|
|
hidlReturn = soundtrigger->loadPhraseSoundModel(
|
|
|
|
|
halSoundModel,
|
|
|
|
|
this, modelId, [&](int32_t retval, auto res) {
|
|
|
|
|
ret = retval;
|
|
|
|
|
halHandle = res;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (soundtrigger_2_2) {
|
|
|
|
|
V2_2_ISoundTriggerHw::SoundModel halSoundModel;
|
|
|
|
|
auto result = convertSoundModelToHal(&halSoundModel, sound_model);
|
|
|
|
|
if (result.first) {
|
|
|
|
|
AutoMutex lock(mHalLock);
|
|
|
|
|
hidlReturn = soundtrigger_2_2->loadSoundModel_2_1(halSoundModel,
|
|
|
|
|
this, modelId, [&](int32_t retval, auto res) {
|
|
|
|
|
ret = retval;
|
|
|
|
|
halHandle = res;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
return NO_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
} else if (soundtrigger_2_1) {
|
|
|
|
|
V2_1_ISoundTriggerHw::SoundModel halSoundModel;
|
|
|
|
|
auto result = convertSoundModelToHal(&halSoundModel, sound_model);
|
|
|
|
|
if (result.first) {
|
|
|
|
@ -217,6 +236,15 @@ int SoundTriggerHalHidl::loadSoundModel(struct sound_trigger_sound_model *sound_
|
|
|
|
|
} else {
|
|
|
|
|
return NO_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ISoundTriggerHw::SoundModel halSoundModel;
|
|
|
|
|
convertSoundModelToHal(&halSoundModel, sound_model);
|
|
|
|
|
AutoMutex lock(mHalLock);
|
|
|
|
|
hidlReturn = soundtrigger->loadSoundModel(halSoundModel,
|
|
|
|
|
this, modelId, [&](int32_t retval, auto res) {
|
|
|
|
|
ret = retval;
|
|
|
|
|
halHandle = res;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -282,16 +310,20 @@ int SoundTriggerHalHidl::startRecognition(sound_model_handle_t handle,
|
|
|
|
|
model->mRecognitionCookie = cookie;
|
|
|
|
|
|
|
|
|
|
sp<V2_1_ISoundTriggerHw> soundtrigger_2_1 = toService2_1(soundtrigger);
|
|
|
|
|
sp<V2_2_ISoundTriggerHw> soundtrigger_2_2 = toService2_2(soundtrigger);
|
|
|
|
|
Return<int32_t> hidlReturn(0);
|
|
|
|
|
|
|
|
|
|
if (!soundtrigger_2_1) {
|
|
|
|
|
ISoundTriggerHw::RecognitionConfig halConfig;
|
|
|
|
|
convertRecognitionConfigToHal(&halConfig, config);
|
|
|
|
|
{
|
|
|
|
|
if (soundtrigger_2_2) {
|
|
|
|
|
V2_2_ISoundTriggerHw::RecognitionConfig halConfig;
|
|
|
|
|
auto result = convertRecognitionConfigToHal(&halConfig, config);
|
|
|
|
|
if (result.first) {
|
|
|
|
|
AutoMutex lock(mHalLock);
|
|
|
|
|
hidlReturn = soundtrigger->startRecognition(model->mHalHandle, halConfig, this, handle);
|
|
|
|
|
hidlReturn = soundtrigger_2_2->startRecognition_2_1(
|
|
|
|
|
model->mHalHandle, halConfig, this, handle);
|
|
|
|
|
} else {
|
|
|
|
|
return NO_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
} else if (soundtrigger_2_1) {
|
|
|
|
|
V2_1_ISoundTriggerHw::RecognitionConfig halConfig;
|
|
|
|
|
auto result = convertRecognitionConfigToHal(&halConfig, config);
|
|
|
|
|
if (result.first) {
|
|
|
|
@ -301,6 +333,13 @@ int SoundTriggerHalHidl::startRecognition(sound_model_handle_t handle,
|
|
|
|
|
} else {
|
|
|
|
|
return NO_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ISoundTriggerHw::RecognitionConfig halConfig;
|
|
|
|
|
convertRecognitionConfigToHal(&halConfig, config);
|
|
|
|
|
{
|
|
|
|
|
AutoMutex lock(mHalLock);
|
|
|
|
|
hidlReturn = soundtrigger->startRecognition(model->mHalHandle, halConfig, this, handle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hidlReturn.isOk()) {
|
|
|
|
|