diff options
author | rioskao <rioskao@google.com> | 2020-04-06 16:20:17 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-04-06 16:20:17 +0000 |
commit | 16507e2bc1a6d55b99ad1ca9b2569d58a735bc6e (patch) | |
tree | 0ccfff835b80999867a4ccda1b4432dd791d01f5 | |
parent | 88e355514cc9f4b2eee5120a1b7723ad379e2791 (diff) | |
parent | f96b22fd8c2af23d5cf5c3dbc5b381d551b81090 (diff) | |
download | sound_trigger_hal-16507e2bc1a6d55b99ad1ca9b2569d58a735bc6e.tar.gz |
sthal: refactor hw_properties. am: f96b22fd8c
Change-Id: I6c250fbc76701100dada0d14f0170c20e684066c
-rw-r--r-- | sound_trigger_hw_iaxxx.c | 91 |
1 files changed, 44 insertions, 47 deletions
diff --git a/sound_trigger_hw_iaxxx.c b/sound_trigger_hw_iaxxx.c index 73ea3e5..6e39d2b 100644 --- a/sound_trigger_hw_iaxxx.c +++ b/sound_trigger_hw_iaxxx.c @@ -93,28 +93,32 @@ #define ADNC_STRM_LIBRARY_PATH "/vendor/lib/hw/adnc_strm.primary.default.so" #endif -static const struct sound_trigger_properties hw_properties = { - "Knowles Electronics", // implementor - "Continous VoiceQ", // description - 0, // version - // Version UUID - { 0x80f7dcd5, 0xbb62, 0x4816, 0xa931, {0x9c, 0xaa, 0x52, 0x5d, 0xf5, 0xc7}}, - MAX_MODELS, // max_sound_models - MAX_KEY_PHRASES, // max_key_phrases - MAX_USERS, // max_users - RECOGNITION_MODE_VOICE_TRIGGER | // recognition_mode - RECOGNITION_MODE_GENERIC_TRIGGER, - true, // capture_transition - MAX_BUFFER_MS, // max_capture_ms - true, // concurrent_capture - false, // trigger_in_event - POWER_CONSUMPTION // power_consumption_mw +static struct sound_trigger_properties_extended_1_3 hw_properties = { + { + SOUND_TRIGGER_DEVICE_API_VERSION_1_3, //ST version + sizeof(struct sound_trigger_properties_extended_1_3) + }, + { + "Knowles Electronics", // implementor + "Continuous VoiceQ", // description + 0, // library version + // Version UUID + { 0x80f7dcd5, 0xbb62, 0x4816, 0xa931, {0x9c, 0xaa, 0x52, 0x5d, 0xf5, 0xc7}}, + MAX_MODELS, // max_sound_models + MAX_KEY_PHRASES, // max_key_phrases + MAX_USERS, // max_users + RECOGNITION_MODE_VOICE_TRIGGER | // recognition_mode + RECOGNITION_MODE_GENERIC_TRIGGER, + true, // capture_transition + MAX_BUFFER_MS, // max_capture_ms + true, // concurrent_capture + false, // trigger_in_event + POWER_CONSUMPTION // power_consumption_mw + }, + "9b55e25e-8ea3-4f73-bce9-b37860d57f5a", //supported arch + 0, // audio capability }; -const char codec_arch[SOUND_TRIGGER_MAX_STRING_LEN] = "9b55e25e-8ea3-4f73-bce9-b37860d57f5a"; - -static struct sound_trigger_properties_extended_1_3 hw_properties_1_3; - struct model_info { void *recognition_cookie; void *sound_model_cookie; @@ -2544,7 +2548,7 @@ static int stdev_get_properties( ALOGV("+%s+", __func__); if (properties == NULL) return -EINVAL; - memcpy(properties, &hw_properties, sizeof(struct sound_trigger_properties)); + memcpy(properties, &hw_properties.base, sizeof(struct sound_trigger_properties)); ALOGV("-%s-", __func__); return 0; } @@ -2555,19 +2559,20 @@ static const struct sound_trigger_properties_header* stdev_get_properties_extend struct knowles_sound_trigger_device *stdev = (struct knowles_sound_trigger_device *)dev; ALOGV("+%s+", __func__); - - if (hw_properties_1_3.header.version >= SOUND_TRIGGER_DEVICE_API_VERSION_1_3) { - hw_properties_1_3.base.version = stdev->hotword_version; + pthread_mutex_lock(&stdev->lock); + if (hw_properties.header.version >= SOUND_TRIGGER_DEVICE_API_VERSION_1_3) { + hw_properties.base.version = stdev->hotword_version; ALOGW("SoundTrigger hotword Version is %u", - hw_properties_1_3.base.version); + hw_properties.base.version); } else { - ALOGE("STHAL Version is %u", hw_properties_1_3.header.version); + ALOGE("STHAL Version is %u", hw_properties.header.version); + pthread_mutex_unlock(&stdev->lock); return NULL; } - + pthread_mutex_unlock(&stdev->lock); ALOGV("-%s-", __func__); - return &hw_properties_1_3.header; + return &hw_properties.header; } @@ -3045,24 +3050,25 @@ static int stdev_start_recognition_extended( { struct sound_trigger_recognition_config_extended_1_3 *config_1_3 = (struct sound_trigger_recognition_config_extended_1_3 *)header; + int status = 0; if (header->version >= SOUND_TRIGGER_DEVICE_API_VERSION_1_3) { /* Use old version before we have real usecase */ ALOGD("%s: Running 2_3", __func__); - stdev_start_recognition(dev, sound_model_handle, - &config_1_3->base, - callback, - cookie); + status = stdev_start_recognition(dev, sound_model_handle, + &config_1_3->base, + callback, + cookie); } else { /* Rollback into old start recognition */ ALOGD("%s: Running 2_1", __func__); - stdev_start_recognition(dev, sound_model_handle, - &config_1_3->base, - callback, - cookie); + status = stdev_start_recognition(dev, sound_model_handle, + &config_1_3->base, + callback, + cookie); } - return 0; + return status; } @@ -3534,7 +3540,7 @@ static int stdev_open(const hw_module_t *module, const char *name, stdev->recover_model_list = 0; stdev->rx_active_count = 0; stdev->is_ahal_media_recording = false; - stdev->is_concurrent_capture = hw_properties.concurrent_capture; + stdev->is_concurrent_capture = hw_properties.base.concurrent_capture; stdev->is_sensor_destroy_in_prog = false; stdev->ss_timer_created = false; @@ -3546,15 +3552,6 @@ static int stdev_open(const hw_module_t *module, const char *name, stdev->fw_reset_done_by_hal = false; stdev->hotword_version = 0; - hw_properties_1_3.header.version = SOUND_TRIGGER_DEVICE_API_VERSION_1_3; - hw_properties_1_3.header.size = - sizeof(struct sound_trigger_properties_extended_1_3); - memcpy(&hw_properties_1_3.base, &hw_properties, - sizeof(struct sound_trigger_properties)); - snprintf(hw_properties_1_3.supported_model_arch, - SOUND_TRIGGER_MAX_STRING_LEN, codec_arch); - hw_properties_1_3.audio_capabilities = 0; - str_to_uuid(HOTWORD_AUDIO_MODEL, &stdev->hotword_model_uuid); str_to_uuid(WAKEUP_MODEL, &stdev->wakeup_model_uuid); str_to_uuid(SENSOR_MANAGER_MODEL, &stdev->sensor_model_uuid); |