From 30753d14f8ffb4552ed2934156c0af508e8f0888 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 18 Oct 2019 13:43:18 +0900 Subject: [PATCH 01/16] Bump version to 0.2.1 Change-Id: If694bf9dbc732a183e70e7e64df7094356748643 --- org.tizen.multi-assistant-service.xml | 2 +- packaging/org.tizen.multi-assistant-service.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.multi-assistant-service.xml b/org.tizen.multi-assistant-service.xml index 4220817..c7ff283 100644 --- a/org.tizen.multi-assistant-service.xml +++ b/org.tizen.multi-assistant-service.xml @@ -1,5 +1,5 @@ - + Won Nam Jang Sooyeon Kim diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index 494261e..663f768 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -1,6 +1,6 @@ Name: org.tizen.multi-assistant-service Summary: Multi assistant service -Version: 0.2.0 +Version: 0.2.1 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From 2fb1daf0e9c8ea41f082cb3afe7ef1a6086e7f66 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 21 Oct 2019 20:55:41 +0900 Subject: [PATCH 02/16] Deactivate wakeup engines with no activated assistant If there is a wakeup engine that no activate assistant specified as its wakeup event source, deactivate it since it would consume resources unnecessarily. Change-Id: I5b88fbe0b7644bdb5601216f46ccedc6566a7938 --- inc/multi_assistant_service_plugin.h | 11 ++ plugins/wakeup-manager/inc/wakeup_engine_manager.h | 1 + plugins/wakeup-manager/inc/wakeup_manager.h | 13 ++- .../wakeup-manager/inc/wakeup_manager_wrapper.h | 4 + plugins/wakeup-manager/inc/wakeup_settings.h | 9 +- .../wakeup-manager/src/wakeup_engine_manager.cpp | 3 +- plugins/wakeup-manager/src/wakeup_manager.cpp | 96 +++++++++++++++- .../wakeup-manager/src/wakeup_manager_wrapper.cpp | 29 +++++ plugins/wakeup-manager/src/wakeup_settings.cpp | 122 ++++++++++++++++++++- src/multi_assistant_service.c | 30 +++-- src/multi_assistant_service_plugin.c | 48 ++++++++ 11 files changed, 343 insertions(+), 23 deletions(-) diff --git a/inc/multi_assistant_service_plugin.h b/inc/multi_assistant_service_plugin.h index 9bb703c..7bfd761 100644 --- a/inc/multi_assistant_service_plugin.h +++ b/inc/multi_assistant_service_plugin.h @@ -53,6 +53,10 @@ int multi_assistant_service_plugin_add_assistant_language(const char* appid, con int multi_assistant_service_plugin_set_assistant_wakeup_engine(const char* appid, const char* engine); +int multi_assistant_service_plugin_set_default_assistant(const char* appid); + +int multi_assistant_service_plugin_get_default_assistant(const char** appid); + int multi_assistant_service_plugin_activate(void); int multi_assistant_service_plugin_deactivate(void); @@ -99,6 +103,7 @@ int multi_assistant_service_plugin_set_speech_status_callback(wakeup_service_spe int multi_assistant_service_plugin_set_error_callback(wakeup_service_error_cb callback, void* user_data); + #define MA_WAKEUP_MANAGER_PATH tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "multiassistant/") #define MA_DEFAULT_WAKEUP_MANAGER_FILENAME "libma-wakeup-manager.so" @@ -116,6 +121,10 @@ typedef int (*wakeup_manager_add_assistant_wakeup_word)(const char* appid, const typedef int (*wakeup_manager_add_assistant_language)(const char* appid, const char* language); #define MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE "wakeup_manager_set_assistant_wakeup_engine" typedef int (*wakeup_manager_set_assistant_wakeup_engine)(const char* appid, const char* engine); +#define MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT "wakeup_manager_set_default_assistant" +typedef int (*wakeup_manager_set_default_assistant)(const char* appid); +#define MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT "wakeup_manager_get_default_assistant" +typedef int (*wakeup_manager_get_default_assistant)(const char** appid); #define MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE "wakeup_manager_set_language" typedef int (*wakeup_manager_set_language)(const char* language); #define MA_WAKEUP_MANAGER_FUNC_ACTIVATE "wakeup_manager_activate" @@ -172,6 +181,8 @@ typedef struct { wakeup_manager_add_assistant_wakeup_word add_assistant_wakeup_word; wakeup_manager_add_assistant_language add_assistant_language; wakeup_manager_set_assistant_wakeup_engine set_assistant_wakeup_engine; + wakeup_manager_set_default_assistant set_default_assistant; + wakeup_manager_get_default_assistant get_default_assistant; wakeup_manager_set_language set_language; wakeup_manager_activate activate; wakeup_manager_deactivate deactivate; diff --git a/plugins/wakeup-manager/inc/wakeup_engine_manager.h b/plugins/wakeup-manager/inc/wakeup_engine_manager.h index 4e24631..49d8e22 100644 --- a/plugins/wakeup-manager/inc/wakeup_engine_manager.h +++ b/plugins/wakeup-manager/inc/wakeup_engine_manager.h @@ -152,6 +152,7 @@ public: bool set_language(string language); void set_assistant_activated(string appid, bool activated); + bool get_assistant_activated(string appid); void set_wake_word_audio_require_flag(bool require); void start_streaming_current_utterance_data(); diff --git a/plugins/wakeup-manager/inc/wakeup_manager.h b/plugins/wakeup-manager/inc/wakeup_manager.h index 645bcfc..d682387 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager.h +++ b/plugins/wakeup-manager/inc/wakeup_manager.h @@ -78,6 +78,11 @@ public: bool add_assistant_wakeup_word(string appid, string wakeup_word, string language); bool set_assistant_wakeup_engine(string appid, string engine); + bool set_assistant_enabled(string appid, bool enabled); + bool get_assistant_enabled(string appid); + bool set_default_assistant(string appid); + string get_default_assistant(); + bool update_voice_feedback_state(string appid, bool state); bool send_assistant_specific_command(string appid, string command); bool set_background_volume(string appid, double ratio); @@ -157,6 +162,8 @@ private: { public: bool on_voice_input_language_changed(const char* language) override; + bool on_assistant_enabled_info_changed(const char* appid, bool enabled) override; + bool on_default_assistant_appid_changed(const char* appid) override; void set_wakeup_manager(CWakeupManager *manager) { mWakeupManager = manager; } private: @@ -170,7 +177,8 @@ private: vector languageList; } AssistantLanguageInfo; vector mAssistantLanguageInfo; - map mAssistantActivated; + map mAssistantSupportsCurrentLanguage; + map mAssistantEnabled; vector mObservers; @@ -190,6 +198,7 @@ private: bool mVoiceKeyPressed{false}; string mCurrentLanguage; + string mCurrentDefaultAssistant; STREAMING_MODE mStreamingMode{STREAMING_MODE::NONE}; Ecore_Timer* mStreamingDurationTimer{nullptr}; @@ -202,4 +211,4 @@ private: } // wakeup } // multiassistant -#endif /* _WAKEUP_MANAGER_H_ */ +#endif /* _WAKEUP_MANAGER_H_ */ \ No newline at end of file diff --git a/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h b/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h index a5acc99..c566d83 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h +++ b/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h @@ -85,6 +85,10 @@ EXPORT_API int wakeup_manager_add_assistant_language(const char* appid, const ch EXPORT_API int wakeup_manager_set_assistant_wakeup_engine(const char* appid, const char *engine); +EXPORT_API int wakeup_manager_set_default_assistant(const char* appid); + +EXPORT_API int wakeup_manager_get_default_assistant(const char** appid); + EXPORT_API int wakeup_manager_set_language(const char* language); EXPORT_API int wakeup_manager_activate(void); diff --git a/plugins/wakeup-manager/inc/wakeup_settings.h b/plugins/wakeup-manager/inc/wakeup_settings.h index e99c72e..99c8fd1 100644 --- a/plugins/wakeup-manager/inc/wakeup_settings.h +++ b/plugins/wakeup-manager/inc/wakeup_settings.h @@ -30,8 +30,6 @@ namespace wakeup using namespace std; -#define DEFAULT_ASSISTANT_APPID "org.tizen.voice-app" - #define WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID "db/multi-assistant/default_assistant_appid" #define WAKEUP_SETTINGS_KEY_UI_PANEL_ENABLED "db/multi-assistant/ui_panel_enabled" #define WAKEUP_SETTINGS_KEY_CONVERSATION_TIMEOUT "db/multi-assistant/conversation_timeout" @@ -47,6 +45,8 @@ class ISettingsEventObserver public: virtual ~ISettingsEventObserver() = default; virtual bool on_voice_input_language_changed(const char* language) = 0; + virtual bool on_assistant_enabled_info_changed(const char* appid, bool enabled) = 0; + virtual bool on_default_assistant_appid_changed(const char* appid) = 0; }; class CWakeupSettings @@ -77,14 +77,15 @@ public: private: vector mObservers; - string mDefaultAssistantAppid{DEFAULT_ASSISTANT_APPID}; + string mDefaultAssistantAppid; bool mUiPanelEnabled{true}; float mConversationTimeout{5.0}; bool mMultipleMode{true}; - vector mEnabledAssistants{DEFAULT_ASSISTANT_APPID}; + vector mEnabledAssistants; float mWakeupPolicyDelay{0.1}; vector mWakeupPolicyPriority; // No priority by default float mStreamingDurationMax{10.0}; + string mVoiceInputLanguage; }; } // wakeup diff --git a/plugins/wakeup-manager/src/wakeup_engine_manager.cpp b/plugins/wakeup-manager/src/wakeup_engine_manager.cpp index 1b159aa..46e9a1d 100644 --- a/plugins/wakeup-manager/src/wakeup_engine_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_engine_manager.cpp @@ -413,7 +413,8 @@ void CWakeupEngineManager::engine_set_assistant_specific_command(string appid, s void CWakeupEngineManager::engine_feed_audio_data(long time, void* data, int len) { for (const auto& info : mEngineInfo) { - if (info.audio_data_require_status && + if (info.activated && + info.audio_data_require_status && info.interface.feed_audio_data) { int ret = info.interface.feed_audio_data(time, data, len); if (0 != ret) { diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 14373df..81ed6eb 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -95,6 +95,7 @@ bool CWakeupManager::initialize() mAudioEventObserver.set_wakeup_manager(this); mSettingsEventObserver.set_wakeup_manager(this); + mWakeupSettings.subscribe(&mSettingsEventObserver); mWakeupSettings.initialize(); mAudioEventObserver.set_wakeup_engine_manager(&mWakeupEngineManager); @@ -112,8 +113,6 @@ bool CWakeupManager::initialize() dependency_resolver_initialize(interface); - mWakeupSettings.subscribe(&mSettingsEventObserver); - MWR_LOGD("[END]"); return true; } @@ -200,6 +199,12 @@ bool CWakeupManager::add_assistant_language(string appid, string language) info.languageList.push_back(language); mAssistantLanguageInfo.push_back(info); } + if (0 == mCurrentLanguage.compare(language)) { + mAssistantSupportsCurrentLanguage[appid] = true; + if (true == mAssistantEnabled[appid]) { + mWakeupEngineManager.set_assistant_activated(appid, true); + } + } MWR_LOGD("[END]"); return true; } @@ -224,6 +229,56 @@ bool CWakeupManager::set_assistant_wakeup_engine(string appid, string engine) return true; } +bool CWakeupManager::set_assistant_enabled(string appid, bool enabled) +{ + MWR_LOGD("[ENTER]"); + + mAssistantEnabled[appid] = enabled; + bool activated = enabled; + if (false == mAssistantSupportsCurrentLanguage[appid]) { + activated = false; + } + if (0 == appid.compare(mCurrentDefaultAssistant)) { + activated = true; + } + mWakeupEngineManager.set_assistant_activated(appid, activated); + + MWR_LOGD("[END]"); + return true; +} + +bool CWakeupManager::set_default_assistant(string appid) +{ + MWR_LOGD("[ENTER]"); + + /* Check if previous default assistant has to be deactivated */ + bool activated = true; + if (false == mAssistantSupportsCurrentLanguage[mCurrentDefaultAssistant]) { + activated = false; + } + if (false == mAssistantEnabled[mCurrentDefaultAssistant]) { + activated = false; + } + mWakeupEngineManager.set_assistant_activated(mCurrentDefaultAssistant, activated); + + /* New default assistant has to be activated no matter what */ + mWakeupEngineManager.set_assistant_activated(appid, true); + mCurrentDefaultAssistant = appid; + + MWR_LOGD("[END]"); + return true; +} + +string CWakeupManager::get_default_assistant() +{ + return mCurrentDefaultAssistant; +} + +bool CWakeupManager::get_assistant_enabled(string appid) +{ + return mAssistantEnabled[appid]; +} + bool CWakeupManager::set_language(string language) { bool ret = false; @@ -242,12 +297,19 @@ bool CWakeupManager::set_language(string language) } } if(false == found) { - mAssistantActivated[info.appid] = false; + mAssistantSupportsCurrentLanguage[info.appid] = false; } else { - mAssistantActivated[info.appid] = true; + mAssistantSupportsCurrentLanguage[info.appid] = true; } - mWakeupEngineManager.set_assistant_activated(info.appid, found); + bool activated = found; + if (false == mAssistantEnabled[info.appid]) { + activated = false; + } + if (0 == info.appid.compare(mCurrentDefaultAssistant)) { + activated = true; + } + mWakeupEngineManager.set_assistant_activated(info.appid, activated); } mWakeupEngineManager.set_language(language); @@ -718,6 +780,14 @@ bool CWakeupManager::CEngineEventObserver::on_wakeup_event(string engine_name, w { MWR_LOGD("[ENTER]"); if (nullptr == mWakeupManager) return false; + if (nullptr == wakeup_info.wakeup_appid) return false; + + if (0 != mWakeupManager->get_default_assistant().compare(wakeup_info.wakeup_appid)) { + if (false == mWakeupManager->get_assistant_enabled(string{wakeup_info.wakeup_appid})) { + MWR_LOGE("Wakeup event with deactivated appid : %s", wakeup_info.wakeup_appid); + return false; + } + } CWakeupPolicy* policy = mWakeupManager->get_wakeup_policy(); if (policy) { @@ -855,5 +925,21 @@ bool CWakeupManager::CSettingsEventObserver::on_voice_input_language_changed( return true; } +bool CWakeupManager::CSettingsEventObserver::on_assistant_enabled_info_changed( + const char* appid, bool enabled) +{ + if (nullptr == mWakeupManager || nullptr == appid) return false; + mWakeupManager->set_assistant_enabled(std::string(appid), enabled); + return true; +} + +bool CWakeupManager::CSettingsEventObserver::on_default_assistant_appid_changed( + const char* appid) +{ + if (nullptr == mWakeupManager || nullptr == appid) return false; + mWakeupManager->set_default_assistant(std::string(appid)); + return true; +} + } // wakeup } // multiassistant diff --git a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp index d639cf1..9853c34 100644 --- a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp @@ -153,6 +153,35 @@ int wakeup_manager_set_assistant_wakeup_engine(const char* appid, const char* en return 0; } +int wakeup_manager_set_default_assistant(const char* appid) +{ + MWR_LOGD("[ENTER]"); + + if (NULL == appid) { + MWR_LOGD("[ERROR] Parameter is invalid, appid(%s)", appid); + return -1; + } + + MWR_LOGD("[DEBUG] default_assistant appid(%s)", appid); + g_wakeup_manager.set_default_assistant(string{appid}); + + MWR_LOGD("[END]"); + return 0; +} + +int wakeup_manager_get_default_assistant(const char** appid) +{ + static string default_assistant; + default_assistant = g_wakeup_manager.get_default_assistant(); + + if (default_assistant.empty()) { + *appid = nullptr; + } else { + *appid = default_assistant.c_str(); + } + return 0; +} + int wakeup_manager_set_language(const char* language) { MWR_LOGD("[ENTER]"); diff --git a/plugins/wakeup-manager/src/wakeup_settings.cpp b/plugins/wakeup-manager/src/wakeup_settings.cpp index 0787f09..c68d6ba 100644 --- a/plugins/wakeup-manager/src/wakeup_settings.cpp +++ b/plugins/wakeup-manager/src/wakeup_settings.cpp @@ -9,6 +9,13 @@ namespace multiassistant namespace wakeup { +/* Utility function for checking if an element exists in a container */ +template +static auto contains(const C& v, const T& x) -> decltype(end(v), true) +{ + return end(v) != find(begin(v), end(v), x); +} + CWakeupSettings::CWakeupSettings() { } @@ -17,8 +24,9 @@ CWakeupSettings::~CWakeupSettings() { } -static void wakeup_setting_input_language_changed_cb(keynode_t *node, void* data) +static void wakeup_setting_input_language_changed_cb(keynode_t* node, void* data) { + MWR_LOGD("[ENTER]"); if (nullptr == node) return; CWakeupSettings* settings = static_cast(data); @@ -39,6 +47,84 @@ static void wakeup_setting_input_language_changed_cb(keynode_t *node, void* data } } +static void wakeup_setting_enabled_assistants_changed_cb(keynode_t* node, void* data) +{ + MWR_LOGD("[ENTER]"); + if (nullptr == node) return; + + CWakeupSettings* settings = static_cast(data); + if (nullptr == settings) return; + + if (VCONF_TYPE_STRING == node->type) { + vector newlyAddedAssistants; + vector newlyRemovedAssistants; + const char* value = static_cast(node->value.s); + if (value) { + vector previouslyEnabledAssistants = settings->get_enabled_assistants(); + vector currentlyEnabledAssistants; + string token; + istringstream iss(value); + currentlyEnabledAssistants.clear(); + while (getline(iss, token, ';')) { + currentlyEnabledAssistants.push_back(token); + MWR_LOGD("enabled_assistants : %s", token.c_str()); + } + + for (const auto& assistant : currentlyEnabledAssistants) { + if (!contains(previouslyEnabledAssistants, assistant)) { + newlyAddedAssistants.push_back(assistant); + } + } + for (const auto& assistant : previouslyEnabledAssistants) { + if (!contains(currentlyEnabledAssistants, assistant)) { + newlyRemovedAssistants.push_back(assistant); + } + } + } + + vector observers = settings->get_observers(); + for (const auto& observer : observers) { + if (observer) { + for (const auto& assistant : newlyAddedAssistants) { + if (!observer->on_assistant_enabled_info_changed(assistant.c_str(), true)) { + LOGW("[Settings WARNING] One of the observer returned false"); + } + } + for (const auto& assistant : newlyRemovedAssistants) { + if (!observer->on_assistant_enabled_info_changed(assistant.c_str(), false)) { + LOGW("[Settings WARNING] One of the observer returned false"); + } + } + } + } + } else { + LOGE("[Settings ERROR] the value type is not string : %d", node->type); + } +} + +static void wakeup_setting_default_assistant_appid_changed_cb(keynode_t* node, void* data) +{ + MWR_LOGD("[ENTER]"); + if (nullptr == node) return; + + CWakeupSettings* settings = static_cast(data); + if (nullptr == settings) return; + + if (VCONF_TYPE_STRING == node->type) { + const char* value = static_cast(node->value.s); + vector observers = settings->get_observers(); + for (const auto& observer : observers) { + if (observer) { + if (!observer->on_default_assistant_appid_changed(value)) { + LOGW("[Settings WARNING] One of the observer returned false"); + } + } + } + } else { + LOGE("[Settings ERROR] the value type is not string : %d", node->type); + } +} + void CWakeupSettings::initialize() { int vconf_ret; @@ -50,6 +136,13 @@ void CWakeupSettings::initialize() if (vconf_str) { mDefaultAssistantAppid = vconf_str; MWR_LOGD("default_assistant_appid : %s", mDefaultAssistantAppid.c_str()); + for (const auto& observer : mObservers) { + if (observer) { + if (!observer->on_default_assistant_appid_changed(vconf_str)) { + LOGW("[Settings WARNING] One of the observer returned false"); + } + } + } free(vconf_str); vconf_str = nullptr; } @@ -76,6 +169,13 @@ void CWakeupSettings::initialize() while (getline(iss, token, ';')) { mEnabledAssistants.push_back(token); MWR_LOGD("enabled_assistants : %s", token.c_str()); + for (const auto& observer : mObservers) { + if (observer) { + if (!observer->on_assistant_enabled_info_changed(token.c_str(), true)) { + LOGW("[Settings WARNING] One of the observer returned false"); + } + } + } } free(vconf_str); vconf_str = nullptr; @@ -102,14 +202,34 @@ void CWakeupSettings::initialize() mStreamingDurationMax = vconf_double; MWR_LOGD("streaming_duration_max : %f", mStreamingDurationMax); } + vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_VOICE_INPUT_LANGUAGE); + if (vconf_str) { + mVoiceInputLanguage = vconf_str; + MWR_LOGD("voice input language : %s", mVoiceInputLanguage.c_str()); + for (const auto& observer : mObservers) { + if (observer) { + if (!observer->on_voice_input_language_changed(vconf_str)) { + LOGW("[Settings WARNING] One of the observer returned false"); + } + } + } + free(vconf_str); + vconf_str = nullptr; + } vconf_notify_key_changed(WAKEUP_SETTINGS_KEY_VOICE_INPUT_LANGUAGE, wakeup_setting_input_language_changed_cb, this); + vconf_notify_key_changed(WAKEUP_SETTINGS_KEY_ENABLED_ASSISTANTS, + wakeup_setting_enabled_assistants_changed_cb, this); + vconf_notify_key_changed(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID, + wakeup_setting_default_assistant_appid_changed_cb, this); } void CWakeupSettings::deinitialize() { vconf_ignore_key_changed(WAKEUP_SETTINGS_KEY_VOICE_INPUT_LANGUAGE, NULL); + vconf_ignore_key_changed(WAKEUP_SETTINGS_KEY_ENABLED_ASSISTANTS, NULL); + vconf_ignore_key_changed(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID, NULL); } void CWakeupSettings::subscribe(ISettingsEventObserver *observer) diff --git a/src/multi_assistant_service.c b/src/multi_assistant_service.c index a6a8c0a..5b2b220 100644 --- a/src/multi_assistant_service.c +++ b/src/multi_assistant_service.c @@ -37,8 +37,9 @@ static const char *g_current_lang = "en_US"; +#define ENABLE_MULTI_ASSISTANT_BY_DEFAULT + #define MULTI_ASSISTANT_SETTINGS_ACTIVATED "db/multi-assistant/activated" -#define WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID "db/multi-assistant/default_assistant_appid" #define WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID "db/multi-assistant/preprocessing_assistant_appid" #define WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE "db/multi-assistant/prelaunch_mode" @@ -744,23 +745,32 @@ static int init_wakeup(void) /* Activate / deactivate according to the vconf key setting */ mas_active_state_changed_cb(NULL, NULL); } else { +#ifdef ENABLE_MULTI_ASSISTANT_BY_DEFAULT /* Multi-assistant needs to be enabled by default, unless disabled explicitly */ multi_assistant_service_plugin_activate(); - vconf_set_bool(MULTI_ASSISTANT_SETTINGS_ACTIVATED, 1); - vconf_notify_key_changed(MULTI_ASSISTANT_SETTINGS_ACTIVATED, mas_active_state_changed_cb, NULL); + const char *default_assistant = NULL; + if (0 == multi_assistant_service_plugin_get_default_assistant(&default_assistant)) { + if (NULL == default_assistant) { + if (g_maclient_info[0].used) { + default_assistant = g_maclient_info[0].appid; + MAS_LOGW("No default assistant, setting %s as default", default_assistant); + multi_assistant_service_plugin_set_default_assistant(default_assistant); + } else { + MAS_LOGE("No default assistant, and no assistant installed"); + } + } + } +#endif } /* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */ int prelaunch_mode; int res = vconf_get_bool(WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE, &prelaunch_mode); if (0 == res && 0 != prelaunch_mode) { - char *vconf_str; - vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID); - if (vconf_str) { - MAS_LOGD("prelaunching default_assistant_appid : %s", vconf_str); - mas_launch_client_by_appid(vconf_str, CLIENT_LAUNCH_MODE_PRELAUNCH); - free(vconf_str); - vconf_str = NULL; + const char *default_assistant = NULL; + if (0 == multi_assistant_service_plugin_get_default_assistant(&default_assistant)) { + MAS_LOGD("prelaunching default_assistant_appid : %s", default_assistant); + mas_launch_client_by_appid(default_assistant, CLIENT_LAUNCH_MODE_PRELAUNCH); } } diff --git a/src/multi_assistant_service_plugin.c b/src/multi_assistant_service_plugin.c index 700b3f2..518e5e5 100644 --- a/src/multi_assistant_service_plugin.c +++ b/src/multi_assistant_service_plugin.c @@ -383,6 +383,12 @@ int multi_assistant_service_plugin_initialize(void) _wakeup_manager_interface.set_assistant_wakeup_engine = (wakeup_manager_set_assistant_wakeup_engine)dlsym(g_handle, MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE); + _wakeup_manager_interface.set_default_assistant = + (wakeup_manager_set_default_assistant)dlsym(g_handle, + MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT); + _wakeup_manager_interface.get_default_assistant = + (wakeup_manager_get_default_assistant)dlsym(g_handle, + MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT); _wakeup_manager_interface.set_language = (wakeup_manager_set_language)dlsym(g_handle, MA_WAKEUP_MANAGER_FUNC_SET_LANGUAGE); @@ -613,6 +619,48 @@ int multi_assistant_service_plugin_set_assistant_wakeup_engine(const char* appid return ret; } +int multi_assistant_service_plugin_set_default_assistant(const char* appid) +{ + int ret = -1; + if (NULL != g_handle) { + wakeup_manager_set_default_assistant func = _wakeup_manager_interface.set_default_assistant; + if (NULL == func) { + MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT); + } else { + ret = func(appid); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to set default assistant(%s), ret(%d)", appid, ret); + } + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); + } + return ret; +} + +int multi_assistant_service_plugin_get_default_assistant(const char** appid) +{ + int ret = -1; + if (NULL == appid) { + MAS_LOGE("[ERROR] appid is not valid"); + return ret; + } + if (NULL != g_handle) { + wakeup_manager_get_default_assistant func = _wakeup_manager_interface.get_default_assistant; + if (NULL == func) { + MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT); + } else { + ret = func(appid); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to get default assistant, ret(%d)", ret); + } + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); + } + return ret; +} + int multi_assistant_service_plugin_activate(void) { int ret = -1; -- 2.7.4 From 63461547d0e4d312920a8afce5d3666c816a608d Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 22 Oct 2019 18:09:05 +0900 Subject: [PATCH 03/16] Ignore enabled assistants setting in single mode Change-Id: If8832442ec3c9cfd56f8823a5c0636f284190132 --- plugins/wakeup-manager/inc/wakeup_settings.h | 2 +- plugins/wakeup-manager/src/wakeup_settings.cpp | 40 +++++++++++++++----------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/plugins/wakeup-manager/inc/wakeup_settings.h b/plugins/wakeup-manager/inc/wakeup_settings.h index 99c8fd1..13ecbb4 100644 --- a/plugins/wakeup-manager/inc/wakeup_settings.h +++ b/plugins/wakeup-manager/inc/wakeup_settings.h @@ -80,7 +80,7 @@ private: string mDefaultAssistantAppid; bool mUiPanelEnabled{true}; float mConversationTimeout{5.0}; - bool mMultipleMode{true}; + bool mMultipleMode{false}; vector mEnabledAssistants; float mWakeupPolicyDelay{0.1}; vector mWakeupPolicyPriority; // No priority by default diff --git a/plugins/wakeup-manager/src/wakeup_settings.cpp b/plugins/wakeup-manager/src/wakeup_settings.cpp index c68d6ba..96a006f 100644 --- a/plugins/wakeup-manager/src/wakeup_settings.cpp +++ b/plugins/wakeup-manager/src/wakeup_settings.cpp @@ -161,24 +161,26 @@ void CWakeupSettings::initialize() mMultipleMode = vconf_bool; MWR_LOGD("multiple_mode : %s", (mMultipleMode ? "true" : "false")); } - vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_ENABLED_ASSISTANTS); - if (vconf_str) { - string token; - istringstream iss(vconf_str); - mEnabledAssistants.clear(); - while (getline(iss, token, ';')) { - mEnabledAssistants.push_back(token); - MWR_LOGD("enabled_assistants : %s", token.c_str()); - for (const auto& observer : mObservers) { - if (observer) { - if (!observer->on_assistant_enabled_info_changed(token.c_str(), true)) { - LOGW("[Settings WARNING] One of the observer returned false"); + if (true == mMultipleMode) { + vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_ENABLED_ASSISTANTS); + if (vconf_str) { + string token; + istringstream iss(vconf_str); + mEnabledAssistants.clear(); + while (getline(iss, token, ';')) { + mEnabledAssistants.push_back(token); + MWR_LOGD("enabled_assistants : %s", token.c_str()); + for (const auto& observer : mObservers) { + if (observer) { + if (!observer->on_assistant_enabled_info_changed(token.c_str(), true)) { + LOGW("[Settings WARNING] One of the observer returned false"); + } } } } + free(vconf_str); + vconf_str = nullptr; } - free(vconf_str); - vconf_str = nullptr; } vconf_ret = vconf_get_dbl(WAKEUP_SETTINGS_KEY_WAKEUP_POLICY_DELAY, &vconf_double); if (0 == vconf_ret) { @@ -219,17 +221,21 @@ void CWakeupSettings::initialize() vconf_notify_key_changed(WAKEUP_SETTINGS_KEY_VOICE_INPUT_LANGUAGE, wakeup_setting_input_language_changed_cb, this); - vconf_notify_key_changed(WAKEUP_SETTINGS_KEY_ENABLED_ASSISTANTS, - wakeup_setting_enabled_assistants_changed_cb, this); vconf_notify_key_changed(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID, wakeup_setting_default_assistant_appid_changed_cb, this); + if (true == mMultipleMode) { + vconf_notify_key_changed(WAKEUP_SETTINGS_KEY_ENABLED_ASSISTANTS, + wakeup_setting_enabled_assistants_changed_cb, this); + } } void CWakeupSettings::deinitialize() { vconf_ignore_key_changed(WAKEUP_SETTINGS_KEY_VOICE_INPUT_LANGUAGE, NULL); - vconf_ignore_key_changed(WAKEUP_SETTINGS_KEY_ENABLED_ASSISTANTS, NULL); vconf_ignore_key_changed(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID, NULL); + if (true == mMultipleMode) { + vconf_ignore_key_changed(WAKEUP_SETTINGS_KEY_ENABLED_ASSISTANTS, NULL); + } } void CWakeupSettings::subscribe(ISettingsEventObserver *observer) -- 2.7.4 From 0c6a47d8546af3e403e7a0908af1287222c24d2d Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 22 Oct 2019 18:14:26 +0900 Subject: [PATCH 04/16] Bump version to 0.2.2 Change-Id: I21cb1ebde99f3234b0f3c96a1cef201e9bee5b4f --- org.tizen.multi-assistant-service.xml | 2 +- packaging/org.tizen.multi-assistant-service.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.multi-assistant-service.xml b/org.tizen.multi-assistant-service.xml index c7ff283..c7c4f14 100644 --- a/org.tizen.multi-assistant-service.xml +++ b/org.tizen.multi-assistant-service.xml @@ -1,5 +1,5 @@ - + Won Nam Jang Sooyeon Kim diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index 663f768..f6d0b3c 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -1,6 +1,6 @@ Name: org.tizen.multi-assistant-service Summary: Multi assistant service -Version: 0.2.1 +Version: 0.2.2 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From a31117e83974901f41b952766e94c4dcff4bd819 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 24 Oct 2019 16:31:22 +0900 Subject: [PATCH 05/16] Add exception handlers for the functions in external modules Change-Id: Iae5619b299fc0a6ff737b042f90d23d13a3864c0 --- plugins/wakeup-manager/src/dependency_resolver.cpp | 65 +++++++-- .../wakeup-manager/src/wakeup_engine_manager.cpp | 150 ++++++++++++++------- 2 files changed, 156 insertions(+), 59 deletions(-) diff --git a/plugins/wakeup-manager/src/dependency_resolver.cpp b/plugins/wakeup-manager/src/dependency_resolver.cpp index 551290e..43b080d 100644 --- a/plugins/wakeup-manager/src/dependency_resolver.cpp +++ b/plugins/wakeup-manager/src/dependency_resolver.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include "multi_assistant_main.h" #include "dependency_resolver.h" @@ -93,7 +95,12 @@ int dependency_resolver_initialize(mas_proxy_interface interface) if (NULL == func) { MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_INITIALIZE); } else { - ret = func(interface, &dependency_version); + try { + ret = func(interface, &dependency_version); + } catch (const std::exception& e) { + MAS_LOGE("[ERROR] %s of dependency module threw exception : %s", + MAS_DEPENDENCY_FUNC_INITIALIZE, e.what()); + } if (0 != ret) { MAS_LOGE("[ERROR] Fail to initialize, ret(%d)", ret); } @@ -114,7 +121,12 @@ int dependency_resolver_deinitialize(void) if (NULL == func) { MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_DEINITIALIZE); } else { - ret = func(); + try { + ret = func(); + } catch (const std::exception& e) { + MAS_LOGE("[ERROR] %s of dependency module threw exception : %s", + MAS_DEPENDENCY_FUNC_DEINITIALIZE, e.what()); + } if (0 != ret) { MAS_LOGE("[ERROR] Fail to deinitialize, ret(%d)", ret); } @@ -137,7 +149,12 @@ int dependency_resolver_set_error_callback(mas_dependency_error_cb callback, voi if (NULL == func) { MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_SET_ERROR_CALLBACK); } else { - ret = func(callback, user_data); + try { + ret = func(callback, user_data); + } catch (const std::exception& e) { + MAS_LOGE("[ERROR] %s of dependency module threw exception : %s", + MAS_DEPENDENCY_FUNC_DEINITIALIZE, e.what()); + } if (0 != ret) { MAS_LOGE("[ERROR] Fail to set error callback(%p, %p), ret(%d)", callback, user_data, ret); } @@ -157,7 +174,12 @@ int dependency_resolver_start_recording(void) if (NULL == func) { MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_START_RECORDING); } else { - ret = func(); + try { + ret = func(); + } catch (const std::exception& e) { + MAS_LOGE("[ERROR] %s of dependency module threw exception : %s", + MAS_DEPENDENCY_FUNC_DEINITIALIZE, e.what()); + } if (0 != ret) { MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret); } @@ -177,7 +199,12 @@ int dependency_resolver_stop_recording(void) if (NULL == func) { MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_STOP_RECORDING); } else { - ret = func(); + try { + ret = func(); + } catch (const std::exception& e) { + MAS_LOGE("[ERROR] %s of dependency module threw exception : %s", + MAS_DEPENDENCY_FUNC_DEINITIALIZE, e.what()); + } if (0 != ret) { MAS_LOGE("[ERROR] Fail to stop recording, ret(%d)", ret); } @@ -198,7 +225,12 @@ int dependency_resolver_set_recording_session(unsigned int session) if (NULL == func) { MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_SET_RECORDING_SESSION); } else { - ret = func(session); + try { + ret = func(session); + } catch (const std::exception& e) { + MAS_LOGE("[ERROR] %s of dependency module threw exception : %s", + MAS_DEPENDENCY_FUNC_DEINITIALIZE, e.what()); + } if (0 != ret) { MAS_LOGE("[ERROR] Fail to set recording session, ret(%d)", ret); } @@ -218,7 +250,12 @@ int dependency_resolver_set_background_volume(double ratio) if (NULL == func) { MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_SET_BACKGROUND_VOLUME); } else { - ret = func(ratio); + try { + ret = func(ratio); + } catch (const std::exception& e) { + MAS_LOGE("[ERROR] %s of dependency module threw exception : %s", + MAS_DEPENDENCY_FUNC_DEINITIALIZE, e.what()); + } if (0 != ret) { MAS_LOGE("[ERROR] Fail to set background volume to %f, ret(%d)", ratio, ret); } @@ -238,7 +275,12 @@ int dependency_resolver_get_audio_format(int* rate, int* channel, int* audio_typ if (NULL == func) { MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_GET_AUDIO_FORMAT); } else { - ret = func(rate, channel, audio_type); + try { + ret = func(rate, channel, audio_type); + } catch (const std::exception& e) { + MAS_LOGE("[ERROR] %s of dependency module threw exception : %s", + MAS_DEPENDENCY_FUNC_DEINITIALIZE, e.what()); + } if (0 != ret) { MAS_LOGE("[ERROR] Fail to get audio format, ret(%d)", ret); } @@ -258,7 +300,12 @@ int dependency_resolver_get_audio_source_type(char** type) if (NULL == func) { MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_GET_AUDIO_SOURCE_TYPE); } else { - ret = func(type); + try { + ret = func(type); + } catch (const std::exception& e) { + MAS_LOGE("[ERROR] %s of dependency module threw exception : %s", + MAS_DEPENDENCY_FUNC_DEINITIALIZE, e.what()); + } if (0 != ret) { MAS_LOGE("[ERROR] Fail to get audio source type, ret(%d)", ret); } diff --git a/plugins/wakeup-manager/src/wakeup_engine_manager.cpp b/plugins/wakeup-manager/src/wakeup_engine_manager.cpp index 46e9a1d..5e1163c 100644 --- a/plugins/wakeup-manager/src/wakeup_engine_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_engine_manager.cpp @@ -77,20 +77,25 @@ void CWakeupEngineManager::initialize() void CWakeupEngineManager::deinitialize() { for (auto& info : mEngineInfo) { - if (info.interface.set_wakeup_event_callback) { - info.interface.set_wakeup_event_callback(nullptr, nullptr); - } - if (info.interface.set_speech_status_callback) { - info.interface.set_speech_status_callback(nullptr, nullptr); - } - if (info.interface.set_error_callback) { - info.interface.set_error_callback(nullptr, nullptr); - } - if (info.interface.set_audio_data_require_status_callback) { - info.interface.set_audio_data_require_status_callback(nullptr, nullptr); - } - if (info.interface.deinitialize) { - info.interface.deinitialize(); + try { + if (info.interface.set_wakeup_event_callback) { + info.interface.set_wakeup_event_callback(nullptr, nullptr); + } + if (info.interface.set_speech_status_callback) { + info.interface.set_speech_status_callback(nullptr, nullptr); + } + if (info.interface.set_error_callback) { + info.interface.set_error_callback(nullptr, nullptr); + } + if (info.interface.set_audio_data_require_status_callback) { + info.interface.set_audio_data_require_status_callback(nullptr, nullptr); + } + if (info.interface.deinitialize) { + info.interface.deinitialize(); + } + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); } if (info.engine_handle) { dlclose(info.engine_handle); @@ -138,7 +143,12 @@ bool CWakeupEngineManager::set_language(string language) { for (const auto& info : mEngineInfo) { if (info.interface.set_language) { - info.interface.set_language(language.c_str()); + try { + info.interface.set_language(language.c_str()); + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); + } } } return true; @@ -164,9 +174,19 @@ void CWakeupEngineManager::set_assistant_activated(string appid, bool activated) info.activated = (info.activated_assistants.size() > 0); if (previously_activated != info.activated) { if (info.activated) { - info.interface.activate(); + try { + info.interface.activate(); + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); + } } else { - info.interface.deactivate(); + try { + info.interface.deactivate(); + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); + } } /* Activated status changed, need to update audio_data_require_status too */ on_audio_data_require_status(info.engine_name, info.audio_data_require_status); @@ -181,7 +201,12 @@ void CWakeupEngineManager::set_wake_word_audio_require_flag(bool require) mWakeWordAudioRequired = require; for (const auto& info : mEngineInfo) { if (info.interface.set_wake_word_audio_require_flag) { - info.interface.set_wake_word_audio_require_flag(require); + try { + info.interface.set_wake_word_audio_require_flag(require); + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); + } } } } @@ -336,7 +361,12 @@ void CWakeupEngineManager::update_manager_state(wakeup_manager_state_e state) { for (const auto& info : mEngineInfo) { if (info.interface.update_manager_state) { - info.interface.update_manager_state(state); + try { + info.interface.update_manager_state(state); + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); + } } } } @@ -392,7 +422,12 @@ void CWakeupEngineManager::engine_add_wakeup_word(string appid, string wakeup_wo bool found = contains(info.assistant_list, appid); if (found) { if (info.interface.add_wakeup_word) { - info.interface.add_wakeup_word(appid.c_str(), wakeup_word.c_str(), language.c_str()); + try { + info.interface.add_wakeup_word(appid.c_str(), wakeup_word.c_str(), language.c_str()); + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); + } } } } @@ -404,7 +439,12 @@ void CWakeupEngineManager::engine_set_assistant_specific_command(string appid, s bool found = contains(info.assistant_list, appid); if (found) { if (info.interface.set_assistant_specific_command) { - info.interface.set_assistant_specific_command(appid.c_str(), command.c_str()); + try { + info.interface.set_assistant_specific_command(appid.c_str(), command.c_str()); + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); + } } } } @@ -416,9 +456,14 @@ void CWakeupEngineManager::engine_feed_audio_data(long time, void* data, int len if (info.activated && info.audio_data_require_status && info.interface.feed_audio_data) { - int ret = info.interface.feed_audio_data(time, data, len); - if (0 != ret) { - LOGE("[ERROR] Fail to feed speech data, ret(%d) : %s", ret, info.engine_name.c_str()); + try { + int ret = info.interface.feed_audio_data(time, data, len); + if (0 != ret) { + LOGE("[ERROR] Fail to feed speech data, ret(%d) : %s", ret, info.engine_name.c_str()); + } + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); } } } @@ -618,35 +663,40 @@ void CWakeupEngineManager::add_engine(string name, string path) user_data.engine_name = info.engine_name; callback_user_data.push_back(user_data); - if (info.interface.set_wakeup_event_callback) { - info.interface.set_wakeup_event_callback( - [](wakeup_event_info info, void* user_data) { - CallbackUserData *data = static_cast(user_data); - if (nullptr == data) return; - if (nullptr == data->manager) return; - info.wakeup_engine = data->engine_name.c_str(); - data->manager->on_wakeup_event(data->engine_name, info); - }, &(callback_user_data.back())); - } + try { + if (info.interface.set_wakeup_event_callback) { + info.interface.set_wakeup_event_callback( + [](wakeup_event_info info, void* user_data) { + CallbackUserData *data = static_cast(user_data); + if (nullptr == data) return; + if (nullptr == data->manager) return; + info.wakeup_engine = data->engine_name.c_str(); + data->manager->on_wakeup_event(data->engine_name, info); + }, &(callback_user_data.back())); + } - if (info.interface.set_audio_data_require_status_callback) { - info.interface.set_audio_data_require_status_callback( - [](bool require, void* user_data) { - CallbackUserData *data = static_cast(user_data); - if (nullptr == data) return; - if (nullptr == data->manager) return; - data->manager->on_audio_data_require_status(data->engine_name, require); - }, &(callback_user_data.back())); - } + if (info.interface.set_audio_data_require_status_callback) { + info.interface.set_audio_data_require_status_callback( + [](bool require, void* user_data) { + CallbackUserData *data = static_cast(user_data); + if (nullptr == data) return; + if (nullptr == data->manager) return; + data->manager->on_audio_data_require_status(data->engine_name, require); + }, &(callback_user_data.back())); + } - if (info.interface.initialize) { - info.interface.initialize(); - } - if (info.interface.get_version) { - int version; - if (0 == info.interface.get_version(&version)) { - info.version = version; + if (info.interface.initialize) { + info.interface.initialize(); + } + if (info.interface.get_version) { + int version; + if (0 == info.interface.get_version(&version)) { + info.version = version; + } } + } catch (const std::exception& e) { + MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", + info.engine_name.c_str(), e.what()); } } -- 2.7.4 From b22e1d111f1cf6a6840be16e44149e27b920d52d Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 24 Oct 2019 16:36:25 +0900 Subject: [PATCH 06/16] Bump version to 0.2.3 Change-Id: I6019ce410e76fb78c2a525d4929379a1342e48d9 --- org.tizen.multi-assistant-service.xml | 2 +- packaging/org.tizen.multi-assistant-service.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.multi-assistant-service.xml b/org.tizen.multi-assistant-service.xml index c7c4f14..4ae038a 100644 --- a/org.tizen.multi-assistant-service.xml +++ b/org.tizen.multi-assistant-service.xml @@ -1,5 +1,5 @@ - + Won Nam Jang Sooyeon Kim diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index f6d0b3c..19ee155 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -1,6 +1,6 @@ Name: org.tizen.multi-assistant-service Summary: Multi assistant service -Version: 0.2.2 +Version: 0.2.3 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From 54f7b4364bcdfc7d925fb4f261ce1b3345af847b Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 24 Oct 2019 21:33:18 +0900 Subject: [PATCH 07/16] Remove multi-assistant header inclusion Change-Id: I13635bc2bbd080e6dc2706a057f807a2f29f51d7 --- inc/multi_wakeup_recognizer.h | 33 +++++++++++++++++++++- plugins/wakeup-manager/inc/wakeup_engine_manager.h | 2 -- plugins/wakeup-manager/inc/wakeup_manager.h | 2 -- .../wakeup-manager/inc/wakeup_manager_wrapper.h | 15 +++++++++- src/multi_assistant_service.c | 1 - src/multi_assistant_service_plugin.c | 1 - 6 files changed, 46 insertions(+), 8 deletions(-) diff --git a/inc/multi_wakeup_recognizer.h b/inc/multi_wakeup_recognizer.h index c818e1a..6c3eb6f 100644 --- a/inc/multi_wakeup_recognizer.h +++ b/inc/multi_wakeup_recognizer.h @@ -19,7 +19,6 @@ #define _MULTI_WAKEUP_RECOGNIZER_H_ #include -#include #ifdef __cplusplus extern "C" { @@ -61,6 +60,38 @@ typedef enum { WAKEUP_ASR_RESULT_EVENT_ERROR /**< Event when the recognition has failed */ } wakeup_asr_result_event_e; +typedef enum { + MA_AUDIO_STREAMING_DATA_TYPE_CURRENT_UTTERANCE = 0, /**< Current utterance */ + MA_AUDIO_STREAMING_DATA_TYPE_PREVIOUS_UTTERANCE, /**< Previous utterance */ + MA_AUDIO_STREAMING_DATA_TYPE_FOLLOW_UP_SPEECH /**< Follow-up speech */ +} ma_audio_streaming_data_type_e; + +typedef enum { + MA_ACTIVE_STATE_INACTIVE = 0, /**< 'Inactive' state */ + MA_ACTIVE_STATE_ACTIVE, /**< 'Active' state */ + MA_ACTIVE_STATE_PREPROCESSING, /**< 'Preprocessing' state */ +} ma_active_state_e; + +typedef enum { + MA_RECOGNITION_RESULT_EVENT_SUCCESS = 0, /**< Recognition succeeded */ + MA_RECOGNITION_RESULT_EVENT_EMPTY_TEXT, /**< No text result recognized */ + MA_RECOGNITION_RESULT_EVENT_ERROR, /**< Unknown error occurred */ + MA_RECOGNITION_RESULT_EVENT_FALSE_TRIGGER /**< Turned out to be a false trigger */ +} ma_recognition_result_event_e; + +typedef enum { + MA_PREPROCESSING_ALLOW_NONE = 0, /**< No preprocessing allowed */ + MA_PREPROCESSING_ALLOW_UTTERANCE, /**< Preprocessing allowed for utterance audio only */ + MA_PREPROCESSING_ALLOW_FOLLOW_UP, /**< Preprocessing allowed for follow-up audio only */ + MA_PREPROCESSING_ALLOW_ALL, /**< Preprocessing allowed for all audio */ +} ma_preprocessing_allow_mode_e; + +typedef enum { + MA_AUDIO_STREAMING_DATA_SECTION_UTTERANCE = 0, /**< Utterance section started */ + MA_AUDIO_STREAMING_DATA_SECTION_WAKE_WORD, /**< Wake word section started */ +} ma_audio_streaming_data_section_e; + +typedef void (*ma_audio_streaming_data_section_changed_cb)(ma_audio_streaming_data_section_e section, void* user_data); typedef void (*wakeup_service_wakeup_event_cb)(wakeup_event_info wakeup_info, const char* wakeup_word, void* user_data); diff --git a/plugins/wakeup-manager/inc/wakeup_engine_manager.h b/plugins/wakeup-manager/inc/wakeup_engine_manager.h index 49d8e22..c768f9b 100644 --- a/plugins/wakeup-manager/inc/wakeup_engine_manager.h +++ b/plugins/wakeup-manager/inc/wakeup_engine_manager.h @@ -19,8 +19,6 @@ #include "wakeup_manager_wrapper.h" -#include - #include #include #include diff --git a/plugins/wakeup-manager/inc/wakeup_manager.h b/plugins/wakeup-manager/inc/wakeup_manager.h index d682387..e6f5251 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager.h +++ b/plugins/wakeup-manager/inc/wakeup_manager.h @@ -24,8 +24,6 @@ #include "wakeup_audio_manager.h" #include "wakeup_policy_default.h" -#include "multi_assistant_common.h" - #include #include diff --git a/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h b/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h index c566d83..7f408dc 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h +++ b/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h @@ -22,7 +22,6 @@ #include #include #include -#include #include "wakeup_interfaces.h" @@ -44,6 +43,20 @@ typedef enum { WAKEUP_MANAGER_STATE_VOICE_FEEDBACK = 4 } wakeup_manager_state_e; +typedef enum { + MA_PREPROCESSING_ALLOW_NONE = 0, /**< No preprocessing allowed */ + MA_PREPROCESSING_ALLOW_UTTERANCE, /**< Preprocessing allowed for utterance audio only */ + MA_PREPROCESSING_ALLOW_FOLLOW_UP, /**< Preprocessing allowed for follow-up audio only */ + MA_PREPROCESSING_ALLOW_ALL, /**< Preprocessing allowed for all audio */ +} ma_preprocessing_allow_mode_e; + +typedef enum { + MA_AUDIO_STREAMING_DATA_SECTION_UTTERANCE = 0, /**< Utterance section started */ + MA_AUDIO_STREAMING_DATA_SECTION_WAKE_WORD, /**< Wake word section started */ +} ma_audio_streaming_data_section_e; + +typedef void (*ma_audio_streaming_data_section_changed_cb)(ma_audio_streaming_data_section_e section, void* user_data); + typedef void (*wakeup_service_wakeup_event_cb)(wakeup_event_info wakeup_info, void* user_data); typedef void (*wakeup_service_speech_streaming_cb)(wakeup_speech_streaming_event_e event, void* buffer, int len, void *user_data); diff --git a/src/multi_assistant_service.c b/src/multi_assistant_service.c index 5b2b220..0baf44e 100644 --- a/src/multi_assistant_service.c +++ b/src/multi_assistant_service.c @@ -33,7 +33,6 @@ #include "multi_assistant_service_plugin.h" #include "multi_assistant_dbus.h" #include "multi_assistant_config.h" -#include "multi_assistant_common.h" static const char *g_current_lang = "en_US"; diff --git a/src/multi_assistant_service_plugin.c b/src/multi_assistant_service_plugin.c index 518e5e5..a04366f 100644 --- a/src/multi_assistant_service_plugin.c +++ b/src/multi_assistant_service_plugin.c @@ -32,7 +32,6 @@ #include "multi_assistant_service.h" #include "multi_assistant_service_plugin.h" #include "multi_assistant_dbus.h" -#include "multi_assistant_common.h" /* Sound buf save for test */ #if 0 -- 2.7.4 From 497c80a7dca588a5472d7f85f2bebae427cfe346 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 24 Oct 2019 21:37:00 +0900 Subject: [PATCH 08/16] Bump version to 0.2.4 Change-Id: I3923e7e0c848fcbf751523dc43ee676fd9169b1b --- org.tizen.multi-assistant-service.xml | 2 +- packaging/org.tizen.multi-assistant-service.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.multi-assistant-service.xml b/org.tizen.multi-assistant-service.xml index 4ae038a..0fe54b1 100644 --- a/org.tizen.multi-assistant-service.xml +++ b/org.tizen.multi-assistant-service.xml @@ -1,5 +1,5 @@ - + Won Nam Jang Sooyeon Kim diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index 19ee155..09ea4a2 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -1,6 +1,6 @@ Name: org.tizen.multi-assistant-service Summary: Multi assistant service -Version: 0.2.3 +Version: 0.2.4 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From 1f68c5e3f0416f7ced134cf1fb992b81466ca1c7 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 24 Oct 2019 22:18:58 +0900 Subject: [PATCH 09/16] Prevent sending preprocessing appid as NULL Change-Id: Id3744e4a00bfb4f1a4e66996b8952027a285f74c --- src/multi_assistant_service.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/multi_assistant_service.c b/src/multi_assistant_service.c index 0baf44e..278c60c 100644 --- a/src/multi_assistant_service.c +++ b/src/multi_assistant_service.c @@ -305,9 +305,11 @@ int mas_client_send_preprocessing_information(int pid) char* vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID); MAS_LOGD("preprocessing_assistant_appid : %s", vconf_str); - ret = masc_dbus_send_preprocessing_information(pid, vconf_str); - free(vconf_str); - vconf_str = NULL; + if (vconf_str) { + ret = masc_dbus_send_preprocessing_information(pid, vconf_str); + free(vconf_str); + vconf_str = NULL; + } return ret; } -- 2.7.4 From 5ffe702859843fb6574805759f6bd0fdce178cb8 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 24 Oct 2019 22:21:03 +0900 Subject: [PATCH 10/16] Bump version to 0.2.5 Change-Id: Ie3e3f4936ba5eedadeadba5a8fdcd2f98de08c1f --- org.tizen.multi-assistant-service.xml | 2 +- packaging/org.tizen.multi-assistant-service.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.multi-assistant-service.xml b/org.tizen.multi-assistant-service.xml index 0fe54b1..483d407 100644 --- a/org.tizen.multi-assistant-service.xml +++ b/org.tizen.multi-assistant-service.xml @@ -1,5 +1,5 @@ - + Won Nam Jang Sooyeon Kim diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index 09ea4a2..9f783fc 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -1,6 +1,6 @@ Name: org.tizen.multi-assistant-service Summary: Multi assistant service -Version: 0.2.4 +Version: 0.2.5 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From 4b026e616c97126331848a3f57534bd07abcd7bd Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 28 Oct 2019 14:45:41 +0900 Subject: [PATCH 11/16] Fix incorrect log messages Change-Id: I5722be377ae9e07f7ab2fa1cba7770091613d141 --- src/multi_assistant_dbus_server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/multi_assistant_dbus_server.c b/src/multi_assistant_dbus_server.c index 16ec6c8..0d00f3e 100644 --- a/src/multi_assistant_dbus_server.c +++ b/src/multi_assistant_dbus_server.c @@ -428,7 +428,7 @@ int ma_service_dbus_start_streaming_audio_data(DBusConnection* conn, DBusMessage dbus_error_free(&err); ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { - MAS_LOGD("[IN] mas send start streaming : pid(%d), result(%d)", pid, type); + MAS_LOGD("[IN] mas send start streaming : pid(%d), type(%d)", pid, type); ret = mas_client_start_streaming_audio_data(pid, type); } @@ -459,7 +459,7 @@ int ma_service_dbus_stop_streaming_audio_data(DBusConnection* conn, DBusMessage* dbus_error_free(&err); ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { - MAS_LOGD("[IN] mas stop streaming : pid(%d), result(%d)", pid, type); + MAS_LOGD("[IN] mas stop streaming : pid(%d), type(%d)", pid, type); ret = mas_client_stop_streaming_audio_data(pid, type); } @@ -490,7 +490,7 @@ int ma_service_dbus_update_voice_feedback_state(DBusConnection* conn, DBusMessag dbus_error_free(&err); ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { - MAS_LOGD("[IN] mas update voice feedback : pid(%d), result(%d)", pid, state); + MAS_LOGD("[IN] mas update voice feedback : pid(%d), state(%d)", pid, state); ret = mas_client_update_voice_feedback_state(pid, state); } -- 2.7.4 From 398892c34e1d54b56f5968bf0a12bd5e7912505e Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 29 Oct 2019 11:11:34 +0900 Subject: [PATCH 12/16] Support background/foreground preprocessing selectively Change-Id: If8d8d875f35a08ec8463fe0549b0c9f35df0e2a8 --- inc/multi_assistant_service.h | 3 +- src/multi_assistant_service.c | 81 ++++++++++++++++++++++++++---------- src/multi_assistant_service_plugin.c | 2 +- 3 files changed, 62 insertions(+), 24 deletions(-) diff --git a/inc/multi_assistant_service.h b/inc/multi_assistant_service.h index 0a79b99..0bbc37a 100644 --- a/inc/multi_assistant_service.h +++ b/inc/multi_assistant_service.h @@ -98,8 +98,7 @@ typedef enum { } PREPROCESSING_STATE; typedef enum { - PREPROCESSING_STATE_EVENT_WAKEUP, - PREPROCESSING_STATE_EVENT_ACTIVE_ASSISTANT_LAUNCHED, + PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED, PREPROCESSING_STATE_EVENT_PREPROCESSING_ALLOW_MODE_CHANGED, PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED, PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED, diff --git a/src/multi_assistant_service.c b/src/multi_assistant_service.c index 278c60c..b2da67b 100644 --- a/src/multi_assistant_service.c +++ b/src/multi_assistant_service.c @@ -248,7 +248,7 @@ int mas_client_initialize(int pid) if (g_wakeup_maclient_appid && strncmp(g_wakeup_maclient_appid, appid, MAX_APPID_LEN) == 0) { g_wakeup_maclient_appid = NULL; mas_client_activate(pid); - mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ACTIVE_ASSISTANT_LAUNCHED); + mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED); } else { MAS_LOGE("[ERROR] g_wakeup_maclient_appid and appid differ : %s %s", (g_wakeup_maclient_appid ? g_wakeup_maclient_appid : "NULL"), appid); @@ -503,11 +503,9 @@ int mas_client_send_preprocessing_result(int pid, bool result) if (result) { MAS_LOGD("Preprocessing succeeded, bring (%s) to foreground", pid_appid); - mas_bring_client_to_foreground(pid_appid); mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED); } else { MAS_LOGD("Preprocessing failed, bring (%s) to foreground", current_maclient_appid); - mas_bring_client_to_foreground(current_maclient_appid); mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED); } @@ -1105,6 +1103,9 @@ ma_preprocessing_allow_mode_e get_preprocessing_allow_mode(const char* appid) return MA_PREPROCESSING_ALLOW_NONE; } +/* This might need to be read from settings in the future, but using macro for now */ +//#define BRING_PREPROCESSING_ASSISTANT_TO_FRONT + int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event) { const char* current_maclient_appid = NULL; @@ -1116,28 +1117,40 @@ int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event) ma_preprocessing_allow_mode_e mode = get_preprocessing_allow_mode(current_maclient_appid); switch (event) { - case PREPROCESSING_STATE_EVENT_WAKEUP: - case PREPROCESSING_STATE_EVENT_ACTIVE_ASSISTANT_LAUNCHED: + case PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED: { - if (!check_preprocessing_assistant_exists()) { - mas_bring_client_to_foreground(current_maclient_appid); - } +#ifndef BRING_PREPROCESSING_ASSISTANT_TO_FRONT + /* If there is no need to bring preprocessing assistant to front, + current_maclient should always be brought to front */ + mas_bring_client_to_foreground(current_maclient_appid); +#endif g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED; - if (MA_PREPROCESSING_ALLOW_UTTERANCE == mode || - MA_PREPROCESSING_ALLOW_ALL == mode) { - if (is_current_preprocessing_assistant(preprocessing_allow_appid)) { - g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED; + if (check_preprocessing_assistant_exists()) { + if (MA_PREPROCESSING_ALLOW_UTTERANCE == mode || + MA_PREPROCESSING_ALLOW_ALL == mode) { + if (is_current_preprocessing_assistant(preprocessing_allow_appid)) { + g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED; + } } + } else { +#ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT + /* If preprocessing assistant does not exist, there is no way to enable + preprocessing assistant, so bring current maclient to front right away */ + mas_bring_client_to_foreground(current_maclient_appid); +#endif } } break; case PREPROCESSING_STATE_EVENT_PREPROCESSING_ALLOW_MODE_CHANGED: { g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED; - if (MA_PREPROCESSING_ALLOW_UTTERANCE == mode || - MA_PREPROCESSING_ALLOW_ALL == mode) { - if (is_current_preprocessing_assistant(preprocessing_allow_appid)) { - g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED; + /* Enable preprocessing mode only if the preprocessing assistant exists */ + if (check_preprocessing_assistant_exists()) { + if (MA_PREPROCESSING_ALLOW_UTTERANCE == mode || + MA_PREPROCESSING_ALLOW_ALL == mode) { + if (is_current_preprocessing_assistant(preprocessing_allow_appid)) { + g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED; + } } } } @@ -1147,27 +1160,53 @@ int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event) if (PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED == g_current_preprocessing_state) { g_current_preprocessing_state = PREPROCESSING_STATE_PREPROCESSING_UTTERANCE; } else if (PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED == g_current_preprocessing_state) { - mas_bring_client_to_foreground(current_maclient_appid); + /* If preprocessing assistant does not exist, the current_maclient + would have been brought to front already on wakeup event */ +#ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT + if (check_preprocessing_assistant_exists()) { + mas_bring_client_to_foreground(current_maclient_appid); + } +#endif g_current_preprocessing_state = PREPROCESSING_STATE_NONE; } } break; case PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED: { - if (MA_PREPROCESSING_ALLOW_FOLLOW_UP == mode || - MA_PREPROCESSING_ALLOW_ALL == mode) { - g_current_preprocessing_state = PREPROCESSING_STATE_PREPROCESSING_FOLLOW_UP; + g_current_preprocessing_state = PREPROCESSING_STATE_NONE; + if (check_preprocessing_assistant_exists()) { + if (MA_PREPROCESSING_ALLOW_FOLLOW_UP == mode || + MA_PREPROCESSING_ALLOW_ALL == mode) { + g_current_preprocessing_state = PREPROCESSING_STATE_PREPROCESSING_FOLLOW_UP; + } } } break; case PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED: { +#ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT + if (PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED == g_current_preprocessing_state || + PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED == g_current_preprocessing_state) { + char* vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID); + MAS_LOGD("preprocessing_assistant_appid : %s", vconf_str); + if (vconf_str) { + mas_bring_client_to_foreground(vconf_str); + free(vconf_str); + vconf_str = NULL; + } + } +#endif g_current_preprocessing_state = PREPROCESSING_STATE_NONE; } break; case PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED: { - mas_bring_client_to_foreground(current_maclient_appid); +#ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT + if (PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED == g_current_preprocessing_state || + PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED == g_current_preprocessing_state) { + mas_bring_client_to_foreground(current_maclient_appid); + } +#endif g_current_preprocessing_state = PREPROCESSING_STATE_NONE; } break; diff --git a/src/multi_assistant_service_plugin.c b/src/multi_assistant_service_plugin.c index a04366f..5e9e063 100644 --- a/src/multi_assistant_service_plugin.c +++ b/src/multi_assistant_service_plugin.c @@ -109,12 +109,12 @@ Eina_Bool process_wakeup_event_by_appid_timer(char* appid) if ((pid = mas_get_client_pid_by_appid(appid)) != -1) { mas_client_send_preprocessing_information(pid); mas_client_activate(pid); + mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED); } else { // Appropriate MA Client not available, trying to launch new one MAS_LOGD("MA Client with appid %s does not exist, launching client", appid); mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION); } - mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_WAKEUP); if (appid) free(appid); -- 2.7.4 From 871c00fcc97b27edfb84f723407a84286fae69a8 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 29 Oct 2019 16:03:40 +0900 Subject: [PATCH 13/16] Prelaunch default assistant on setting change event Change-Id: I1a8f96a408bff8668d81020876cdebad0623e969 --- inc/multi_assistant_service.h | 2 + inc/multi_assistant_service_plugin.h | 3 + inc/multi_wakeup_recognizer.h | 2 + plugins/wakeup-manager/inc/wakeup_manager.h | 22 +++++-- .../wakeup-manager/inc/wakeup_manager_wrapper.h | 4 ++ plugins/wakeup-manager/src/wakeup_manager.cpp | 67 ++++++++++++++++------ .../wakeup-manager/src/wakeup_manager_wrapper.cpp | 37 +++++++++++- src/multi_assistant_service.c | 28 +++++---- src/multi_assistant_service_plugin.c | 32 +++++++++++ 9 files changed, 164 insertions(+), 33 deletions(-) diff --git a/inc/multi_assistant_service.h b/inc/multi_assistant_service.h index 0bbc37a..775245d 100644 --- a/inc/multi_assistant_service.h +++ b/inc/multi_assistant_service.h @@ -81,6 +81,8 @@ int mas_set_current_client_by_appid(const char *appid); int mas_launch_client_by_wakeup_word(const char *wakeup_word); +int mas_prelaunch_default_assistant(); + typedef enum { CLIENT_LAUNCH_MODE_ACTIVATION, CLIENT_LAUNCH_MODE_PRELAUNCH, diff --git a/inc/multi_assistant_service_plugin.h b/inc/multi_assistant_service_plugin.h index 7bfd761..dbfd673 100644 --- a/inc/multi_assistant_service_plugin.h +++ b/inc/multi_assistant_service_plugin.h @@ -169,6 +169,8 @@ typedef int (*wakeup_manager_set_previous_utterance_streaming_callback)(wakeup_s typedef int (*wakeup_manager_set_follow_up_streaming_callback)(wakeup_service_speech_streaming_cb callback, void* user_data); #define MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK "wakeup_manager_set_speech_status_callback" typedef int (*wakeup_manager_set_speech_status_callback)(wakeup_service_speech_status_cb callback, void* user_data); +#define MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK "wakeup_manager_set_setting_changed_callback" +typedef int (*wakeup_manager_set_setting_changed_callback)(wakeup_service_setting_changed_cb callback, void* user_data); #define MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK "wakeup_manager_set_error_callback" typedef int (*wakeup_manager_set_error_callback)(wakeup_service_error_cb callback, void* user_data); #define MA_WAKEUP_MANAGER_FUNC_SET_STREAMING_SECTION_CHANGED_CALLBACK "wakeup_manager_set_streaming_section_changed_callback" @@ -205,6 +207,7 @@ typedef struct { wakeup_manager_set_previous_utterance_streaming_callback set_previous_utterance_streaming_callback; wakeup_manager_set_follow_up_streaming_callback set_follow_up_streaming_callback; wakeup_manager_set_speech_status_callback set_speech_status_callback; + wakeup_manager_set_setting_changed_callback set_setting_changed_callback; wakeup_manager_set_error_callback set_error_callback; wakeup_manager_set_streaming_section_changed_callback set_streaming_section_changed_callback; } wakeup_manager_interface; diff --git a/inc/multi_wakeup_recognizer.h b/inc/multi_wakeup_recognizer.h index 6c3eb6f..b0732f9 100644 --- a/inc/multi_wakeup_recognizer.h +++ b/inc/multi_wakeup_recognizer.h @@ -99,6 +99,8 @@ typedef void (*wakeup_service_speech_streaming_cb)(wakeup_speech_streaming_event typedef void (*wakeup_service_speech_status_cb)(wakeup_speech_status_e status, void *user_data); +typedef void (*wakeup_service_setting_changed_cb)(void *user_data); + typedef void (*wakeup_service_error_cb)(int error, const char* err_msg, void* user_data); typedef void (*wakeup_service_streaming_section_changed_cb)(ma_audio_streaming_data_section_e section, void* user_data); diff --git a/plugins/wakeup-manager/inc/wakeup_manager.h b/plugins/wakeup-manager/inc/wakeup_manager.h index e6f5251..d574646 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager.h +++ b/plugins/wakeup-manager/inc/wakeup_manager.h @@ -50,6 +50,12 @@ public: virtual void on_audio_streaming_data_section(ma_audio_streaming_data_section_e section) = 0; }; +class ISettingValueObserver { +public: + virtual ~ISettingValueObserver() = default; + virtual void on_value_changed() = 0; +}; + /* If a wakeup event is raised by pressing a voice key, the wakeup_engine attribute of wakeup_event_info will have the following value */ #define WAKEUP_ENGINE_VOICE_KEY "voice_key" @@ -57,7 +63,7 @@ public: class CWakeupManager { public: - CWakeupManager(IWakeupEventObserver *observer); + CWakeupManager(IWakeupEventObserver* wakeup_observer, ISettingValueObserver* setting_observer); virtual ~CWakeupManager(); CWakeupManager(const CWakeupManager&) = delete; @@ -66,8 +72,11 @@ public: bool initialize(); bool deinitialize(); - void subscribe(IWakeupEventObserver *observer); - void unsubscribe(IWakeupEventObserver *observer); + void subscribe_wakeup_observer(IWakeupEventObserver* observer); + void unsubscribe_wakeup_observer(IWakeupEventObserver* observer); + + void subscribe_setting_observer(ISettingValueObserver* observer); + void unsubscribe_setting_observer(ISettingValueObserver* observer); bool activate(); bool deactivate(); @@ -107,9 +116,11 @@ public: CAudioManager* get_audio_manager(); CWakeupSettings* get_wakeup_settings(); - vector get_observers(); + vector get_wakeup_observers(); void set_last_wakeup_event_info(wakeup_event_info wakeup_info); + vector get_setting_observers(); + bool change_manager_state(wakeup_manager_state_e state); wakeup_manager_state_e get_manager_state(); @@ -178,7 +189,8 @@ private: map mAssistantSupportsCurrentLanguage; map mAssistantEnabled; - vector mObservers; + vector mWakeupObservers; + vector mSettingObservers; unique_ptr mWakeupPolicy; diff --git a/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h b/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h index 7f408dc..2df503e 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h +++ b/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h @@ -63,6 +63,8 @@ typedef void (*wakeup_service_speech_streaming_cb)(wakeup_speech_streaming_event typedef void (*wakeup_service_speech_status_cb)(wakeup_service_speech_status_e status, void *user_data); +typedef void (*wakeup_service_setting_changed_cb)( void *user_data); + typedef void (*wakeup_service_error_cb)(int error, const char* err_msg, void* user_data); typedef void (*wakeup_service_audio_data_require_status_cb)(bool require, void* user_data); @@ -146,6 +148,8 @@ EXPORT_API int wakeup_manager_set_follow_up_streaming_callback(wakeup_service_sp EXPORT_API int wakeup_manager_set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data); +EXPORT_API int wakeup_manager_set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data); + EXPORT_API int wakeup_manager_set_error_callback(wakeup_service_error_cb callback, void* user_data); EXPORT_API int wakeup_manager_set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data); diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 81ed6eb..9e16d36 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -54,12 +54,15 @@ static bool initialize_wakeup_event_info(wakeup_event_info* wakeup_info) return ret; } -CWakeupManager::CWakeupManager(IWakeupEventObserver *observer) +CWakeupManager::CWakeupManager(IWakeupEventObserver* wakeup_observer, ISettingValueObserver* setting_observer) { initialize_wakeup_event_info(&mLastWakeupEventInfo); - if (observer) { - subscribe(observer); + if (wakeup_observer) { + subscribe_wakeup_observer(wakeup_observer); + } + if (setting_observer) { + subscribe_setting_observer(setting_observer); } } @@ -136,16 +139,29 @@ bool CWakeupManager::deinitialize() return true; } -void CWakeupManager::subscribe(IWakeupEventObserver *observer) +void CWakeupManager::subscribe_wakeup_observer(IWakeupEventObserver *observer) { - mObservers.push_back(observer); + mWakeupObservers.push_back(observer); } -void CWakeupManager::unsubscribe(IWakeupEventObserver *observer) +void CWakeupManager::unsubscribe_wakeup_observer(IWakeupEventObserver *observer) { - auto iter = find(mObservers.begin(), mObservers.end(), observer); - if (iter != mObservers.end()) { - mObservers.erase(iter); + auto iter = find(mWakeupObservers.begin(), mWakeupObservers.end(), observer); + if (iter != mWakeupObservers.end()) { + mWakeupObservers.erase(iter); + } +} + +void CWakeupManager::subscribe_setting_observer(ISettingValueObserver* observer) +{ + mSettingObservers.push_back(observer); +} + +void CWakeupManager::unsubscribe_setting_observer(ISettingValueObserver* observer) +{ + auto iter = find(mSettingObservers.begin(), mSettingObservers.end(), observer); + if (iter != mSettingObservers.end()) { + mSettingObservers.erase(iter); } } @@ -469,7 +485,7 @@ bool CWakeupManager::process_event(ma_plugin_event_e event, void* data, int len) set_last_wakeup_event_info(wakeup_info); mWakeupEngineManager.set_selected_wakeup_info(wakeup_info); - for (const auto& observer : mObservers) { + for (const auto& observer : mWakeupObservers) { observer->on_wakeup(wakeup_info); } } @@ -498,9 +514,9 @@ bool CWakeupManager::process_event(ma_plugin_event_e event, void* data, int len) return true; } -vector CWakeupManager::get_observers() +vector CWakeupManager::get_wakeup_observers() { - return mObservers; + return mWakeupObservers; } void CWakeupManager::set_last_wakeup_event_info(wakeup_event_info wakeup_info) @@ -508,6 +524,11 @@ void CWakeupManager::set_last_wakeup_event_info(wakeup_event_info wakeup_info) mLastWakeupEventInfo = wakeup_info; } +vector CWakeupManager::get_setting_observers() +{ + return mSettingObservers; +} + static Eina_Bool streaming_duration_expired(void *data) { MWR_LOGD("[ENTER]"); @@ -534,7 +555,7 @@ static Eina_Bool streaming_duration_expired(void *data) } unsigned char final_buffer[2] = {'\0', }; - vector observers = wakeup_manager->get_observers(); + vector observers = wakeup_manager->get_wakeup_observers(); for (const auto& observer : observers) { observer->on_streaming_audio_data( WAKEUP_SPEECH_STREAMING_EVENT_FINISH, final_buffer, sizeof(final_buffer)); @@ -841,7 +862,7 @@ bool CWakeupManager::CEngineEventObserver::on_streaming_audio_data( { if (nullptr == mWakeupManager) return false; - vector observers = mWakeupManager->get_observers(); + vector observers = mWakeupManager->get_wakeup_observers(); for (const auto& observer : observers) { observer->on_streaming_audio_data(event, buffer, len); } @@ -857,7 +878,7 @@ bool CWakeupManager::CEngineEventObserver::on_audio_streaming_data_section( { if (nullptr == mWakeupManager) return false; - vector observers = mWakeupManager->get_observers(); + vector observers = mWakeupManager->get_wakeup_observers(); for (const auto& observer : observers) { observer->on_audio_streaming_data_section(section); } @@ -878,7 +899,7 @@ void CWakeupManager::CPolicyEventObserver::on_wakeup(wakeup_event_info wakeup_in mWakeupManager->set_last_wakeup_event_info(wakeup_info); engine_manager->set_selected_wakeup_info(wakeup_info); - vector observers = mWakeupManager->get_observers(); + vector observers = mWakeupManager->get_wakeup_observers(); for (const auto& observer : observers) { observer->on_wakeup(wakeup_info); } @@ -906,7 +927,7 @@ bool CWakeupManager::CAudioEventObserver::on_streaming_audio_data( { if (nullptr == mWakeupManager) return false; - vector observers = mWakeupManager->get_observers(); + vector observers = mWakeupManager->get_wakeup_observers(); for (const auto& observer : observers) { observer->on_streaming_audio_data(event, buffer, len); } @@ -922,6 +943,10 @@ bool CWakeupManager::CSettingsEventObserver::on_voice_input_language_changed( { if (nullptr == mWakeupManager || nullptr == language) return false; mWakeupManager->set_language(std::string(language)); + vector observers = mWakeupManager->get_setting_observers(); + for (const auto& observer : observers) { + observer->on_value_changed(); + } return true; } @@ -930,6 +955,10 @@ bool CWakeupManager::CSettingsEventObserver::on_assistant_enabled_info_changed( { if (nullptr == mWakeupManager || nullptr == appid) return false; mWakeupManager->set_assistant_enabled(std::string(appid), enabled); + vector observers = mWakeupManager->get_setting_observers(); + for (const auto& observer : observers) { + observer->on_value_changed(); + } return true; } @@ -938,6 +967,10 @@ bool CWakeupManager::CSettingsEventObserver::on_default_assistant_appid_changed( { if (nullptr == mWakeupManager || nullptr == appid) return false; mWakeupManager->set_default_assistant(std::string(appid)); + vector observers = mWakeupManager->get_setting_observers(); + for (const auto& observer : observers) { + observer->on_value_changed(); + } return true; } diff --git a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp index 9853c34..1c72602 100644 --- a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp @@ -34,6 +34,9 @@ static void* g_follow_up_streaming_user_data; static wakeup_service_speech_status_cb g_speech_status_cb; static void* g_speech_status_user_data; +static wakeup_service_setting_changed_cb g_setting_changed_cb; +static void* g_setting_changed_user_data; + static wakeup_service_error_cb g_error_cb; static void* g_error_user_data; @@ -48,8 +51,14 @@ class CWakeupEventObserver : public IWakeupEventObserver void on_audio_streaming_data_section(ma_audio_streaming_data_section_e section) override; }; +class CSettingValueObserver : public ISettingValueObserver +{ + void on_value_changed() override; +}; + static CWakeupEventObserver g_wakeup_event_observer; -static CWakeupManager g_wakeup_manager(&g_wakeup_event_observer); +static CSettingValueObserver g_setting_value_observer; +static CWakeupManager g_wakeup_manager(&g_wakeup_event_observer, &g_setting_value_observer); int wakeup_manager_initialize(void) { @@ -67,6 +76,9 @@ int wakeup_manager_initialize(void) g_speech_status_cb = NULL; g_speech_status_user_data = NULL; + g_setting_changed_cb = NULL; + g_setting_changed_user_data = NULL; + g_error_cb = NULL; g_error_user_data = NULL; @@ -481,6 +493,22 @@ int wakeup_manager_set_speech_status_callback(wakeup_service_speech_status_cb ca return 0; } +int wakeup_manager_set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data) +{ + MWR_LOGD("[ENTER]"); + + if (NULL == callback) { + MWR_LOGE("[ERROR] Input parameter is NULL"); + return -1; + } + + g_setting_changed_cb = callback; + g_setting_changed_user_data = user_data; + + MWR_LOGD("[END]"); + return 0; +} + int wakeup_manager_set_error_callback(wakeup_service_error_cb callback, void* user_data) { MWR_LOGD("[ENTER]"); @@ -549,3 +577,10 @@ void CWakeupEventObserver::on_audio_streaming_data_section( g_streaming_section_changed_cb(section, g_streaming_section_changed_user_data); } } + +void CSettingValueObserver::on_value_changed() +{ + if (g_setting_changed_cb) { + g_setting_changed_cb(g_setting_changed_user_data); + } +} \ No newline at end of file diff --git a/src/multi_assistant_service.c b/src/multi_assistant_service.c index b2da67b..35cc1ed 100644 --- a/src/multi_assistant_service.c +++ b/src/multi_assistant_service.c @@ -762,16 +762,7 @@ static int init_wakeup(void) #endif } - /* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */ - int prelaunch_mode; - int res = vconf_get_bool(WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE, &prelaunch_mode); - if (0 == res && 0 != prelaunch_mode) { - const char *default_assistant = NULL; - if (0 == multi_assistant_service_plugin_get_default_assistant(&default_assistant)) { - MAS_LOGD("prelaunching default_assistant_appid : %s", default_assistant); - mas_launch_client_by_appid(default_assistant, CLIENT_LAUNCH_MODE_PRELAUNCH); - } - } + mas_prelaunch_default_assistant(); /* For the case of preprocessing assistant, it always have to be launched beforehand */ char *vconf_str; @@ -1080,6 +1071,23 @@ int mas_launch_client_by_wakeup_word(const char *wakeup_word) return mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION); } +int mas_prelaunch_default_assistant() +{ + /* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */ + int prelaunch_mode; + int res = vconf_get_bool(WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE, &prelaunch_mode); + if (0 == res && 0 != prelaunch_mode) { + const char *default_assistant = NULL; + if (0 == multi_assistant_service_plugin_get_default_assistant(&default_assistant)) { + if (0 == aul_app_is_running(default_assistant)) { + MAS_LOGD("prelaunching default_assistant_appid : %s", default_assistant); + mas_launch_client_by_appid(default_assistant, CLIENT_LAUNCH_MODE_PRELAUNCH); + } + } + } + return 0; +} + int mas_process_voice_key_event(bool pressed) { diff --git a/src/multi_assistant_service_plugin.c b/src/multi_assistant_service_plugin.c index 5e9e063..8307104 100644 --- a/src/multi_assistant_service_plugin.c +++ b/src/multi_assistant_service_plugin.c @@ -337,6 +337,12 @@ static void __error_cb(int error, const char* err_msg, void* user_data) } } +static void __setting_changed_cb(void *user_data) +{ + mas_prelaunch_default_assistant(); + MAS_LOGD( "[SUCCESS] __setting_changed_cb is called"); +} + static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e section, void* user_data) { MAS_LOGD( "[SUCCESS] __streaming_section_changed_cb is called, section(%d)", section); @@ -454,6 +460,9 @@ int multi_assistant_service_plugin_initialize(void) _wakeup_manager_interface.set_speech_status_callback = (wakeup_manager_set_speech_status_callback)dlsym(g_handle, MA_WAKEUP_MANAGER_FUNC_SET_SPEECH_STATUS_CALLBACK); + _wakeup_manager_interface.set_setting_changed_callback = + (wakeup_manager_set_setting_changed_callback)dlsym(g_handle, + MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK); _wakeup_manager_interface.set_error_callback = (wakeup_manager_set_error_callback)dlsym(g_handle, MA_WAKEUP_MANAGER_FUNC_SET_ERROR_CALLBACK); @@ -996,6 +1005,12 @@ int multi_assistant_service_plugin_set_callbacks(void) return ret; } + ret = multi_assistant_service_plugin_set_setting_changed_callback(__setting_changed_cb, NULL); + if (0 != ret) { + MAS_LOGE("Fail to set setting changed cb"); + return ret; + } + ret = multi_assistant_service_plugin_set_error_callback(__error_cb, NULL); if (0 != ret) { MAS_LOGE("Fail to set error cb"); @@ -1104,6 +1119,23 @@ int multi_assistant_service_plugin_set_speech_status_callback(wakeup_service_spe return ret; } +int multi_assistant_service_plugin_set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data) +{ + int ret = -1; + if (NULL != g_handle) { + wakeup_manager_set_setting_changed_callback func = _wakeup_manager_interface.set_setting_changed_callback; + if (NULL == func) { + MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_SETTING_CHANGED_CALLBACK); + } else { + ret = func(callback, user_data); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to set setting_changed callback, ret(%d)", ret); + } + } + } + return ret; +} + int multi_assistant_service_plugin_set_error_callback(wakeup_service_error_cb callback, void* user_data) { int ret = -1; -- 2.7.4 From 02784ac4a8b72a15134b394c2bbee278eb27333c Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 29 Oct 2019 16:04:40 +0900 Subject: [PATCH 14/16] Bump version to 0.2.6 Change-Id: I0d42ae4371b25e7e24e8cd4329251ba39f672fe9 --- org.tizen.multi-assistant-service.xml | 2 +- packaging/org.tizen.multi-assistant-service.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.multi-assistant-service.xml b/org.tizen.multi-assistant-service.xml index 483d407..15f683c 100644 --- a/org.tizen.multi-assistant-service.xml +++ b/org.tizen.multi-assistant-service.xml @@ -1,5 +1,5 @@ - + Won Nam Jang Sooyeon Kim diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index 9f783fc..127eeb5 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -1,6 +1,6 @@ Name: org.tizen.multi-assistant-service Summary: Multi assistant service -Version: 0.2.5 +Version: 0.2.6 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From 11a6ddfc6830fce8f1850c0dbab91a0dc614286e Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 31 Oct 2019 20:16:18 +0900 Subject: [PATCH 15/16] Finalize audio data when voice key is in pressed state When audio is finalized after voice key variable is set to false, the FINISH audio event will be fed to wakeup engines where the event itself is not useful for wakeup engines. Change-Id: Ifdd41be5e76a84b779d697edefd57203ac2bfe5a --- plugins/wakeup-manager/src/wakeup_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 9e16d36..1ac4694 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -491,8 +491,8 @@ bool CWakeupManager::process_event(ma_plugin_event_e event, void* data, int len) } } else if (MA_PLUGIN_EVENT_VOICE_KEY_RELEASED_AFTER_PUSH == event) { if (mVoiceKeyPressed != false) { - mVoiceKeyPressed = false; mAudioManager.finalize_audio_data(); + mVoiceKeyPressed = false; if (mWakeupEngineManager.get_audio_data_required()) { /* Restart recorder thread using appropriate recording device */ -- 2.7.4 From 199d497dec43a6f3b1a20844c64bf9feccd4bd55 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 31 Oct 2019 20:20:28 +0900 Subject: [PATCH 16/16] Change manager state right away on voice key release Change-Id: I97f074bfca65f0af8e770eae675dbf46fbb8713d --- plugins/wakeup-manager/src/wakeup_manager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 1ac4694..12b82a8 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -494,6 +494,12 @@ bool CWakeupManager::process_event(ma_plugin_event_e event, void* data, int len) mAudioManager.finalize_audio_data(); mVoiceKeyPressed = false; + if (STREAMING_MODE::UTTERANCE == mStreamingMode) { + change_manager_state(WAKEUP_MANAGER_STATE_PROCESSING); + } else { + change_manager_state(WAKEUP_MANAGER_STATE_LISTENING); + } + if (mWakeupEngineManager.get_audio_data_required()) { /* Restart recorder thread using appropriate recording device */ mAudioManager.stop_recording(true); -- 2.7.4