soundtrigger: Apply clang-format to 2.0 default implementation
The implementation needs to be updated to become extensible. The current coding style is not consistent with the style required for hardware/interfaces. Reformatted with: clang-format -style=file -i <...>/SoundTriggerHalImpl.* No manual changes. Bug: 68823037 Change-Id: I5f5cbb599190a515dec8afe9026ca835b8fd20fa Test: make
This commit is contained in:
parent
882d2377ec
commit
0bbc4aa61f
2 changed files with 169 additions and 225 deletions
|
@ -17,9 +17,8 @@
|
||||||
#define LOG_TAG "SoundTriggerHalImpl"
|
#define LOG_TAG "SoundTriggerHalImpl"
|
||||||
//#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
|
|
||||||
#include <android/log.h>
|
|
||||||
#include "SoundTriggerHalImpl.h"
|
#include "SoundTriggerHalImpl.h"
|
||||||
|
#include <android/log.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
|
@ -28,15 +27,14 @@ namespace V2_0 {
|
||||||
namespace implementation {
|
namespace implementation {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void SoundTriggerHalImpl::soundModelCallback(struct sound_trigger_model_event *halEvent,
|
void SoundTriggerHalImpl::soundModelCallback(struct sound_trigger_model_event* halEvent,
|
||||||
void *cookie)
|
void* cookie) {
|
||||||
{
|
|
||||||
if (halEvent == NULL) {
|
if (halEvent == NULL) {
|
||||||
ALOGW("soundModelCallback called with NULL event");
|
ALOGW("soundModelCallback called with NULL event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sp<SoundModelClient> client =
|
sp<SoundModelClient> client =
|
||||||
wp<SoundModelClient>(static_cast<SoundModelClient *>(cookie)).promote();
|
wp<SoundModelClient>(static_cast<SoundModelClient*>(cookie)).promote();
|
||||||
if (client == 0) {
|
if (client == 0) {
|
||||||
ALOGW("soundModelCallback called on stale client");
|
ALOGW("soundModelCallback called on stale client");
|
||||||
return;
|
return;
|
||||||
|
@ -55,37 +53,33 @@ void SoundTriggerHalImpl::soundModelCallback(struct sound_trigger_model_event *h
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void SoundTriggerHalImpl::recognitionCallback(struct sound_trigger_recognition_event *halEvent,
|
void SoundTriggerHalImpl::recognitionCallback(struct sound_trigger_recognition_event* halEvent,
|
||||||
void *cookie)
|
void* cookie) {
|
||||||
{
|
|
||||||
if (halEvent == NULL) {
|
if (halEvent == NULL) {
|
||||||
ALOGW("recognitionCallback call NULL event");
|
ALOGW("recognitionCallback call NULL event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sp<SoundModelClient> client =
|
sp<SoundModelClient> client =
|
||||||
wp<SoundModelClient>(static_cast<SoundModelClient *>(cookie)).promote();
|
wp<SoundModelClient>(static_cast<SoundModelClient*>(cookie)).promote();
|
||||||
if (client == 0) {
|
if (client == 0) {
|
||||||
ALOGW("soundModelCallback called on stale client");
|
ALOGW("soundModelCallback called on stale client");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISoundTriggerHwCallback::RecognitionEvent *event = convertRecognitionEventFromHal(halEvent);
|
ISoundTriggerHwCallback::RecognitionEvent* event = convertRecognitionEventFromHal(halEvent);
|
||||||
event->model = client->mId;
|
event->model = client->mId;
|
||||||
if (halEvent->type == SOUND_MODEL_TYPE_KEYPHRASE) {
|
if (halEvent->type == SOUND_MODEL_TYPE_KEYPHRASE) {
|
||||||
client->mCallback->phraseRecognitionCallback(
|
client->mCallback->phraseRecognitionCallback(
|
||||||
*(reinterpret_cast<ISoundTriggerHwCallback::PhraseRecognitionEvent *>(event)),
|
*(reinterpret_cast<ISoundTriggerHwCallback::PhraseRecognitionEvent*>(event)),
|
||||||
client->mCookie);
|
client->mCookie);
|
||||||
} else {
|
} else {
|
||||||
client->mCallback->recognitionCallback(*event, client->mCookie);
|
client->mCallback->recognitionCallback(*event, client->mCookie);
|
||||||
}
|
}
|
||||||
delete event;
|
delete event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Methods from ::android::hardware::soundtrigger::V2_0::ISoundTriggerHw follow.
|
// Methods from ::android::hardware::soundtrigger::V2_0::ISoundTriggerHw follow.
|
||||||
Return<void> SoundTriggerHalImpl::getProperties(getProperties_cb _hidl_cb)
|
Return<void> SoundTriggerHalImpl::getProperties(getProperties_cb _hidl_cb) {
|
||||||
{
|
|
||||||
ALOGV("getProperties() mHwDevice %p", mHwDevice);
|
ALOGV("getProperties() mHwDevice %p", mHwDevice);
|
||||||
int ret;
|
int ret;
|
||||||
struct sound_trigger_properties halProperties;
|
struct sound_trigger_properties halProperties;
|
||||||
|
@ -100,8 +94,8 @@ Return<void> SoundTriggerHalImpl::getProperties(getProperties_cb _hidl_cb)
|
||||||
|
|
||||||
convertPropertiesFromHal(&properties, &halProperties);
|
convertPropertiesFromHal(&properties, &halProperties);
|
||||||
|
|
||||||
ALOGV("getProperties implementor %s recognitionModes %08x",
|
ALOGV("getProperties implementor %s recognitionModes %08x", properties.implementor.c_str(),
|
||||||
properties.implementor.c_str(), properties.recognitionModes);
|
properties.recognitionModes);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
_hidl_cb(ret, properties);
|
_hidl_cb(ret, properties);
|
||||||
|
@ -109,12 +103,11 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
int SoundTriggerHalImpl::doLoadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
|
int SoundTriggerHalImpl::doLoadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
|
||||||
const sp<ISoundTriggerHwCallback>& callback,
|
const sp<ISoundTriggerHwCallback>& callback,
|
||||||
ISoundTriggerHwCallback::CallbackCookie cookie,
|
ISoundTriggerHwCallback::CallbackCookie cookie,
|
||||||
uint32_t *modelId)
|
uint32_t* modelId) {
|
||||||
{
|
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
struct sound_trigger_sound_model *halSoundModel;
|
struct sound_trigger_sound_model* halSoundModel;
|
||||||
*modelId = 0;
|
*modelId = 0;
|
||||||
sp<SoundModelClient> client;
|
sp<SoundModelClient> client;
|
||||||
|
|
||||||
|
@ -137,13 +130,13 @@ int SoundTriggerHalImpl::doLoadSoundModel(const ISoundTriggerHw::SoundModel& sou
|
||||||
*modelId = nextUniqueId();
|
*modelId = nextUniqueId();
|
||||||
} while (mClients.valueFor(*modelId) != 0 && *modelId != 0);
|
} while (mClients.valueFor(*modelId) != 0 && *modelId != 0);
|
||||||
}
|
}
|
||||||
LOG_ALWAYS_FATAL_IF(*modelId == 0,
|
LOG_ALWAYS_FATAL_IF(*modelId == 0, "wrap around in sound model IDs, num loaded models %zu",
|
||||||
"wrap around in sound model IDs, num loaded models %zu", mClients.size());
|
mClients.size());
|
||||||
|
|
||||||
client = new SoundModelClient(*modelId, callback, cookie);
|
client = new SoundModelClient(*modelId, callback, cookie);
|
||||||
|
|
||||||
ret = mHwDevice->load_sound_model(mHwDevice, halSoundModel, soundModelCallback,
|
ret = mHwDevice->load_sound_model(mHwDevice, halSoundModel, soundModelCallback, client.get(),
|
||||||
client.get(), &client->mHalHandle);
|
&client->mHalHandle);
|
||||||
|
|
||||||
free(halSoundModel);
|
free(halSoundModel);
|
||||||
|
|
||||||
|
@ -163,8 +156,7 @@ exit:
|
||||||
Return<void> SoundTriggerHalImpl::loadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
|
Return<void> SoundTriggerHalImpl::loadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
|
||||||
const sp<ISoundTriggerHwCallback>& callback,
|
const sp<ISoundTriggerHwCallback>& callback,
|
||||||
ISoundTriggerHwCallback::CallbackCookie cookie,
|
ISoundTriggerHwCallback::CallbackCookie cookie,
|
||||||
loadSoundModel_cb _hidl_cb)
|
loadSoundModel_cb _hidl_cb) {
|
||||||
{
|
|
||||||
uint32_t modelId = 0;
|
uint32_t modelId = 0;
|
||||||
int32_t ret = doLoadSoundModel(soundModel, callback, cookie, &modelId);
|
int32_t ret = doLoadSoundModel(soundModel, callback, cookie, &modelId);
|
||||||
|
|
||||||
|
@ -173,21 +165,18 @@ Return<void> SoundTriggerHalImpl::loadSoundModel(const ISoundTriggerHw::SoundMod
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<void> SoundTriggerHalImpl::loadPhraseSoundModel(
|
Return<void> SoundTriggerHalImpl::loadPhraseSoundModel(
|
||||||
const ISoundTriggerHw::PhraseSoundModel& soundModel,
|
const ISoundTriggerHw::PhraseSoundModel& soundModel,
|
||||||
const sp<ISoundTriggerHwCallback>& callback,
|
const sp<ISoundTriggerHwCallback>& callback, ISoundTriggerHwCallback::CallbackCookie cookie,
|
||||||
ISoundTriggerHwCallback::CallbackCookie cookie,
|
ISoundTriggerHw::loadPhraseSoundModel_cb _hidl_cb) {
|
||||||
ISoundTriggerHw::loadPhraseSoundModel_cb _hidl_cb)
|
|
||||||
{
|
|
||||||
uint32_t modelId = 0;
|
uint32_t modelId = 0;
|
||||||
int32_t ret = doLoadSoundModel((const ISoundTriggerHw::SoundModel&)soundModel,
|
int32_t ret = doLoadSoundModel((const ISoundTriggerHw::SoundModel&)soundModel, callback, cookie,
|
||||||
callback, cookie, &modelId);
|
&modelId);
|
||||||
|
|
||||||
_hidl_cb(ret, modelId);
|
_hidl_cb(ret, modelId);
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<int32_t> SoundTriggerHalImpl::unloadSoundModel(SoundModelHandle modelHandle)
|
Return<int32_t> SoundTriggerHalImpl::unloadSoundModel(SoundModelHandle modelHandle) {
|
||||||
{
|
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
sp<SoundModelClient> client;
|
sp<SoundModelClient> client;
|
||||||
|
|
||||||
|
@ -213,14 +202,13 @@ exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<int32_t> SoundTriggerHalImpl::startRecognition(SoundModelHandle modelHandle,
|
Return<int32_t> SoundTriggerHalImpl::startRecognition(
|
||||||
const ISoundTriggerHw::RecognitionConfig& config,
|
SoundModelHandle modelHandle, const ISoundTriggerHw::RecognitionConfig& config,
|
||||||
const sp<ISoundTriggerHwCallback>& callback __unused,
|
const sp<ISoundTriggerHwCallback>& callback __unused,
|
||||||
ISoundTriggerHwCallback::CallbackCookie cookie __unused)
|
ISoundTriggerHwCallback::CallbackCookie cookie __unused) {
|
||||||
{
|
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
sp<SoundModelClient> client;
|
sp<SoundModelClient> client;
|
||||||
struct sound_trigger_recognition_config *halConfig;
|
struct sound_trigger_recognition_config* halConfig;
|
||||||
|
|
||||||
if (mHwDevice == NULL) {
|
if (mHwDevice == NULL) {
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
|
@ -236,7 +224,6 @@ Return<int32_t> SoundTriggerHalImpl::startRecognition(SoundModelHandle modelHand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
halConfig = convertRecognitionConfigToHal(&config);
|
halConfig = convertRecognitionConfigToHal(&config);
|
||||||
|
|
||||||
if (halConfig == NULL) {
|
if (halConfig == NULL) {
|
||||||
|
@ -244,7 +231,7 @@ Return<int32_t> SoundTriggerHalImpl::startRecognition(SoundModelHandle modelHand
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
ret = mHwDevice->start_recognition(mHwDevice, client->mHalHandle, halConfig,
|
ret = mHwDevice->start_recognition(mHwDevice, client->mHalHandle, halConfig,
|
||||||
recognitionCallback, client.get());
|
recognitionCallback, client.get());
|
||||||
|
|
||||||
free(halConfig);
|
free(halConfig);
|
||||||
|
|
||||||
|
@ -252,8 +239,7 @@ exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<int32_t> SoundTriggerHalImpl::stopRecognition(SoundModelHandle modelHandle)
|
Return<int32_t> SoundTriggerHalImpl::stopRecognition(SoundModelHandle modelHandle) {
|
||||||
{
|
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
sp<SoundModelClient> client;
|
sp<SoundModelClient> client;
|
||||||
if (mHwDevice == NULL) {
|
if (mHwDevice == NULL) {
|
||||||
|
@ -276,8 +262,7 @@ exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<int32_t> SoundTriggerHalImpl::stopAllRecognitions()
|
Return<int32_t> SoundTriggerHalImpl::stopAllRecognitions() {
|
||||||
{
|
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
if (mHwDevice == NULL) {
|
if (mHwDevice == NULL) {
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
|
@ -285,7 +270,7 @@ Return<int32_t> SoundTriggerHalImpl::stopAllRecognitions()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHwDevice->common.version >= SOUND_TRIGGER_DEVICE_API_VERSION_1_1 &&
|
if (mHwDevice->common.version >= SOUND_TRIGGER_DEVICE_API_VERSION_1_1 &&
|
||||||
mHwDevice->stop_all_recognitions) {
|
mHwDevice->stop_all_recognitions) {
|
||||||
ret = mHwDevice->stop_all_recognitions(mHwDevice);
|
ret = mHwDevice->stop_all_recognitions(mHwDevice);
|
||||||
} else {
|
} else {
|
||||||
ret = -ENOSYS;
|
ret = -ENOSYS;
|
||||||
|
@ -295,19 +280,16 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundTriggerHalImpl::SoundTriggerHalImpl()
|
SoundTriggerHalImpl::SoundTriggerHalImpl()
|
||||||
: mModuleName("primary"), mHwDevice(NULL), mNextModelId(1)
|
: mModuleName("primary"), mHwDevice(NULL), mNextModelId(1) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SoundTriggerHalImpl::onFirstRef()
|
void SoundTriggerHalImpl::onFirstRef() {
|
||||||
{
|
const hw_module_t* mod;
|
||||||
const hw_module_t *mod;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = hw_get_module_by_class(SOUND_TRIGGER_HARDWARE_MODULE_ID, mModuleName, &mod);
|
rc = hw_get_module_by_class(SOUND_TRIGGER_HARDWARE_MODULE_ID, mModuleName, &mod);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ALOGE("couldn't load sound trigger module %s.%s (%s)",
|
ALOGE("couldn't load sound trigger module %s.%s (%s)", SOUND_TRIGGER_HARDWARE_MODULE_ID,
|
||||||
SOUND_TRIGGER_HARDWARE_MODULE_ID, mModuleName, strerror(-rc));
|
mModuleName, strerror(-rc));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rc = sound_trigger_hw_device_open(mod, &mHwDevice);
|
rc = sound_trigger_hw_device_open(mod, &mHwDevice);
|
||||||
|
@ -318,7 +300,7 @@ void SoundTriggerHalImpl::onFirstRef()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mHwDevice->common.version < SOUND_TRIGGER_DEVICE_API_VERSION_1_0 ||
|
if (mHwDevice->common.version < SOUND_TRIGGER_DEVICE_API_VERSION_1_0 ||
|
||||||
mHwDevice->common.version > SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT) {
|
mHwDevice->common.version > SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT) {
|
||||||
ALOGE("wrong sound trigger hw device version %04x", mHwDevice->common.version);
|
ALOGE("wrong sound trigger hw device version %04x", mHwDevice->common.version);
|
||||||
sound_trigger_hw_device_close(mHwDevice);
|
sound_trigger_hw_device_close(mHwDevice);
|
||||||
mHwDevice = NULL;
|
mHwDevice = NULL;
|
||||||
|
@ -328,22 +310,18 @@ void SoundTriggerHalImpl::onFirstRef()
|
||||||
ALOGI("onFirstRef() mModuleName %s mHwDevice %p", mModuleName, mHwDevice);
|
ALOGI("onFirstRef() mModuleName %s mHwDevice %p", mModuleName, mHwDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundTriggerHalImpl::~SoundTriggerHalImpl()
|
SoundTriggerHalImpl::~SoundTriggerHalImpl() {
|
||||||
{
|
|
||||||
if (mHwDevice != NULL) {
|
if (mHwDevice != NULL) {
|
||||||
sound_trigger_hw_device_close(mHwDevice);
|
sound_trigger_hw_device_close(mHwDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SoundTriggerHalImpl::nextUniqueId()
|
uint32_t SoundTriggerHalImpl::nextUniqueId() {
|
||||||
{
|
return (uint32_t)atomic_fetch_add_explicit(&mNextModelId, (uint_fast32_t)1,
|
||||||
return (uint32_t) atomic_fetch_add_explicit(&mNextModelId,
|
memory_order_acq_rel);
|
||||||
(uint_fast32_t) 1, memory_order_acq_rel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundTriggerHalImpl::convertUuidFromHal(Uuid *uuid,
|
void SoundTriggerHalImpl::convertUuidFromHal(Uuid* uuid, const sound_trigger_uuid_t* halUuid) {
|
||||||
const sound_trigger_uuid_t *halUuid)
|
|
||||||
{
|
|
||||||
uuid->timeLow = halUuid->timeLow;
|
uuid->timeLow = halUuid->timeLow;
|
||||||
uuid->timeMid = halUuid->timeMid;
|
uuid->timeMid = halUuid->timeMid;
|
||||||
uuid->versionAndTimeHigh = halUuid->timeHiAndVersion;
|
uuid->versionAndTimeHigh = halUuid->timeHiAndVersion;
|
||||||
|
@ -351,9 +329,7 @@ void SoundTriggerHalImpl::convertUuidFromHal(Uuid *uuid,
|
||||||
memcpy(&uuid->node[0], &halUuid->node[0], 6);
|
memcpy(&uuid->node[0], &halUuid->node[0], 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundTriggerHalImpl::convertUuidToHal(sound_trigger_uuid_t *halUuid,
|
void SoundTriggerHalImpl::convertUuidToHal(sound_trigger_uuid_t* halUuid, const Uuid* uuid) {
|
||||||
const Uuid *uuid)
|
|
||||||
{
|
|
||||||
halUuid->timeLow = uuid->timeLow;
|
halUuid->timeLow = uuid->timeLow;
|
||||||
halUuid->timeMid = uuid->timeMid;
|
halUuid->timeMid = uuid->timeMid;
|
||||||
halUuid->timeHiAndVersion = uuid->versionAndTimeHigh;
|
halUuid->timeHiAndVersion = uuid->versionAndTimeHigh;
|
||||||
|
@ -362,9 +338,7 @@ void SoundTriggerHalImpl::convertUuidToHal(sound_trigger_uuid_t *halUuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundTriggerHalImpl::convertPropertiesFromHal(
|
void SoundTriggerHalImpl::convertPropertiesFromHal(
|
||||||
ISoundTriggerHw::Properties *properties,
|
ISoundTriggerHw::Properties* properties, const struct sound_trigger_properties* halProperties) {
|
||||||
const struct sound_trigger_properties *halProperties)
|
|
||||||
{
|
|
||||||
properties->implementor = halProperties->implementor;
|
properties->implementor = halProperties->implementor;
|
||||||
properties->description = halProperties->description;
|
properties->description = halProperties->description;
|
||||||
properties->version = halProperties->version;
|
properties->version = halProperties->version;
|
||||||
|
@ -378,13 +352,10 @@ void SoundTriggerHalImpl::convertPropertiesFromHal(
|
||||||
properties->concurrentCapture = halProperties->concurrent_capture;
|
properties->concurrentCapture = halProperties->concurrent_capture;
|
||||||
properties->triggerInEvent = halProperties->trigger_in_event;
|
properties->triggerInEvent = halProperties->trigger_in_event;
|
||||||
properties->powerConsumptionMw = halProperties->power_consumption_mw;
|
properties->powerConsumptionMw = halProperties->power_consumption_mw;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundTriggerHalImpl::convertTriggerPhraseToHal(
|
void SoundTriggerHalImpl::convertTriggerPhraseToHal(struct sound_trigger_phrase* halTriggerPhrase,
|
||||||
struct sound_trigger_phrase *halTriggerPhrase,
|
const ISoundTriggerHw::Phrase* triggerPhrase) {
|
||||||
const ISoundTriggerHw::Phrase *triggerPhrase)
|
|
||||||
{
|
|
||||||
halTriggerPhrase->id = triggerPhrase->id;
|
halTriggerPhrase->id = triggerPhrase->id;
|
||||||
halTriggerPhrase->recognition_mode = triggerPhrase->recognitionModes;
|
halTriggerPhrase->recognition_mode = triggerPhrase->recognitionModes;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -395,39 +366,35 @@ void SoundTriggerHalImpl::convertTriggerPhraseToHal(
|
||||||
halTriggerPhrase->users[i] = triggerPhrase->users[i];
|
halTriggerPhrase->users[i] = triggerPhrase->users[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
strlcpy(halTriggerPhrase->locale,
|
strlcpy(halTriggerPhrase->locale, triggerPhrase->locale.c_str(), SOUND_TRIGGER_MAX_LOCALE_LEN);
|
||||||
triggerPhrase->locale.c_str(), SOUND_TRIGGER_MAX_LOCALE_LEN);
|
strlcpy(halTriggerPhrase->text, triggerPhrase->text.c_str(), SOUND_TRIGGER_MAX_STRING_LEN);
|
||||||
strlcpy(halTriggerPhrase->text,
|
|
||||||
triggerPhrase->text.c_str(), SOUND_TRIGGER_MAX_STRING_LEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sound_trigger_sound_model *SoundTriggerHalImpl::convertSoundModelToHal(
|
struct sound_trigger_sound_model* SoundTriggerHalImpl::convertSoundModelToHal(
|
||||||
const ISoundTriggerHw::SoundModel *soundModel)
|
const ISoundTriggerHw::SoundModel* soundModel) {
|
||||||
{
|
struct sound_trigger_sound_model* halModel = NULL;
|
||||||
struct sound_trigger_sound_model *halModel = NULL;
|
|
||||||
if (soundModel->type == SoundModelType::KEYPHRASE) {
|
if (soundModel->type == SoundModelType::KEYPHRASE) {
|
||||||
size_t allocSize =
|
size_t allocSize =
|
||||||
sizeof(struct sound_trigger_phrase_sound_model) + soundModel->data.size();
|
sizeof(struct sound_trigger_phrase_sound_model) + soundModel->data.size();
|
||||||
struct sound_trigger_phrase_sound_model *halKeyPhraseModel =
|
struct sound_trigger_phrase_sound_model* halKeyPhraseModel =
|
||||||
static_cast<struct sound_trigger_phrase_sound_model *>(malloc(allocSize));
|
static_cast<struct sound_trigger_phrase_sound_model*>(malloc(allocSize));
|
||||||
LOG_ALWAYS_FATAL_IF(halKeyPhraseModel == NULL,
|
LOG_ALWAYS_FATAL_IF(halKeyPhraseModel == NULL,
|
||||||
"malloc failed for size %zu in convertSoundModelToHal PHRASE", allocSize);
|
"malloc failed for size %zu in convertSoundModelToHal PHRASE",
|
||||||
|
allocSize);
|
||||||
|
|
||||||
const ISoundTriggerHw::PhraseSoundModel *keyPhraseModel =
|
const ISoundTriggerHw::PhraseSoundModel* keyPhraseModel =
|
||||||
reinterpret_cast<const ISoundTriggerHw::PhraseSoundModel *>(soundModel);
|
reinterpret_cast<const ISoundTriggerHw::PhraseSoundModel*>(soundModel);
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < keyPhraseModel->phrases.size() && i < SOUND_TRIGGER_MAX_PHRASES; i++) {
|
for (i = 0; i < keyPhraseModel->phrases.size() && i < SOUND_TRIGGER_MAX_PHRASES; i++) {
|
||||||
convertTriggerPhraseToHal(&halKeyPhraseModel->phrases[i],
|
convertTriggerPhraseToHal(&halKeyPhraseModel->phrases[i], &keyPhraseModel->phrases[i]);
|
||||||
&keyPhraseModel->phrases[i]);
|
|
||||||
}
|
}
|
||||||
halKeyPhraseModel->num_phrases = (unsigned int)i;
|
halKeyPhraseModel->num_phrases = (unsigned int)i;
|
||||||
halModel = reinterpret_cast<struct sound_trigger_sound_model *>(halKeyPhraseModel);
|
halModel = reinterpret_cast<struct sound_trigger_sound_model*>(halKeyPhraseModel);
|
||||||
halModel->data_offset = sizeof(struct sound_trigger_phrase_sound_model);
|
halModel->data_offset = sizeof(struct sound_trigger_phrase_sound_model);
|
||||||
} else {
|
} else {
|
||||||
size_t allocSize =
|
size_t allocSize = sizeof(struct sound_trigger_sound_model) + soundModel->data.size();
|
||||||
sizeof(struct sound_trigger_sound_model) + soundModel->data.size();
|
halModel = static_cast<struct sound_trigger_sound_model*>(malloc(allocSize));
|
||||||
halModel = static_cast<struct sound_trigger_sound_model *>(malloc(allocSize));
|
|
||||||
LOG_ALWAYS_FATAL_IF(halModel == NULL,
|
LOG_ALWAYS_FATAL_IF(halModel == NULL,
|
||||||
"malloc failed for size %zu in convertSoundModelToHal GENERIC",
|
"malloc failed for size %zu in convertSoundModelToHal GENERIC",
|
||||||
allocSize);
|
allocSize);
|
||||||
|
@ -438,17 +405,15 @@ struct sound_trigger_sound_model *SoundTriggerHalImpl::convertSoundModelToHal(
|
||||||
convertUuidToHal(&halModel->uuid, &soundModel->uuid);
|
convertUuidToHal(&halModel->uuid, &soundModel->uuid);
|
||||||
convertUuidToHal(&halModel->vendor_uuid, &soundModel->vendorUuid);
|
convertUuidToHal(&halModel->vendor_uuid, &soundModel->vendorUuid);
|
||||||
halModel->data_size = soundModel->data.size();
|
halModel->data_size = soundModel->data.size();
|
||||||
uint8_t *dst = reinterpret_cast<uint8_t *>(halModel) + halModel->data_offset;
|
uint8_t* dst = reinterpret_cast<uint8_t*>(halModel) + halModel->data_offset;
|
||||||
const uint8_t *src = reinterpret_cast<const uint8_t *>(&soundModel->data[0]);
|
const uint8_t* src = reinterpret_cast<const uint8_t*>(&soundModel->data[0]);
|
||||||
memcpy(dst, src, soundModel->data.size());
|
memcpy(dst, src, soundModel->data.size());
|
||||||
|
|
||||||
return halModel;
|
return halModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundTriggerHalImpl::convertPhraseRecognitionExtraToHal(
|
void SoundTriggerHalImpl::convertPhraseRecognitionExtraToHal(
|
||||||
struct sound_trigger_phrase_recognition_extra *halExtra,
|
struct sound_trigger_phrase_recognition_extra* halExtra, const PhraseRecognitionExtra* extra) {
|
||||||
const PhraseRecognitionExtra *extra)
|
|
||||||
{
|
|
||||||
halExtra->id = extra->id;
|
halExtra->id = extra->id;
|
||||||
halExtra->recognition_modes = extra->recognitionModes;
|
halExtra->recognition_modes = extra->recognitionModes;
|
||||||
halExtra->confidence_level = extra->confidenceLevel;
|
halExtra->confidence_level = extra->confidenceLevel;
|
||||||
|
@ -461,16 +426,14 @@ void SoundTriggerHalImpl::convertPhraseRecognitionExtraToHal(
|
||||||
halExtra->num_levels = i;
|
halExtra->num_levels = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sound_trigger_recognition_config *SoundTriggerHalImpl::convertRecognitionConfigToHal(
|
struct sound_trigger_recognition_config* SoundTriggerHalImpl::convertRecognitionConfigToHal(
|
||||||
const ISoundTriggerHw::RecognitionConfig *config)
|
const ISoundTriggerHw::RecognitionConfig* config) {
|
||||||
{
|
|
||||||
size_t allocSize = sizeof(struct sound_trigger_recognition_config) + config->data.size();
|
size_t allocSize = sizeof(struct sound_trigger_recognition_config) + config->data.size();
|
||||||
struct sound_trigger_recognition_config *halConfig =
|
struct sound_trigger_recognition_config* halConfig =
|
||||||
static_cast<struct sound_trigger_recognition_config *>(malloc(allocSize));
|
static_cast<struct sound_trigger_recognition_config*>(malloc(allocSize));
|
||||||
|
|
||||||
LOG_ALWAYS_FATAL_IF(halConfig == NULL,
|
LOG_ALWAYS_FATAL_IF(halConfig == NULL,
|
||||||
"malloc failed for size %zu in convertRecognitionConfigToHal",
|
"malloc failed for size %zu in convertRecognitionConfigToHal", allocSize);
|
||||||
allocSize);
|
|
||||||
|
|
||||||
halConfig->capture_handle = (audio_io_handle_t)config->captureHandle;
|
halConfig->capture_handle = (audio_io_handle_t)config->captureHandle;
|
||||||
halConfig->capture_device = (audio_devices_t)config->captureDevice;
|
halConfig->capture_device = (audio_devices_t)config->captureDevice;
|
||||||
|
@ -478,44 +441,41 @@ struct sound_trigger_recognition_config *SoundTriggerHalImpl::convertRecognition
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i < config->phrases.size() && i < SOUND_TRIGGER_MAX_PHRASES; i++) {
|
for (i = 0; i < config->phrases.size() && i < SOUND_TRIGGER_MAX_PHRASES; i++) {
|
||||||
convertPhraseRecognitionExtraToHal(&halConfig->phrases[i],
|
convertPhraseRecognitionExtraToHal(&halConfig->phrases[i], &config->phrases[i]);
|
||||||
&config->phrases[i]);
|
|
||||||
}
|
}
|
||||||
halConfig->num_phrases = i;
|
halConfig->num_phrases = i;
|
||||||
|
|
||||||
halConfig->data_offset = sizeof(struct sound_trigger_recognition_config);
|
halConfig->data_offset = sizeof(struct sound_trigger_recognition_config);
|
||||||
halConfig->data_size = config->data.size();
|
halConfig->data_size = config->data.size();
|
||||||
uint8_t *dst = reinterpret_cast<uint8_t *>(halConfig) + halConfig->data_offset;
|
uint8_t* dst = reinterpret_cast<uint8_t*>(halConfig) + halConfig->data_offset;
|
||||||
const uint8_t *src = reinterpret_cast<const uint8_t *>(&config->data[0]);
|
const uint8_t* src = reinterpret_cast<const uint8_t*>(&config->data[0]);
|
||||||
memcpy(dst, src, config->data.size());
|
memcpy(dst, src, config->data.size());
|
||||||
return halConfig;
|
return halConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void SoundTriggerHalImpl::convertSoundModelEventFromHal(ISoundTriggerHwCallback::ModelEvent *event,
|
void SoundTriggerHalImpl::convertSoundModelEventFromHal(
|
||||||
const struct sound_trigger_model_event *halEvent)
|
ISoundTriggerHwCallback::ModelEvent* event, const struct sound_trigger_model_event* halEvent) {
|
||||||
{
|
|
||||||
event->status = (ISoundTriggerHwCallback::SoundModelStatus)halEvent->status;
|
event->status = (ISoundTriggerHwCallback::SoundModelStatus)halEvent->status;
|
||||||
// event->model to be remapped by called
|
// event->model to be remapped by called
|
||||||
event->data.setToExternal(
|
event->data.setToExternal(
|
||||||
const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(halEvent)) + halEvent->data_offset,
|
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(halEvent)) + halEvent->data_offset,
|
||||||
halEvent->data_size);
|
halEvent->data_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
ISoundTriggerHwCallback::RecognitionEvent *SoundTriggerHalImpl::convertRecognitionEventFromHal(
|
ISoundTriggerHwCallback::RecognitionEvent* SoundTriggerHalImpl::convertRecognitionEventFromHal(
|
||||||
const struct sound_trigger_recognition_event *halEvent)
|
const struct sound_trigger_recognition_event* halEvent) {
|
||||||
{
|
ISoundTriggerHwCallback::RecognitionEvent* event;
|
||||||
ISoundTriggerHwCallback::RecognitionEvent * event;
|
|
||||||
|
|
||||||
if (halEvent->type == SOUND_MODEL_TYPE_KEYPHRASE) {
|
if (halEvent->type == SOUND_MODEL_TYPE_KEYPHRASE) {
|
||||||
const struct sound_trigger_phrase_recognition_event *halPhraseEvent =
|
const struct sound_trigger_phrase_recognition_event* halPhraseEvent =
|
||||||
reinterpret_cast<const struct sound_trigger_phrase_recognition_event *>(halEvent);
|
reinterpret_cast<const struct sound_trigger_phrase_recognition_event*>(halEvent);
|
||||||
ISoundTriggerHwCallback::PhraseRecognitionEvent *phraseEvent =
|
ISoundTriggerHwCallback::PhraseRecognitionEvent* phraseEvent =
|
||||||
new ISoundTriggerHwCallback::PhraseRecognitionEvent();
|
new ISoundTriggerHwCallback::PhraseRecognitionEvent();
|
||||||
|
|
||||||
PhraseRecognitionExtra *phraseExtras =
|
PhraseRecognitionExtra* phraseExtras =
|
||||||
new PhraseRecognitionExtra[halPhraseEvent->num_phrases];
|
new PhraseRecognitionExtra[halPhraseEvent->num_phrases];
|
||||||
for (unsigned int i = 0; i < halPhraseEvent->num_phrases; i++) {
|
for (unsigned int i = 0; i < halPhraseEvent->num_phrases; i++) {
|
||||||
convertPhraseRecognitionExtraFromHal(&phraseExtras[i],
|
convertPhraseRecognitionExtraFromHal(&phraseExtras[i],
|
||||||
&halPhraseEvent->phrase_extras[i]);
|
&halPhraseEvent->phrase_extras[i]);
|
||||||
|
@ -524,7 +484,7 @@ ISoundTriggerHwCallback::RecognitionEvent *SoundTriggerHalImpl::convertRecogniti
|
||||||
// FIXME: transfer buffer ownership. should have a method for that in hidl_vec
|
// FIXME: transfer buffer ownership. should have a method for that in hidl_vec
|
||||||
phraseEvent->phraseExtras.resize(halPhraseEvent->num_phrases);
|
phraseEvent->phraseExtras.resize(halPhraseEvent->num_phrases);
|
||||||
delete[] phraseExtras;
|
delete[] phraseExtras;
|
||||||
event = reinterpret_cast<ISoundTriggerHwCallback::RecognitionEvent *>(phraseEvent);
|
event = reinterpret_cast<ISoundTriggerHwCallback::RecognitionEvent*>(phraseEvent);
|
||||||
} else {
|
} else {
|
||||||
event = new ISoundTriggerHwCallback::RecognitionEvent();
|
event = new ISoundTriggerHwCallback::RecognitionEvent();
|
||||||
}
|
}
|
||||||
|
@ -539,26 +499,23 @@ ISoundTriggerHwCallback::RecognitionEvent *SoundTriggerHalImpl::convertRecogniti
|
||||||
event->triggerInData = halEvent->trigger_in_data;
|
event->triggerInData = halEvent->trigger_in_data;
|
||||||
event->audioConfig.sampleRateHz = halEvent->audio_config.sample_rate;
|
event->audioConfig.sampleRateHz = halEvent->audio_config.sample_rate;
|
||||||
event->audioConfig.channelMask =
|
event->audioConfig.channelMask =
|
||||||
(audio::common::V2_0::AudioChannelMask)halEvent->audio_config.channel_mask;
|
(audio::common::V2_0::AudioChannelMask)halEvent->audio_config.channel_mask;
|
||||||
event->audioConfig.format = (audio::common::V2_0::AudioFormat)halEvent->audio_config.format;
|
event->audioConfig.format = (audio::common::V2_0::AudioFormat)halEvent->audio_config.format;
|
||||||
event->data.setToExternal(
|
event->data.setToExternal(
|
||||||
const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(halEvent)) + halEvent->data_offset,
|
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(halEvent)) + halEvent->data_offset,
|
||||||
halEvent->data_size);
|
halEvent->data_size);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void SoundTriggerHalImpl::convertPhraseRecognitionExtraFromHal(
|
void SoundTriggerHalImpl::convertPhraseRecognitionExtraFromHal(
|
||||||
PhraseRecognitionExtra *extra,
|
PhraseRecognitionExtra* extra, const struct sound_trigger_phrase_recognition_extra* halExtra) {
|
||||||
const struct sound_trigger_phrase_recognition_extra *halExtra)
|
|
||||||
{
|
|
||||||
extra->id = halExtra->id;
|
extra->id = halExtra->id;
|
||||||
extra->recognitionModes = halExtra->recognition_modes;
|
extra->recognitionModes = halExtra->recognition_modes;
|
||||||
extra->confidenceLevel = halExtra->confidence_level;
|
extra->confidenceLevel = halExtra->confidence_level;
|
||||||
|
|
||||||
ConfidenceLevel *levels =
|
ConfidenceLevel* levels = new ConfidenceLevel[halExtra->num_levels];
|
||||||
new ConfidenceLevel[halExtra->num_levels];
|
|
||||||
for (unsigned int i = 0; i < halExtra->num_levels; i++) {
|
for (unsigned int i = 0; i < halExtra->num_levels; i++) {
|
||||||
levels[i].userId = halExtra->levels[i].user_id;
|
levels[i].userId = halExtra->levels[i].user_id;
|
||||||
levels[i].levelPercent = halExtra->levels[i].level;
|
levels[i].levelPercent = halExtra->levels[i].level;
|
||||||
|
@ -569,15 +526,11 @@ void SoundTriggerHalImpl::convertPhraseRecognitionExtraFromHal(
|
||||||
delete[] levels;
|
delete[] levels;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISoundTriggerHw *HIDL_FETCH_ISoundTriggerHw(const char* /* name */)
|
ISoundTriggerHw* HIDL_FETCH_ISoundTriggerHw(const char* /* name */) {
|
||||||
{
|
|
||||||
return new SoundTriggerHalImpl();
|
return new SoundTriggerHalImpl();
|
||||||
}
|
}
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace V2_0
|
} // namespace V2_0
|
||||||
} // namespace soundtrigger
|
} // namespace soundtrigger
|
||||||
} // namespace hardware
|
} // namespace hardware
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
|
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
|
||||||
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHwCallback.h>
|
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHwCallback.h>
|
||||||
|
#include <hardware/sound_trigger.h>
|
||||||
#include <hidl/Status.h>
|
#include <hidl/Status.h>
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
#include <utils/threads.h>
|
|
||||||
#include <utils/KeyedVector.h>
|
|
||||||
#include <system/sound_trigger.h>
|
#include <system/sound_trigger.h>
|
||||||
#include <hardware/sound_trigger.h>
|
#include <utils/KeyedVector.h>
|
||||||
|
#include <utils/threads.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
|
@ -35,95 +35,87 @@ namespace implementation {
|
||||||
using ::android::hardware::audio::common::V2_0::Uuid;
|
using ::android::hardware::audio::common::V2_0::Uuid;
|
||||||
using ::android::hardware::soundtrigger::V2_0::ISoundTriggerHwCallback;
|
using ::android::hardware::soundtrigger::V2_0::ISoundTriggerHwCallback;
|
||||||
|
|
||||||
|
|
||||||
class SoundTriggerHalImpl : public ISoundTriggerHw {
|
class SoundTriggerHalImpl : public ISoundTriggerHw {
|
||||||
public:
|
public:
|
||||||
SoundTriggerHalImpl();
|
SoundTriggerHalImpl();
|
||||||
|
|
||||||
// Methods from ::android::hardware::soundtrigger::V2_0::ISoundTriggerHw follow.
|
// Methods from ::android::hardware::soundtrigger::V2_0::ISoundTriggerHw follow.
|
||||||
Return<void> getProperties(getProperties_cb _hidl_cb) override;
|
Return<void> getProperties(getProperties_cb _hidl_cb) override;
|
||||||
Return<void> loadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
|
Return<void> loadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
|
||||||
const sp<ISoundTriggerHwCallback>& callback,
|
const sp<ISoundTriggerHwCallback>& callback,
|
||||||
ISoundTriggerHwCallback::CallbackCookie cookie,
|
ISoundTriggerHwCallback::CallbackCookie cookie,
|
||||||
loadSoundModel_cb _hidl_cb) override;
|
loadSoundModel_cb _hidl_cb) override;
|
||||||
Return<void> loadPhraseSoundModel(const ISoundTriggerHw::PhraseSoundModel& soundModel,
|
Return<void> loadPhraseSoundModel(const ISoundTriggerHw::PhraseSoundModel& soundModel,
|
||||||
const sp<ISoundTriggerHwCallback>& callback,
|
|
||||||
ISoundTriggerHwCallback::CallbackCookie cookie,
|
|
||||||
loadPhraseSoundModel_cb _hidl_cb) override;
|
|
||||||
|
|
||||||
Return<int32_t> unloadSoundModel(SoundModelHandle modelHandle) override;
|
|
||||||
Return<int32_t> startRecognition(SoundModelHandle modelHandle,
|
|
||||||
const ISoundTriggerHw::RecognitionConfig& config,
|
|
||||||
const sp<ISoundTriggerHwCallback>& callback,
|
const sp<ISoundTriggerHwCallback>& callback,
|
||||||
ISoundTriggerHwCallback::CallbackCookie cookie) override;
|
ISoundTriggerHwCallback::CallbackCookie cookie,
|
||||||
Return<int32_t> stopRecognition(SoundModelHandle modelHandle) override;
|
loadPhraseSoundModel_cb _hidl_cb) override;
|
||||||
Return<int32_t> stopAllRecognitions() override;
|
|
||||||
|
|
||||||
// RefBase
|
Return<int32_t> unloadSoundModel(SoundModelHandle modelHandle) override;
|
||||||
virtual void onFirstRef();
|
Return<int32_t> startRecognition(SoundModelHandle modelHandle,
|
||||||
|
const ISoundTriggerHw::RecognitionConfig& config,
|
||||||
|
const sp<ISoundTriggerHwCallback>& callback,
|
||||||
|
ISoundTriggerHwCallback::CallbackCookie cookie) override;
|
||||||
|
Return<int32_t> stopRecognition(SoundModelHandle modelHandle) override;
|
||||||
|
Return<int32_t> stopAllRecognitions() override;
|
||||||
|
|
||||||
static void soundModelCallback(struct sound_trigger_model_event *halEvent,
|
// RefBase
|
||||||
void *cookie);
|
virtual void onFirstRef();
|
||||||
static void recognitionCallback(struct sound_trigger_recognition_event *halEvent,
|
|
||||||
void *cookie);
|
|
||||||
|
|
||||||
private:
|
static void soundModelCallback(struct sound_trigger_model_event* halEvent, void* cookie);
|
||||||
|
static void recognitionCallback(struct sound_trigger_recognition_event* halEvent, void* cookie);
|
||||||
|
|
||||||
class SoundModelClient : public RefBase {
|
private:
|
||||||
public:
|
class SoundModelClient : public RefBase {
|
||||||
SoundModelClient(uint32_t id, sp<ISoundTriggerHwCallback> callback,
|
public:
|
||||||
ISoundTriggerHwCallback::CallbackCookie cookie)
|
SoundModelClient(uint32_t id, sp<ISoundTriggerHwCallback> callback,
|
||||||
: mId(id), mCallback(callback), mCookie(cookie) {}
|
ISoundTriggerHwCallback::CallbackCookie cookie)
|
||||||
virtual ~SoundModelClient() {}
|
: mId(id), mCallback(callback), mCookie(cookie) {}
|
||||||
|
virtual ~SoundModelClient() {}
|
||||||
|
|
||||||
uint32_t mId;
|
uint32_t mId;
|
||||||
sound_model_handle_t mHalHandle;
|
sound_model_handle_t mHalHandle;
|
||||||
sp<ISoundTriggerHwCallback> mCallback;
|
sp<ISoundTriggerHwCallback> mCallback;
|
||||||
ISoundTriggerHwCallback::CallbackCookie mCookie;
|
ISoundTriggerHwCallback::CallbackCookie mCookie;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t nextUniqueId();
|
uint32_t nextUniqueId();
|
||||||
void convertUuidFromHal(Uuid *uuid,
|
void convertUuidFromHal(Uuid* uuid, const sound_trigger_uuid_t* halUuid);
|
||||||
const sound_trigger_uuid_t *halUuid);
|
void convertUuidToHal(sound_trigger_uuid_t* halUuid, const Uuid* uuid);
|
||||||
void convertUuidToHal(sound_trigger_uuid_t *halUuid,
|
void convertPropertiesFromHal(ISoundTriggerHw::Properties* properties,
|
||||||
const Uuid *uuid);
|
const struct sound_trigger_properties* halProperties);
|
||||||
void convertPropertiesFromHal(ISoundTriggerHw::Properties *properties,
|
void convertTriggerPhraseToHal(struct sound_trigger_phrase* halTriggerPhrase,
|
||||||
const struct sound_trigger_properties *halProperties);
|
const ISoundTriggerHw::Phrase* triggerPhrase);
|
||||||
void convertTriggerPhraseToHal(struct sound_trigger_phrase *halTriggerPhrase,
|
// returned HAL sound model must be freed by caller
|
||||||
const ISoundTriggerHw::Phrase *triggerPhrase);
|
struct sound_trigger_sound_model* convertSoundModelToHal(
|
||||||
// returned HAL sound model must be freed by caller
|
const ISoundTriggerHw::SoundModel* soundModel);
|
||||||
struct sound_trigger_sound_model *convertSoundModelToHal(
|
void convertPhraseRecognitionExtraToHal(struct sound_trigger_phrase_recognition_extra* halExtra,
|
||||||
const ISoundTriggerHw::SoundModel *soundModel);
|
const PhraseRecognitionExtra* extra);
|
||||||
void convertPhraseRecognitionExtraToHal(
|
// returned recognition config must be freed by caller
|
||||||
struct sound_trigger_phrase_recognition_extra *halExtra,
|
struct sound_trigger_recognition_config* convertRecognitionConfigToHal(
|
||||||
const PhraseRecognitionExtra *extra);
|
const ISoundTriggerHw::RecognitionConfig* config);
|
||||||
// returned recognition config must be freed by caller
|
|
||||||
struct sound_trigger_recognition_config *convertRecognitionConfigToHal(
|
|
||||||
const ISoundTriggerHw::RecognitionConfig *config);
|
|
||||||
|
|
||||||
|
static void convertSoundModelEventFromHal(ISoundTriggerHwCallback::ModelEvent* event,
|
||||||
|
const struct sound_trigger_model_event* halEvent);
|
||||||
|
static ISoundTriggerHwCallback::RecognitionEvent* convertRecognitionEventFromHal(
|
||||||
|
const struct sound_trigger_recognition_event* halEvent);
|
||||||
|
static void convertPhraseRecognitionExtraFromHal(
|
||||||
|
PhraseRecognitionExtra* extra,
|
||||||
|
const struct sound_trigger_phrase_recognition_extra* halExtra);
|
||||||
|
|
||||||
static void convertSoundModelEventFromHal(ISoundTriggerHwCallback::ModelEvent *event,
|
int doLoadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
|
||||||
const struct sound_trigger_model_event *halEvent);
|
const sp<ISoundTriggerHwCallback>& callback,
|
||||||
static ISoundTriggerHwCallback::RecognitionEvent *convertRecognitionEventFromHal(
|
ISoundTriggerHwCallback::CallbackCookie cookie, uint32_t* modelId);
|
||||||
const struct sound_trigger_recognition_event *halEvent);
|
|
||||||
static void convertPhraseRecognitionExtraFromHal(PhraseRecognitionExtra *extra,
|
|
||||||
const struct sound_trigger_phrase_recognition_extra *halExtra);
|
|
||||||
|
|
||||||
int doLoadSoundModel(const ISoundTriggerHw::SoundModel& soundModel,
|
virtual ~SoundTriggerHalImpl();
|
||||||
const sp<ISoundTriggerHwCallback>& callback,
|
|
||||||
ISoundTriggerHwCallback::CallbackCookie cookie,
|
|
||||||
uint32_t *modelId);
|
|
||||||
|
|
||||||
virtual ~SoundTriggerHalImpl();
|
const char* mModuleName;
|
||||||
|
struct sound_trigger_hw_device* mHwDevice;
|
||||||
const char * mModuleName;
|
volatile atomic_uint_fast32_t mNextModelId;
|
||||||
struct sound_trigger_hw_device* mHwDevice;
|
DefaultKeyedVector<int32_t, sp<SoundModelClient> > mClients;
|
||||||
volatile atomic_uint_fast32_t mNextModelId;
|
Mutex mLock;
|
||||||
DefaultKeyedVector<int32_t, sp<SoundModelClient> > mClients;
|
|
||||||
Mutex mLock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" ISoundTriggerHw *HIDL_FETCH_ISoundTriggerHw(const char *name);
|
extern "C" ISoundTriggerHw* HIDL_FETCH_ISoundTriggerHw(const char* name);
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace V2_0
|
} // namespace V2_0
|
||||||
|
@ -132,4 +124,3 @@ extern "C" ISoundTriggerHw *HIDL_FETCH_ISoundTriggerHw(const char *name);
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
||||||
#endif // ANDROID_HARDWARE_SOUNDTRIGGER_V2_0_IMPLEMENTATION_H
|
#endif // ANDROID_HARDWARE_SOUNDTRIGGER_V2_0_IMPLEMENTATION_H
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue