From 137c84eed7a7a8a1afd264f638f94b5191b94414 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 19 Jan 2023 19:23:10 +0900 Subject: [PATCH 01/16] Fix coding convention about member variables and static functions - Issue: Using two underscores(__) as name of variables or functions is reserved by C and CPP compilers, so it may occur name colision. - Solution: Previously, most of the code followed old tizen coding convention. However, in case of name, the convention conflicts with C and CPP standard, because two underscore is already reserved as an identifier by C and CPP standard. Thus, using two underscores may cause some problems. To resolve this collision, this patch fixes the name of member variables and static functions to match C and CPP standard. Through this patch, CPP files in the project do not use two underscore as name of variables and functions anymore. Change-Id: I2309c0c1d7bdb37a3b55f996d1d0372dc39dd856 Signed-off-by: Suyeon Hwang --- audio-manager/src/vc_audio_manager.cpp | 16 ++-- client/vc_mgr_ducking.cpp | 72 +++++++++--------- common/VoiceControlClientInfo.cpp | 42 +++++------ common/VoiceControlClientInfo.h | 8 +- common/VoiceControlClients.cpp | 44 +++++------ common/VoiceControlClients.h | 4 +- common/VoiceControlConfig.cpp | 94 +++++++++++------------ common/VoiceControlConfig.h | 4 +- common/VoiceControlEngineInfo.cpp | 38 +++++----- common/VoiceControlEngineInfo.h | 12 +-- common/VoiceControlEngines.cpp | 36 ++++----- common/VoiceControlEngines.h | 4 +- common/vc_config_mgr.cpp | 132 ++++++++++++++++----------------- server/vcd_server_data.cpp | 8 +- 14 files changed, 257 insertions(+), 257 deletions(-) diff --git a/audio-manager/src/vc_audio_manager.cpp b/audio-manager/src/vc_audio_manager.cpp index 51c7a97..00f7485 100644 --- a/audio-manager/src/vc_audio_manager.cpp +++ b/audio-manager/src/vc_audio_manager.cpp @@ -46,7 +46,7 @@ static int g_audio_channel = 0; volatile static bool g_is_recording = false; -static bool __convert_audio_channel(int channel, audio_channel_e* output) +static bool convert_audio_channel(int channel, audio_channel_e* output) { audio_channel_e audio_ch = AUDIO_CHANNEL_MONO; @@ -84,7 +84,7 @@ static bool __convert_audio_channel(int channel, audio_channel_e* output) return true; } -static bool __convert_audio_sample_type(vce_audio_type_e audio_type, audio_sample_type_e* output) +static bool convert_audio_sample_type(vce_audio_type_e audio_type, audio_sample_type_e* output) { audio_sample_type_e audio_sample_type = AUDIO_SAMPLE_TYPE_S16_LE; @@ -104,7 +104,7 @@ static bool __convert_audio_sample_type(vce_audio_type_e audio_type, audio_sampl return true; } -static Eina_Bool __recorder_timer_func(void *data) +static Eina_Bool recorder_timer_func(void *data) { const int FRAME_LENGTH = 160; const int BUFFER_LENGTH = FRAME_LENGTH * 2; @@ -150,11 +150,11 @@ int vcd_dependency_initialize(sound_stream_info_h stream_info_h, dependency_audi audio_channel_e audio_ch = AUDIO_CHANNEL_MONO; audio_sample_type_e audio_sample_type = AUDIO_SAMPLE_TYPE_U8; - if (false == __convert_audio_channel(g_audio_channel, &audio_ch)) { + if (false == convert_audio_channel(g_audio_channel, &audio_ch)) { return VCE_ERROR_INVALID_PARAMETER; } - if (false == __convert_audio_sample_type(g_audio_type, &audio_sample_type)) { + if (false == convert_audio_sample_type(g_audio_type, &audio_sample_type)) { return VCE_ERROR_INVALID_PARAMETER; } @@ -241,11 +241,11 @@ int vcd_dependency_set_audio_info(sound_stream_info_h stream_info_h, const char* audio_channel_e audio_ch = AUDIO_CHANNEL_MONO; audio_sample_type_e audio_sample_type = AUDIO_SAMPLE_TYPE_U8; - if (false == __convert_audio_channel(channel, &audio_ch)) { + if (false == convert_audio_channel(channel, &audio_ch)) { return VCE_ERROR_INVALID_PARAMETER; } - if (false == __convert_audio_sample_type(type, &audio_sample_type)) { + if (false == convert_audio_sample_type(type, &audio_sample_type)) { return VCE_ERROR_INVALID_PARAMETER; } @@ -319,7 +319,7 @@ int vcd_dependency_start_recording(void) /* Add ecore timer to read audio data */ ecore_main_loop_thread_safe_call_async([](void* data)->void { - ecore_timer_add(0, __recorder_timer_func, NULL); + ecore_timer_add(0, recorder_timer_func, NULL); }, NULL); diff --git a/client/vc_mgr_ducking.cpp b/client/vc_mgr_ducking.cpp index 06a2290..bbec1d7 100644 --- a/client/vc_mgr_ducking.cpp +++ b/client/vc_mgr_ducking.cpp @@ -32,7 +32,7 @@ static sound_stream_ducking_h g_voice_information_stream_h = nullptr; static bool g_is_created = false; -static const char *__get_ducking_stream(sound_stream_type_e stream_type) +static const char *get_ducking_stream(sound_stream_type_e stream_type) { if (SOUND_STREAM_TYPE_MEDIA == stream_type) return "Media stream"; @@ -48,7 +48,7 @@ static const char *__get_ducking_stream(sound_stream_type_e stream_type) return "Non matched stream"; } -static sound_stream_ducking_h __create_ducking_handle(sound_stream_type_e type) +static sound_stream_ducking_h create_ducking_handle(sound_stream_type_e type) { sound_stream_ducking_h ducking_handle = nullptr; @@ -62,7 +62,7 @@ static sound_stream_ducking_h __create_ducking_handle(sound_stream_type_e type) return ducking_handle; } -static void __destroy_ducking_handle(sound_stream_ducking_h ducking_handle) +static void destroy_ducking_handle(sound_stream_ducking_h ducking_handle) { if (nullptr == ducking_handle) { return; @@ -73,7 +73,7 @@ static void __destroy_ducking_handle(sound_stream_ducking_h ducking_handle) SLOG(LOG_WARN, TAG_VCM, "Destroy ducking handle DONE. ret(%d/%s)", ret, get_error_message(ret)); } -static bool __is_all_ducking_handle_valid() +static bool is_all_ducking_handle_valid() { if (nullptr == g_media_stream_h || nullptr == g_system_stream_h || nullptr == g_notification_stream_h || nullptr == g_alarm_stream_h || nullptr == g_voice_information_stream_h) { @@ -83,13 +83,13 @@ static bool __is_all_ducking_handle_valid() return true; } -static void __destroy_all_ducking_handle() +static void destroy_all_ducking_handle() { - __destroy_ducking_handle(g_media_stream_h); - __destroy_ducking_handle(g_system_stream_h); - __destroy_ducking_handle(g_notification_stream_h); - __destroy_ducking_handle(g_alarm_stream_h); - __destroy_ducking_handle(g_voice_information_stream_h); + destroy_ducking_handle(g_media_stream_h); + destroy_ducking_handle(g_system_stream_h); + destroy_ducking_handle(g_notification_stream_h); + destroy_ducking_handle(g_alarm_stream_h); + destroy_ducking_handle(g_voice_information_stream_h); g_media_stream_h = nullptr; g_system_stream_h = nullptr; @@ -105,14 +105,14 @@ int vc_mgr_ducking_create(void) return VC_ERROR_NONE; } - g_media_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_MEDIA); - g_system_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_SYSTEM); - g_notification_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_NOTIFICATION); - g_alarm_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_ALARM); - g_voice_information_stream_h = __create_ducking_handle(SOUND_STREAM_TYPE_VOICE_INFORMATION); + g_media_stream_h = create_ducking_handle(SOUND_STREAM_TYPE_MEDIA); + g_system_stream_h = create_ducking_handle(SOUND_STREAM_TYPE_SYSTEM); + g_notification_stream_h = create_ducking_handle(SOUND_STREAM_TYPE_NOTIFICATION); + g_alarm_stream_h = create_ducking_handle(SOUND_STREAM_TYPE_ALARM); + g_voice_information_stream_h = create_ducking_handle(SOUND_STREAM_TYPE_VOICE_INFORMATION); - if (false == __is_all_ducking_handle_valid()) { - __destroy_all_ducking_handle(); + if (false == is_all_ducking_handle_valid()) { + destroy_all_ducking_handle(); SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create ducking handles"); return VC_ERROR_OPERATION_FAILED; } @@ -123,27 +123,27 @@ int vc_mgr_ducking_create(void) int vc_mgr_ducking_destroy(void) { - __destroy_all_ducking_handle(); + destroy_all_ducking_handle(); g_is_created = false; return VC_ERROR_NONE; } -static int __activate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header, double ratio) +static int activate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header, double ratio) { bool is_ducked = false; int ret = SOUND_MANAGER_ERROR_NONE; ret = sound_manager_is_ducked(header, &is_ducked); if (is_ducked) { - SLOG(LOG_DEBUG, TAG_VCM, "The %s is already ducked", __get_ducking_stream(type)); + SLOG(LOG_DEBUG, TAG_VCM, "The %s is already ducked", get_ducking_stream(type)); return ret; } ret = sound_manager_activate_ducking(header, SND_MGR_DUCKING_DURATION, ratio); if (SOUND_MANAGER_ERROR_NONE != ret) - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to activate ducking for %s", __get_ducking_stream(type)); + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to activate ducking for %s", get_ducking_stream(type)); else - SLOG(LOG_INFO, TAG_VCM, "Activate ducking for %s", __get_ducking_stream(type)); + SLOG(LOG_INFO, TAG_VCM, "Activate ducking for %s", get_ducking_stream(type)); return ret; } @@ -153,41 +153,41 @@ int vc_mgr_ducking_activate(double ratio) SLOG(LOG_INFO, TAG_VCM, "vc_mgr_ducking_activate ratio(%lf)", ratio); int ret = VC_ERROR_NONE; - ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_h, ratio); + ret = activate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_h, ratio); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h, ratio); + ret = activate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h, ratio); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h, ratio); + ret = activate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h, ratio); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_h, ratio); + ret = activate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_h, ratio); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = __activate_ducking_sound_stream(SOUND_STREAM_TYPE_VOICE_INFORMATION, g_voice_information_stream_h, ratio); + ret = activate_ducking_sound_stream(SOUND_STREAM_TYPE_VOICE_INFORMATION, g_voice_information_stream_h, ratio); return ret; } -static int __deactivate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header) +static int deactivate_ducking_sound_stream(sound_stream_type_e type, sound_stream_ducking_h header) { bool is_ducked = false; int ret = SOUND_MANAGER_ERROR_NONE; ret = sound_manager_is_ducked(header, &is_ducked); if (false == is_ducked) { - SLOG(LOG_DEBUG, TAG_VCM, "The %s is already recovered from ducking", __get_ducking_stream(type)); + SLOG(LOG_DEBUG, TAG_VCM, "The %s is already recovered from ducking", get_ducking_stream(type)); return ret; } ret = sound_manager_deactivate_ducking(header); if (SOUND_MANAGER_ERROR_NONE != ret) - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to deactivate ducking for %s", __get_ducking_stream(type)); + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to deactivate ducking for %s", get_ducking_stream(type)); else - SLOG(LOG_INFO, TAG_VCM, "Deactivate ducking for %s", __get_ducking_stream(type)); + SLOG(LOG_INFO, TAG_VCM, "Deactivate ducking for %s", get_ducking_stream(type)); return ret; } @@ -197,22 +197,22 @@ int vc_mgr_ducking_deactivate(void) SLOG(LOG_INFO, TAG_VCM, "vc_mgr_ducking_deactivate"); int ret = VC_ERROR_NONE; - ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_h); + ret = deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_MEDIA, g_media_stream_h); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h); + ret = deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h); + ret = deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_h); + ret = deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_ALARM, g_alarm_stream_h); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = __deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_VOICE_INFORMATION, g_voice_information_stream_h); + ret = deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_VOICE_INFORMATION, g_voice_information_stream_h); return ret; } diff --git a/common/VoiceControlClientInfo.cpp b/common/VoiceControlClientInfo.cpp index 8ce8f62..b1954af 100644 --- a/common/VoiceControlClientInfo.cpp +++ b/common/VoiceControlClientInfo.cpp @@ -25,68 +25,68 @@ using namespace std; VoiceControlClientInfo::VoiceControlClientInfo(unsigned int uid) { SLOG(LOG_INFO, TAG_VCCONFIG, "[Constructor] VoiceControlClientInfo"); - __engineChangedCallback = nullptr; - __languageChangedCallback = nullptr; - __enabledChangedCallback = nullptr; - __uid = uid; + mEngineChangedCallback = nullptr; + mLanguageChangedCallback = nullptr; + mEnabledChangedCallback = nullptr; + mUid = uid; } VoiceControlClientInfo::~VoiceControlClientInfo() { SLOG(LOG_INFO, TAG_VCCONFIG, "[Destructor] VoiceControlClientInfo"); - __engineChangedCallback = nullptr; - __languageChangedCallback = nullptr; - __enabledChangedCallback = nullptr; - __uid = 0; + mEngineChangedCallback = nullptr; + mLanguageChangedCallback = nullptr; + mEnabledChangedCallback = nullptr; + mUid = 0; } unsigned int VoiceControlClientInfo::getUid() { - return __uid; + return mUid; } void VoiceControlClientInfo::setEngineChangedCallback(vc_config_engine_changed_cb callback) { - __engineChangedCallback = callback; + mEngineChangedCallback = callback; } void VoiceControlClientInfo::invokeEngineChangedCallback(const char *engine_appid) { - if (__engineChangedCallback == nullptr) { - SLOG(LOG_DEBUG, TAG_VCCONFIG, "Engine changed callback is not set. uid(%u)", __uid); + if (mEngineChangedCallback == nullptr) { + SLOG(LOG_DEBUG, TAG_VCCONFIG, "Engine changed callback is not set. uid(%u)", mUid); return; } - __engineChangedCallback(engine_appid); + mEngineChangedCallback(engine_appid); } void VoiceControlClientInfo::setLanguageChangedCallback(vc_config_lang_changed_cb callback) { - __languageChangedCallback = callback; + mLanguageChangedCallback = callback; } void VoiceControlClientInfo::invokeLanguageChangedCallback(const char* before_lang, const char* current_lang) { - if (__languageChangedCallback == nullptr) { - SLOG(LOG_DEBUG, TAG_VCCONFIG, "language changed callback is not set. uid(%u)", __uid); + if (mLanguageChangedCallback == nullptr) { + SLOG(LOG_DEBUG, TAG_VCCONFIG, "language changed callback is not set. uid(%u)", mUid); return; } - __languageChangedCallback(before_lang, current_lang); + mLanguageChangedCallback(before_lang, current_lang); } void VoiceControlClientInfo::setEnabledChangedCallback(vc_config_enabled_cb callback) { - __enabledChangedCallback = callback; + mEnabledChangedCallback = callback; } void VoiceControlClientInfo::invokeEnabledChangedCallback(bool enable) { - if (__enabledChangedCallback == nullptr) { - SLOG(LOG_DEBUG, TAG_VCCONFIG, "Enabled changed callback is not set. uid(%u)", __uid); + if (mEnabledChangedCallback == nullptr) { + SLOG(LOG_DEBUG, TAG_VCCONFIG, "Enabled changed callback is not set. uid(%u)", mUid); return; } - __enabledChangedCallback(enable); + mEnabledChangedCallback(enable); } diff --git a/common/VoiceControlClientInfo.h b/common/VoiceControlClientInfo.h index d6df960..755f912 100644 --- a/common/VoiceControlClientInfo.h +++ b/common/VoiceControlClientInfo.h @@ -38,10 +38,10 @@ public: void invokeEnabledChangedCallback(bool enable); private: - unsigned int __uid; - vc_config_engine_changed_cb __engineChangedCallback; - vc_config_lang_changed_cb __languageChangedCallback; - vc_config_enabled_cb __enabledChangedCallback; + unsigned int mUid; + vc_config_engine_changed_cb mEngineChangedCallback; + vc_config_lang_changed_cb mLanguageChangedCallback; + vc_config_enabled_cb mEnabledChangedCallback; }; #endif /* __VC_COMMON_VOICE_CONTROL_CLIENT_INFO_H_ */ diff --git a/common/VoiceControlClients.cpp b/common/VoiceControlClients.cpp index cb72caf..2b5464d 100644 --- a/common/VoiceControlClients.cpp +++ b/common/VoiceControlClients.cpp @@ -30,14 +30,14 @@ VoiceControlClients::~VoiceControlClients() void VoiceControlClients::printOutClients() { - unique_lock lock(__clientsMutex); + unique_lock lock(mClientsMutex); SLOG(LOG_DEBUG, TAG_VCCONFIG, "@ Client list @"); - if (0 == __clients.size()) { + if (0 == mClients.size()) { SLOG(LOG_DEBUG, TAG_VCCONFIG, " No Client"); } else { unsigned int index = 0; - for (auto &clientInfo : __clients) { + for (auto &clientInfo : mClients) { SLOG(LOG_DEBUG, TAG_VCCONFIG, "[%dth] uid(%u)", index, clientInfo.getUid()); } } @@ -47,29 +47,29 @@ void VoiceControlClients::printOutClients() void VoiceControlClients::appendClient(VoiceControlClientInfo &clientInfo) { - unique_lock lock(__clientsMutex); - __clients.push_back(clientInfo); + unique_lock lock(mClientsMutex); + mClients.push_back(clientInfo); } std::size_t VoiceControlClients::removeClient(unsigned int uid) { - unique_lock lock(__clientsMutex); + unique_lock lock(mClientsMutex); SLOG(LOG_DEBUG, TAG_VCCONFIG, "Remove client ID (%u)", uid); - for (auto iter = __clients.begin(); iter != __clients.end(); iter++) { + for (auto iter = mClients.begin(); iter != mClients.end(); iter++) { if (iter->getUid() == uid) { SLOG(LOG_INFO, TAG_VCCONFIG, "Success to remove client (%u)", uid); - __clients.erase(iter); - return __clients.size(); + mClients.erase(iter); + return mClients.size(); } } SLOG(LOG_ERROR, TAG_VCCONFIG, "There is no client (%u)", uid); - return __clients.size(); + return mClients.size(); } void VoiceControlClients::setEngineChangedCallback(unsigned int uid, vc_config_engine_changed_cb callback) { - unique_lock lock(__clientsMutex); + unique_lock lock(mClientsMutex); auto clientInfo = findClient(uid); if (clientInfo == nullptr) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Fail to found client info"); @@ -82,7 +82,7 @@ void VoiceControlClients::setEngineChangedCallback(unsigned int uid, vc_config_e void VoiceControlClients::setLanguageChangedCallback(unsigned int uid, vc_config_lang_changed_cb callback) { - unique_lock lock(__clientsMutex); + unique_lock lock(mClientsMutex); auto clientInfo = findClient(uid); if (clientInfo == nullptr) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Fail to found client info"); @@ -95,7 +95,7 @@ void VoiceControlClients::setLanguageChangedCallback(unsigned int uid, vc_config void VoiceControlClients::setEnabledChangedCallback(unsigned int uid, vc_config_enabled_cb callback) { - unique_lock lock(__clientsMutex); + unique_lock lock(mClientsMutex); auto clientInfo = findClient(uid); if (clientInfo == nullptr) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Fail to found client info"); @@ -108,7 +108,7 @@ void VoiceControlClients::setEnabledChangedCallback(unsigned int uid, vc_config_ bool VoiceControlClients::isUidValid(unsigned int uid) { - unique_lock lock(__clientsMutex); + unique_lock lock(mClientsMutex); bool isValid = (nullptr != findClient(uid)); SLOG(LOG_INFO, TAG_VCCONFIG, "Client Id(%u) is %svalid", uid, (isValid ? "" : "not ")); return isValid; @@ -116,7 +116,7 @@ bool VoiceControlClients::isUidValid(unsigned int uid) std::shared_ptr VoiceControlClients::getClientInfo(unsigned int uid) { - unique_lock lock(__clientsMutex); + unique_lock lock(mClientsMutex); SLOG(LOG_INFO, TAG_VCCONFIG, "Get client info with ID(%u)", uid); auto clientInfo = findClient(uid); if (clientInfo == nullptr) { @@ -130,7 +130,7 @@ std::shared_ptr VoiceControlClients::getClientInfo(unsig VoiceControlClientInfo *VoiceControlClients::findClient(unsigned int uid) { SLOG(LOG_DEBUG, TAG_VCCONFIG, "Find client ID (%u)", uid); - for (auto &clientInfo : __clients) { + for (auto &clientInfo : mClients) { if (clientInfo.getUid() == uid) { SLOG(LOG_INFO, TAG_VCCONFIG, "Success to find client (%u)", uid); return &clientInfo; @@ -143,15 +143,15 @@ VoiceControlClientInfo *VoiceControlClients::findClient(unsigned int uid) std::vector VoiceControlClients::getClients() { - unique_lock lock(__clientsMutex); - SLOG(LOG_INFO, TAG_VCCONFIG, "Get clients. size(%zu)", __clients.size()); - return __clients; + unique_lock lock(mClientsMutex); + SLOG(LOG_INFO, TAG_VCCONFIG, "Get clients. size(%zu)", mClients.size()); + return mClients; } bool VoiceControlClients::isClientEmpty() { - unique_lock lock(__clientsMutex); - SLOG(LOG_INFO, TAG_VCCONFIG, "Length of clients (%zu)", __clients.size()); - return __clients.empty(); + unique_lock lock(mClientsMutex); + SLOG(LOG_INFO, TAG_VCCONFIG, "Length of clients (%zu)", mClients.size()); + return mClients.empty(); } diff --git a/common/VoiceControlClients.h b/common/VoiceControlClients.h index 01303f5..5a10ecc 100644 --- a/common/VoiceControlClients.h +++ b/common/VoiceControlClients.h @@ -44,8 +44,8 @@ public: private: VoiceControlClientInfo *findClient(unsigned int uid); - std::vector __clients; - std::mutex __clientsMutex; + std::vector mClients; + std::mutex mClientsMutex; }; diff --git a/common/VoiceControlConfig.cpp b/common/VoiceControlConfig.cpp index 750d245..9f754b2 100644 --- a/common/VoiceControlConfig.cpp +++ b/common/VoiceControlConfig.cpp @@ -26,10 +26,10 @@ using namespace std; VoiceControlConfig::VoiceControlConfig() { - unique_lock lock(__configMutex); - __config = nullptr; + unique_lock lock(mConfigMutex); + mConfig = nullptr; - if (0 != vc_parser_load_config(&__config)) { + if (0 != vc_parser_load_config(&mConfig)) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Fail to parse configure information"); throw new runtime_error("Operation failed"); } @@ -37,48 +37,48 @@ VoiceControlConfig::VoiceControlConfig() VoiceControlConfig::~VoiceControlConfig() { - unique_lock lock(__configMutex); - vc_parser_unload_config(__config); - __config = nullptr; + unique_lock lock(mConfigMutex); + vc_parser_unload_config(mConfig); + mConfig = nullptr; } void VoiceControlConfig::printOutConfig() { - unique_lock lock(__configMutex); - SLOG(LOG_DEBUG, TAG_VCCONFIG, "Engine : %s", __config->engine_id); - SLOG(LOG_DEBUG, TAG_VCCONFIG, "Auto lang : %s", __config->auto_lang ? "true" : "false"); - SLOG(LOG_DEBUG, TAG_VCCONFIG, "Language : %s", __config->language); - SLOG(LOG_DEBUG, TAG_VCCONFIG, "Enabled : %s", __config->enabled ? "true" : "false"); + unique_lock lock(mConfigMutex); + SLOG(LOG_DEBUG, TAG_VCCONFIG, "Engine : %s", mConfig->engine_id); + SLOG(LOG_DEBUG, TAG_VCCONFIG, "Auto lang : %s", mConfig->auto_lang ? "true" : "false"); + SLOG(LOG_DEBUG, TAG_VCCONFIG, "Language : %s", mConfig->language); + SLOG(LOG_DEBUG, TAG_VCCONFIG, "Enabled : %s", mConfig->enabled ? "true" : "false"); } void VoiceControlConfig::setEngineId(const std::string engineId) { - unique_lock lock(__configMutex); - if (nullptr == __config) { + unique_lock lock(mConfigMutex); + if (nullptr == mConfig) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Config info is NULL"); return; } - free(__config->engine_id); + free(mConfig->engine_id); if (engineId.empty()) { - __config->engine_id = nullptr; + mConfig->engine_id = nullptr; } else { - __config->engine_id = strdup(engineId.c_str()); + mConfig->engine_id = strdup(engineId.c_str()); } - SLOG(LOG_ERROR, TAG_VCCONFIG, "Set Engine ID : %s", __config->engine_id); + SLOG(LOG_ERROR, TAG_VCCONFIG, "Set Engine ID : %s", mConfig->engine_id); } std::string VoiceControlConfig::getEngineId() { - unique_lock lock(__configMutex); - if (nullptr == __config) { + unique_lock lock(mConfigMutex); + if (nullptr == mConfig) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Config info is NULL"); return ""; } string result; - if (nullptr != __config->engine_id) { - result = __config->engine_id; + if (nullptr != mConfig->engine_id) { + result = mConfig->engine_id; } SLOG(LOG_ERROR, TAG_VCCONFIG, "Get Engine ID : %s", result.c_str()); @@ -87,56 +87,56 @@ std::string VoiceControlConfig::getEngineId() void VoiceControlConfig::setAutoLanguageEnabled(bool isAutoLanguageEnabled) { - unique_lock lock(__configMutex); - if (nullptr == __config) { + unique_lock lock(mConfigMutex); + if (nullptr == mConfig) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Config info is NULL"); return; } - __config->auto_lang = isAutoLanguageEnabled; - SLOG(LOG_ERROR, TAG_VCCONFIG, "Set Auto language : %s", (__config->auto_lang ? "True" : "False")); + mConfig->auto_lang = isAutoLanguageEnabled; + SLOG(LOG_ERROR, TAG_VCCONFIG, "Set Auto language : %s", (mConfig->auto_lang ? "True" : "False")); } bool VoiceControlConfig::isAutoLanguageEnabled() { - unique_lock lock(__configMutex); - if (nullptr == __config) { + unique_lock lock(mConfigMutex); + if (nullptr == mConfig) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Config info is NULL"); return false; } - SLOG(LOG_ERROR, TAG_VCCONFIG, "Get Auto language : %s", (__config->auto_lang ? "True" : "False")); - return __config->auto_lang; + SLOG(LOG_ERROR, TAG_VCCONFIG, "Get Auto language : %s", (mConfig->auto_lang ? "True" : "False")); + return mConfig->auto_lang; } void VoiceControlConfig::setCurrentLanguage(const std::string language) { - unique_lock lock(__configMutex); - if (nullptr == __config) { + unique_lock lock(mConfigMutex); + if (nullptr == mConfig) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Config info is NULL"); return; } - free(__config->language); + free(mConfig->language); if (language.empty()) { - __config->language = nullptr; + mConfig->language = nullptr; } else { - __config->language = strdup(language.c_str()); + mConfig->language = strdup(language.c_str()); } - SLOG(LOG_ERROR, TAG_VCCONFIG, "Set Language : %s", __config->language); + SLOG(LOG_ERROR, TAG_VCCONFIG, "Set Language : %s", mConfig->language); } std::string VoiceControlConfig::getCurrentLanguage() { - unique_lock lock(__configMutex); - if (nullptr == __config) { + unique_lock lock(mConfigMutex); + if (nullptr == mConfig) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Config info is NULL"); return ""; } string result; - if (nullptr != __config->language) { - result = __config->language; + if (nullptr != mConfig->language) { + result = mConfig->language; } SLOG(LOG_ERROR, TAG_VCCONFIG, "Get Language : %s", result.c_str()); return result; @@ -144,24 +144,24 @@ std::string VoiceControlConfig::getCurrentLanguage() void VoiceControlConfig::setEnabled(bool isEnabled) { - unique_lock lock(__configMutex); - if (nullptr == __config) { + unique_lock lock(mConfigMutex); + if (nullptr == mConfig) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Config info is NULL"); return; } - __config->enabled = isEnabled; - SLOG(LOG_ERROR, TAG_VCCONFIG, "Set Enabled : %s", (__config->enabled ? "True" : "False")); + mConfig->enabled = isEnabled; + SLOG(LOG_ERROR, TAG_VCCONFIG, "Set Enabled : %s", (mConfig->enabled ? "True" : "False")); } bool VoiceControlConfig::isEnabled() { - unique_lock lock(__configMutex); - if (nullptr == __config) { + unique_lock lock(mConfigMutex); + if (nullptr == mConfig) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Config info is NULL"); return false; } - SLOG(LOG_ERROR, TAG_VCCONFIG, "Get Enabled : %s", (__config->enabled ? "True" : "False")); - return __config->enabled; + SLOG(LOG_ERROR, TAG_VCCONFIG, "Get Enabled : %s", (mConfig->enabled ? "True" : "False")); + return mConfig->enabled; } diff --git a/common/VoiceControlConfig.h b/common/VoiceControlConfig.h index 2f898e4..ede37e2 100644 --- a/common/VoiceControlConfig.h +++ b/common/VoiceControlConfig.h @@ -40,8 +40,8 @@ public: bool isEnabled(); private: - vc_config_s *__config; - std::mutex __configMutex; + vc_config_s *mConfig; + std::mutex mConfigMutex; }; diff --git a/common/VoiceControlEngineInfo.cpp b/common/VoiceControlEngineInfo.cpp index 475bee1..296d74d 100644 --- a/common/VoiceControlEngineInfo.cpp +++ b/common/VoiceControlEngineInfo.cpp @@ -33,24 +33,24 @@ VoiceControlEngineInfo::VoiceControlEngineInfo(const std::string filePath) } if (engine_info->name) { - __engineName = engine_info->name; + mEngineName = engine_info->name; } if (engine_info->uuid) { - __engineId = engine_info->uuid; + mEngineId = engine_info->uuid; } if (engine_info->setting) { - __settingPath = engine_info->setting; + mSettingPath = engine_info->setting; } if (engine_info->default_lang) { - __defaultLanguage = engine_info->default_lang; + mDefaultLanguage = engine_info->default_lang; } - __nonFixedSupported = engine_info->non_fixed_support; + mNonFixedSupported = engine_info->non_fixed_support; GSList *iter = g_slist_nth(engine_info->languages, 0); while (nullptr != iter) { const char *language = static_cast(iter->data); if (language != nullptr) { - __supportedLanguages.push_back(language); + mSupportedLanguages.push_back(language); } iter = g_slist_next(iter); @@ -66,17 +66,17 @@ VoiceControlEngineInfo::~VoiceControlEngineInfo() void VoiceControlEngineInfo::printOutEngine() { - SLOG(LOG_DEBUG, TAG_VCCONFIG, " name : %s", __engineName.c_str()); - SLOG(LOG_DEBUG, TAG_VCCONFIG, " id : %s", __engineId.c_str()); - SLOG(LOG_DEBUG, TAG_VCCONFIG, " setting : %s", __settingPath.c_str()); - SLOG(LOG_DEBUG, TAG_VCCONFIG, " default language : %s", __defaultLanguage.c_str()); + SLOG(LOG_DEBUG, TAG_VCCONFIG, " name : %s", mEngineName.c_str()); + SLOG(LOG_DEBUG, TAG_VCCONFIG, " id : %s", mEngineId.c_str()); + SLOG(LOG_DEBUG, TAG_VCCONFIG, " setting : %s", mSettingPath.c_str()); + SLOG(LOG_DEBUG, TAG_VCCONFIG, " default language : %s", mDefaultLanguage.c_str()); SLOG(LOG_DEBUG, TAG_VCCONFIG, " languages :"); - if (__supportedLanguages.size() == 0) { + if (mSupportedLanguages.size() == 0) { SLOG(LOG_DEBUG, TAG_VCCONFIG, " language is NONE"); } else { unsigned int index = 1; - for (auto &language : __supportedLanguages) { + for (auto &language : mSupportedLanguages) { SLOG(LOG_DEBUG, TAG_VCCONFIG, " [%uth] %s", index, language.c_str()); index++; } @@ -85,7 +85,7 @@ void VoiceControlEngineInfo::printOutEngine() bool VoiceControlEngineInfo::isLanguageValid(const std::string language) { - for (auto &supportedLanguage : __supportedLanguages) { + for (auto &supportedLanguage : mSupportedLanguages) { SLOG(LOG_DEBUG, TAG_VCCONFIG, "Compare language(%s), Target(%s)", supportedLanguage.c_str(), language.c_str()); if (0 == supportedLanguage.compare(language)) { SLOG(LOG_INFO, TAG_VCCONFIG, "Language(%s) is valid", language.c_str()); @@ -99,31 +99,31 @@ bool VoiceControlEngineInfo::isLanguageValid(const std::string language) std::string VoiceControlEngineInfo::getEngineName() { - return __engineName; + return mEngineName; } std::string VoiceControlEngineInfo::getEngineId() { - return __engineId; + return mEngineId; } std::string VoiceControlEngineInfo::getSettingPath() { - return __settingPath; + return mSettingPath; } std::string VoiceControlEngineInfo::getDefaultLanguage() { - return __defaultLanguage; + return mDefaultLanguage; } std::vector VoiceControlEngineInfo::getSupportedLanguages() { - return __supportedLanguages; + return mSupportedLanguages; } bool VoiceControlEngineInfo::isNonFixedSupported() { - return __nonFixedSupported; + return mNonFixedSupported; } diff --git a/common/VoiceControlEngineInfo.h b/common/VoiceControlEngineInfo.h index 910af97..6c899d2 100644 --- a/common/VoiceControlEngineInfo.h +++ b/common/VoiceControlEngineInfo.h @@ -37,12 +37,12 @@ public: bool isNonFixedSupported(); private: - std::string __engineName; - std::string __engineId; - std::string __settingPath; - std::string __defaultLanguage; - std::vector __supportedLanguages; - bool __nonFixedSupported; + std::string mEngineName; + std::string mEngineId; + std::string mSettingPath; + std::string mDefaultLanguage; + std::vector mSupportedLanguages; + bool mNonFixedSupported; }; diff --git a/common/VoiceControlEngines.cpp b/common/VoiceControlEngines.cpp index 47a3251..e30a1a8 100644 --- a/common/VoiceControlEngines.cpp +++ b/common/VoiceControlEngines.cpp @@ -30,14 +30,14 @@ VoiceControlEngines::~VoiceControlEngines() void VoiceControlEngines::printOutEngineInfo() { - unique_lock lock(__enginesMutex); + unique_lock lock(mEnginesMutex); SLOG(LOG_DEBUG, TAG_VCCONFIG, "@ Engine list @"); - if (0 == __engines.size()) { + if (0 == mEngines.size()) { SLOG(LOG_DEBUG, TAG_VCCONFIG, " No Engine in engine directory"); } else { unsigned int index = 0; - for (auto &engineInfo : __engines) { + for (auto &engineInfo : mEngines) { SLOG(LOG_DEBUG, TAG_VCCONFIG, "[%uth]", index); engineInfo.printOutEngine(); } @@ -48,11 +48,11 @@ void VoiceControlEngines::printOutEngineInfo() void VoiceControlEngines::appendEngine(const std::string path) { - unique_lock lock(__enginesMutex); + unique_lock lock(mEnginesMutex); try { VoiceControlEngineInfo engineInfo(path); - __engines.push_back(engineInfo); + mEngines.push_back(engineInfo); } catch (runtime_error &error) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] Fail to append engine info from path(%s)", path.c_str()); throw error; @@ -66,7 +66,7 @@ bool VoiceControlEngines::isEngineIdValid(const std::string engineId) return false; } - unique_lock lock(__enginesMutex); + unique_lock lock(mEnginesMutex); bool isValid = (nullptr != findEngine(engineId)); SLOG(LOG_INFO, TAG_VCCONFIG, "Engine Id(%s) is %svalid", engineId.c_str(), (isValid ? "" : "not ")); return isValid; @@ -79,7 +79,7 @@ std::shared_ptr VoiceControlEngines::getEngineInfo(const return nullptr; } - unique_lock lock(__enginesMutex); + unique_lock lock(mEnginesMutex); SLOG(LOG_INFO, TAG_VCCONFIG, "Get engine info with ID(%s)", engineId.c_str()); auto engineInfo = findEngine(engineId); if (engineInfo == nullptr) { @@ -92,14 +92,14 @@ std::shared_ptr VoiceControlEngines::getEngineInfo(const std::shared_ptr VoiceControlEngines::getFirstEngineInfo() { - unique_lock lock(__enginesMutex); - if (__engines.size() == 0) { + unique_lock lock(mEnginesMutex); + if (mEngines.size() == 0) { SLOG(LOG_ERROR, TAG_VCCONFIG, "[ERROR] There is no engine"); return nullptr; } - SLOG(LOG_INFO, TAG_VCCONFIG, "Get first engine info. size(%zu)", __engines.size()); - return make_shared(__engines[0]); + SLOG(LOG_INFO, TAG_VCCONFIG, "Get first engine info. size(%zu)", mEngines.size()); + return make_shared(mEngines[0]); } VoiceControlEngineInfo *VoiceControlEngines::findEngine(const std::string engineId) @@ -110,7 +110,7 @@ VoiceControlEngineInfo *VoiceControlEngines::findEngine(const std::string engine } SLOG(LOG_INFO, TAG_VCCONFIG, "Find engine ID (%s)", engineId.c_str()); - for (auto &engineInfo : __engines) { + for (auto &engineInfo : mEngines) { if (0 == engineInfo.getEngineId().compare(engineId)) { SLOG(LOG_INFO, TAG_VCCONFIG, "Success to find engine (%s)", engineId.c_str()); return &engineInfo; @@ -123,15 +123,15 @@ VoiceControlEngineInfo *VoiceControlEngines::findEngine(const std::string engine std::vector VoiceControlEngines::getEngines() { - unique_lock lock(__enginesMutex); - SLOG(LOG_INFO, TAG_VCCONFIG, "Get engines. size(%zu)", __engines.size()); - return __engines; + unique_lock lock(mEnginesMutex); + SLOG(LOG_INFO, TAG_VCCONFIG, "Get engines. size(%zu)", mEngines.size()); + return mEngines; } bool VoiceControlEngines::isEngineEmpty() { - unique_lock lock(__enginesMutex); - SLOG(LOG_INFO, TAG_VCCONFIG, "Length of engines (%zu)", __engines.size()); - return __engines.empty(); + unique_lock lock(mEnginesMutex); + SLOG(LOG_INFO, TAG_VCCONFIG, "Length of engines (%zu)", mEngines.size()); + return mEngines.empty(); } diff --git a/common/VoiceControlEngines.h b/common/VoiceControlEngines.h index ae436a5..9848900 100644 --- a/common/VoiceControlEngines.h +++ b/common/VoiceControlEngines.h @@ -40,8 +40,8 @@ public: private: VoiceControlEngineInfo *findEngine(const std::string engineId); - std::vector __engines; - std::mutex __enginesMutex; + std::vector mEngines; + std::mutex mEnginesMutex; }; diff --git a/common/vc_config_mgr.cpp b/common/vc_config_mgr.cpp index 2ee8af5..23a1fd1 100644 --- a/common/vc_config_mgr.cpp +++ b/common/vc_config_mgr.cpp @@ -74,11 +74,11 @@ static int g_wd_lang = -1; static GList* g_ino_list = nullptr; static mutex g_ino_list_mutex; -static int __vc_config_mgr_register_engine_config_updated_event(const char* path); -static int __vc_config_mgr_unregister_engine_config_updated_event(); -static int __vc_config_mgr_set_default_language(const char* language); +static int register_engine_config_updated_event(const char* path); +static int unregister_engine_config_updated_event(); +static int set_current_language(const char* language); -static void __vc_config_mgr_notify_engine_changed(const char *engine_appid) +static void notify_engine_changed(const char *engine_appid) { SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke engine changed callback"); if (nullptr == engine_appid) { @@ -97,7 +97,7 @@ static void __vc_config_mgr_notify_engine_changed(const char *engine_appid) } } -static void __vc_config_mgr_notify_language_changed(const char* before_lang, const char* current_lang) +static void notify_language_changed(const char* before_lang, const char* current_lang) { SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke language changed callback"); if (nullptr == before_lang || nullptr == current_lang) { @@ -116,7 +116,7 @@ static void __vc_config_mgr_notify_language_changed(const char* before_lang, con } } -static void __vc_config_mgr_notify_enabled_changed(bool enable) +static void notify_enabled_changed(bool enable) { SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke enabled callback"); auto clients = g_VoiceControlClients->getClients(); @@ -130,7 +130,7 @@ static void __vc_config_mgr_notify_enabled_changed(bool enable) } } -static int __initialize_config_info() +static int initialize_config_info() { g_VoiceControlConfig = new(nothrow) VoiceControlConfig(); if (nullptr == g_VoiceControlConfig) { @@ -141,7 +141,7 @@ static int __initialize_config_info() return VC_CONFIG_ERROR_NONE; } -static void __finalize_config_info() +static void finalize_config_info() { delete g_VoiceControlConfig; g_VoiceControlConfig = nullptr; @@ -161,7 +161,7 @@ int vc_config_convert_error_code(vc_config_error_e code) return VC_CONFIG_ERROR_NONE; } -static int __vc_config_mgr_check_and_set_default_engine_id(const char* engine_id) +static int check_and_set_default_engine_id(const char* engine_id) { if (NULL == engine_id) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Input parameter is NULL"); @@ -190,7 +190,7 @@ static int __vc_config_mgr_check_and_set_default_engine_id(const char* engine_id return VC_CONFIG_ERROR_NONE; } -static bool __vc_config_mgr_check_lang_is_valid(const char* engine_id, const char* language) +static bool is_language_valid_in_engine(const char* engine_id, const char* language) { if (NULL == engine_id || NULL == language) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Input parameter is NULL"); @@ -209,7 +209,7 @@ static bool __vc_config_mgr_check_lang_is_valid(const char* engine_id, const cha return is_language_valid; } -static int __vc_config_mgr_select_lang(const char* engine_id, char** language) +static int get_default_language_of_engine(const char* engine_id, char** language) { if (NULL == engine_id || NULL == language) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Input parameter is NULL"); @@ -242,13 +242,13 @@ static int __vc_config_mgr_select_lang(const char* engine_id, char** language) return VC_CONFIG_ERROR_NONE; } -void __vc_config_release_engine() +static void release_engines_information() { delete g_VoiceControlEngines; g_VoiceControlEngines = nullptr; } -static int __vc_config_mgr_get_engine_info() +static int load_engines_information() { DIR *dp = NULL; struct dirent *dirp = NULL; @@ -258,7 +258,7 @@ static int __vc_config_mgr_get_engine_info() SLOG(LOG_DEBUG, vc_config_tag(), "[CONFIG] Release engine and Unregister engine config"); - __vc_config_release_engine(); + release_engines_information(); g_VoiceControlEngines = new(nothrow) VoiceControlEngines(); if (g_VoiceControlEngines == nullptr) { @@ -266,7 +266,7 @@ static int __vc_config_mgr_get_engine_info() return VC_CONFIG_ERROR_OUT_OF_MEMORY; } - __vc_config_mgr_unregister_engine_config_updated_event(); + unregister_engine_config_updated_event(); SLOG(LOG_DEBUG, vc_config_tag(), "[CONFIG] default directory : %s", VC_DEFAULT_ENGINE_INFO); @@ -334,7 +334,7 @@ static int __vc_config_mgr_get_engine_info() try { g_VoiceControlEngines->appendEngine(filepath); - if (0 != __vc_config_mgr_register_engine_config_updated_event(filepath)) { + if (0 != register_engine_config_updated_event(filepath)) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to register engine config updated event"); } } catch (exception &error) { @@ -354,7 +354,7 @@ static int __vc_config_mgr_get_engine_info() return VC_CONFIG_ERROR_NONE; } -static Eina_Bool __vc_config_mgr_engine_config_inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler) +static Eina_Bool engine_config_inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler) { SLOG(LOG_DEBUG, vc_config_tag(), "@@@ Engine config updated callback event"); ecore_thread_main_loop_begin(); @@ -375,7 +375,7 @@ static Eina_Bool __vc_config_mgr_engine_config_inotify_event_callback(void* data } if (IN_CLOSE_WRITE == event.mask) { - int ret = __vc_config_mgr_get_engine_info(); + int ret = load_engines_information(); if (0 != ret) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to get engine info when config updated"); } @@ -387,13 +387,13 @@ static Eina_Bool __vc_config_mgr_engine_config_inotify_event_callback(void* data SLOG(LOG_DEBUG, vc_config_tag(), "[ERROR] Default language is not valid"); char* temp_lang = NULL; string default_engine_id = g_VoiceControlConfig->getEngineId(); - ret = __vc_config_mgr_select_lang(default_engine_id.c_str(), &temp_lang); + ret = get_default_language_of_engine(default_engine_id.c_str(), &temp_lang); if (0 != ret) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to get language"); } - ret = __vc_config_mgr_set_default_language(temp_lang); + ret = set_current_language(temp_lang); if (0 != ret) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to set language"); } else { @@ -414,7 +414,7 @@ static Eina_Bool __vc_config_mgr_engine_config_inotify_event_callback(void* data return ECORE_CALLBACK_PASS_ON; } -static int __vc_config_mgr_register_engine_config_updated_event(const char* path) +static int register_engine_config_updated_event(const char* path) { if (NULL == path) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Path is NULL"); @@ -446,7 +446,7 @@ static int __vc_config_mgr_register_engine_config_updated_event(const char* path return VC_CONFIG_ERROR_OPERATION_FAILED; } - ino->dir_fd_handler = ecore_main_fd_handler_add(ino->dir_fd, ECORE_FD_READ, (Ecore_Fd_Cb)__vc_config_mgr_engine_config_inotify_event_callback, (void *)ino, NULL, NULL); + ino->dir_fd_handler = ecore_main_fd_handler_add(ino->dir_fd, ECORE_FD_READ, (Ecore_Fd_Cb)engine_config_inotify_event_callback, (void *)ino, NULL, NULL); if (NULL == ino->dir_fd_handler) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to add fd handler"); free(ino); @@ -469,7 +469,7 @@ static int __vc_config_mgr_register_engine_config_updated_event(const char* path return VC_CONFIG_ERROR_NONE; } -static int __vc_config_mgr_unregister_engine_config_updated_event() +static int unregister_engine_config_updated_event() { unique_lock lock(g_ino_list_mutex); @@ -497,7 +497,7 @@ static int __vc_config_mgr_unregister_engine_config_updated_event() return VC_CONFIG_ERROR_NONE; } -static Eina_Bool __vc_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handler) +static Eina_Bool language_config_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handler) { SLOG(LOG_DEBUG, vc_config_tag(), "@@@ Config changed callback event"); @@ -537,7 +537,7 @@ static Eina_Bool __vc_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler * g_VoiceControlConfig->setCurrentLanguage(lang); /* Call all callbacks of client*/ - __vc_config_mgr_notify_language_changed(before_lang.c_str(), lang); + notify_language_changed(before_lang.c_str(), lang); free(lang); lang = NULL; @@ -548,7 +548,7 @@ static Eina_Bool __vc_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler * g_VoiceControlConfig->setEngineId(engine); /* Call all callbacks of client*/ - __vc_config_mgr_notify_engine_changed(engine); + notify_engine_changed(engine); free(engine); engine = NULL; } @@ -557,7 +557,7 @@ static Eina_Bool __vc_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler * g_VoiceControlConfig->setEnabled((bool)enabled); /* Call all callbacks of client*/ - __vc_config_mgr_notify_enabled_changed((bool)enabled); + notify_enabled_changed((bool)enabled); } } else { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Undefined event"); @@ -568,7 +568,7 @@ static Eina_Bool __vc_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler * return ECORE_CALLBACK_PASS_ON; } -int __vc_config_set_auto_language() +static int set_language_by_automatic_selection() { char candidate_lang[6] = {'\0', }; char* value = NULL; @@ -592,7 +592,7 @@ int __vc_config_set_auto_language() } string default_engine_id = g_VoiceControlConfig->getEngineId(); - if (true == __vc_config_mgr_check_lang_is_valid(default_engine_id.c_str(), candidate_lang)) { + if (true == is_language_valid_in_engine(default_engine_id.c_str(), candidate_lang)) { /* vc default language change */ string before_language = g_VoiceControlConfig->getCurrentLanguage(); if (0 != vc_parser_set_language(candidate_lang)) { @@ -605,11 +605,11 @@ int __vc_config_set_auto_language() before_language.c_str(), candidate_lang); /* Call all callbacks of client*/ - __vc_config_mgr_notify_language_changed(before_language.c_str(), candidate_lang); + notify_language_changed(before_language.c_str(), candidate_lang); } else { /* Candidate language is not valid */ char* tmp_language = NULL; - if (0 != __vc_config_mgr_select_lang(default_engine_id.c_str(), &tmp_language)) { + if (0 != get_default_language_of_engine(default_engine_id.c_str(), &tmp_language)) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to select language"); return VC_CONFIG_ERROR_OPERATION_FAILED; } @@ -631,22 +631,22 @@ int __vc_config_set_auto_language() before_language.c_str(), tmp_language); /* Call all callbacks of client*/ - __vc_config_mgr_notify_language_changed(before_language.c_str(), tmp_language); + notify_language_changed(before_language.c_str(), tmp_language); free(tmp_language); } return VC_CONFIG_ERROR_NONE; } -static void __vc_config_language_changed_cb(keynode_t *key, void *data) +static void language_changed_cb(keynode_t *key, void *data) { if (g_VoiceControlConfig->isAutoLanguageEnabled()) { /* Get voice input vconf key */ - __vc_config_set_auto_language(); + set_language_by_automatic_selection(); } } -static int __initialize_vc_config_mgr() +static int initialize_vc_config_mgr() { if (g_config_mgr_initialized.load()) { SLOG(LOG_DEBUG, vc_config_tag(), "Config mgr module is already initialized"); @@ -688,40 +688,40 @@ static int __initialize_vc_config_mgr() } } - if (0 != __vc_config_mgr_get_engine_info()) { + if (0 != load_engines_information()) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to get engine info"); - __vc_config_release_engine(); + release_engines_information(); return VC_CONFIG_ERROR_ENGINE_NOT_FOUND; } g_VoiceControlEngines->printOutEngineInfo(); - if (0 != __initialize_config_info()) { + if (0 != initialize_config_info()) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to parse configure information"); - __vc_config_release_engine(); + release_engines_information(); return VC_CONFIG_ERROR_OPERATION_FAILED; } string default_engine_id = g_VoiceControlConfig->getEngineId(); - if (0 != __vc_config_mgr_check_and_set_default_engine_id(default_engine_id.c_str())) { + if (0 != check_and_set_default_engine_id(default_engine_id.c_str())) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to set default engine"); - __vc_config_release_engine(); - __finalize_config_info(); + release_engines_information(); + finalize_config_info(); return VC_CONFIG_ERROR_ENGINE_NOT_FOUND; } if (g_VoiceControlConfig->isAutoLanguageEnabled()) { /* Check language with display language */ - __vc_config_set_auto_language(); + set_language_by_automatic_selection(); } else { string default_language = g_VoiceControlConfig->getCurrentLanguage(); - if (false == __vc_config_mgr_check_lang_is_valid(default_engine_id.c_str(), default_language.c_str())) { + if (false == is_language_valid_in_engine(default_engine_id.c_str(), default_language.c_str())) { /* Default language is not valid */ char* tmp_language; - if (0 != __vc_config_mgr_select_lang(default_engine_id.c_str(), &tmp_language)) { + if (0 != get_default_language_of_engine(default_engine_id.c_str(), &tmp_language)) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to select language"); - __vc_config_release_engine(); - __finalize_config_info(); + release_engines_information(); + finalize_config_info(); return VC_CONFIG_ERROR_OPERATION_FAILED; } @@ -730,8 +730,8 @@ static int __initialize_vc_config_mgr() if (0 != vc_parser_set_language(tmp_language)) { free(tmp_language); SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config"); - __vc_config_release_engine(); - __finalize_config_info(); + release_engines_information(); + finalize_config_info(); return VC_CONFIG_ERROR_OPERATION_FAILED; } @@ -748,7 +748,7 @@ static int __initialize_vc_config_mgr() g_lang_ref_count = 0; /* Register to detect display language change */ - vconf_notify_key_changed(VCONFKEY_LANGSET, __vc_config_language_changed_cb, nullptr); + vconf_notify_key_changed(VCONFKEY_LANGSET, language_changed_cb, nullptr); g_config_mgr_initialized = true; return VC_CONFIG_ERROR_NONE; @@ -759,7 +759,7 @@ int vc_config_mgr_initialize(unsigned int uid) SLOG(LOG_INFO, vc_config_tag(), "[WARNING] Enter critical section"); ecore_thread_main_loop_begin(); - int ret = __initialize_vc_config_mgr(); + int ret = initialize_vc_config_mgr(); if (VC_CONFIG_ERROR_NONE != ret) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to initialize vc_config_mgr"); ecore_thread_main_loop_end(); @@ -803,12 +803,12 @@ int vc_config_mgr_finalize(unsigned int uid) delete g_VoiceControlClients; g_VoiceControlClients = nullptr; - __vc_config_release_engine(); + release_engines_information(); - __vc_config_mgr_unregister_engine_config_updated_event(); + unregister_engine_config_updated_event(); - vconf_ignore_key_changed(VCONFKEY_LANGSET, __vc_config_language_changed_cb); - __finalize_config_info(); + vconf_ignore_key_changed(VCONFKEY_LANGSET, language_changed_cb); + finalize_config_info(); SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); @@ -818,7 +818,7 @@ int vc_config_mgr_finalize(unsigned int uid) } -static int __vc_config_mgr_register_lang_event() +static int register_language_config_changed_event() { if (0 == g_lang_ref_count) { /* get file notification handler */ @@ -835,7 +835,7 @@ static int __vc_config_mgr_register_lang_event() wd = inotify_add_watch(fd, VC_CONFIG, IN_CLOSE_WRITE); g_wd_lang = wd; - g_fd_handler_lang = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)__vc_config_mgr_inotify_event_cb, NULL, NULL, NULL); + g_fd_handler_lang = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)language_config_inotify_event_cb, NULL, NULL, NULL); if (NULL == g_fd_handler_lang) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to get handler_noti"); return VC_CONFIG_ERROR_OPERATION_FAILED; @@ -855,7 +855,7 @@ static int __vc_config_mgr_register_lang_event() return VC_CONFIG_ERROR_NONE; } -static int __vc_config_mgr_unregister_config_event() +static int unregister_language_config_event() { if (0 == g_lang_ref_count) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Lang ref count is 0"); @@ -871,7 +871,7 @@ static int __vc_config_mgr_unregister_config_event() g_fd_handler_lang = NULL; g_fd_lang = -1; - vconf_ignore_key_changed(VCONFKEY_LANGSET, __vc_config_language_changed_cb); + vconf_ignore_key_changed(VCONFKEY_LANGSET, language_changed_cb); } return VC_CONFIG_ERROR_NONE; @@ -893,7 +893,7 @@ int vc_config_mgr_set_engine_cb(unsigned int uid, vc_config_engine_changed_cb en g_VoiceControlClients->setEngineChangedCallback(uid, engine_cb); - if (VC_CONFIG_ERROR_NONE != __vc_config_mgr_register_lang_event()) { + if (VC_CONFIG_ERROR_NONE != register_language_config_changed_event()) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to register config event"); ecore_thread_main_loop_end(); return VC_CONFIG_ERROR_OPERATION_FAILED; @@ -914,7 +914,7 @@ int vc_config_mgr_unset_engine_cb(unsigned int uid) g_VoiceControlClients->setEngineChangedCallback(uid, nullptr); - __vc_config_mgr_unregister_config_event(); + unregister_language_config_event(); ecore_thread_main_loop_end(); return VC_CONFIG_ERROR_NONE; @@ -1011,7 +1011,7 @@ int vc_config_mgr_set_auto_language(bool value) g_VoiceControlConfig->setAutoLanguageEnabled(value); if (true == value) { - __vc_config_set_auto_language(); + set_language_by_automatic_selection(); } } @@ -1075,7 +1075,7 @@ int vc_config_mgr_get_engine(char** engine) return VC_CONFIG_ERROR_NONE; } -static int __vc_config_set_buxtonkey(const char* engine) +static int set_default_engine_id_on_buxtonkey(const char* engine) { /* Set vconfkey */ struct buxton_client * bux_cli; @@ -1150,7 +1150,7 @@ int vc_config_mgr_set_engine(const char* engine) SLOG(LOG_DEBUG, vc_config_tag(), "New engine id : %s", engine); - int ret = __vc_config_set_buxtonkey(engine); + int ret = set_default_engine_id_on_buxtonkey(engine); if (0 != ret) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] set buxtonkey Failed!!!"); return ret; @@ -1246,7 +1246,7 @@ int vc_config_mgr_get_default_language(char** language) return VC_CONFIG_ERROR_NONE; } -static int __vc_config_mgr_set_default_language(const char* language) +static int set_current_language(const char* language) { if (g_config_mgr_initialized.load() == false) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); @@ -1275,7 +1275,7 @@ static int __vc_config_mgr_set_default_language(const char* language) int vc_config_mgr_set_default_language(const char* language) { - int ret = __vc_config_mgr_set_default_language(language); + int ret = set_current_language(language); return ret; } diff --git a/server/vcd_server_data.cpp b/server/vcd_server_data.cpp index 579928a..b57c97d 100644 --- a/server/vcd_server_data.cpp +++ b/server/vcd_server_data.cpp @@ -33,7 +33,7 @@ std::list g_tts_text_data; static pthread_mutex_t g_tts_text_data_mutex = PTHREAD_MUTEX_INITIALIZER; -static int __data_show_text_list(void) +static int show_text_list(void) { SLOG(LOG_DEBUG, TAG_VCD, "----- Text list -----"); @@ -75,7 +75,7 @@ int vcd_data_add_tts_text_data(vc_tts_text_data_s* data) *iter, (*iter)->uid, (*iter)->pid, (*iter)->utt_id, (*iter)->text, (*iter)->language); #ifdef DATA_DEBUG - __data_show_text_list(); + show_text_list(); #endif pthread_mutex_unlock(&g_tts_text_data_mutex); @@ -136,7 +136,7 @@ int vcd_data_get_tts_text_data(unsigned int tts_uid, vc_tts_text_data_s** data) } #ifdef DATA_DEBUG - __data_show_text_list(); + show_text_list(); #endif pthread_mutex_unlock(&g_tts_text_data_mutex); @@ -149,7 +149,7 @@ int vcd_data_get_first_tts_text_data(vc_tts_text_data_s** data) SLOG(LOG_INFO, TAG_VCD, "[DATA] Get first tts text data"); #ifdef DATA_DEBUG - __data_show_text_list(); + show_text_list(); #endif /* mutex is locked */ -- 2.7.4 From 96d51d6700596c418996e10c3aea36e5ed846d97 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Thu, 9 Mar 2023 10:58:39 +0900 Subject: [PATCH 02/16] Update version to 1.75.0 Change-Id: I32a641064bbce6011c536225ebb92105023a9a7d --- packaging/voice-control.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index e318157..db9e989 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.70.8 +Version: 1.75.0 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 7c7d47a4f9a64b13bbeb5b8a171b92a7765ff531 Mon Sep 17 00:00:00 2001 From: ulgal-park Date: Fri, 10 Mar 2023 19:14:30 +0900 Subject: [PATCH 03/16] Change widget retry count and interval when engine not loaded Change-Id: Ia7b97d900f18dad2bec2d2e08864ba77af5d657d --- client/vc_widget_tidl.c | 2 ++ common/vc_defs.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index 9b6a80b..d6fbbc9 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -417,6 +417,8 @@ int vc_widget_tidl_request_hello() if (!g_proxy_tidl_info->connected) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Proxy Not Connected"); __request_tidl_connect(); + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Engine not loaded, sleep 500ms"); + usleep(500000); return VC_ERROR_OPERATION_FAILED; } diff --git a/common/vc_defs.h b/common/vc_defs.h index d6ad568..e3533bc 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -269,7 +269,7 @@ extern "C" { #define VC_INVALID_TTS_UID 0 #define VC_ENGINE_APPID_LEN 256 #define VCM_TIDL_RETRY_COUNT 200 -#define VC_TIDL_RETRY_COUNT 20 +#define VC_TIDL_RETRY_COUNT 30 #define VC_MGR_DEFAULT_FARFIELD_DUCKING_RATIO 0.0 #define VC_MGR_DEFAULT_NEARFIELD_DUCKING_RATIO 0.7 -- 2.7.4 From 5fb5703670aee7ec524a7f4627a1a79d49fb274c Mon Sep 17 00:00:00 2001 From: ulgal-park Date: Mon, 13 Mar 2023 12:54:05 +0900 Subject: [PATCH 04/16] add guard clause when use g_VoiceControlClients Change-Id: I36d7c0cccd8cee52a6948cbcf3af873e3ae950b9 --- common/vc_config_mgr.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/vc_config_mgr.cpp b/common/vc_config_mgr.cpp index 23a1fd1..e502e7e 100644 --- a/common/vc_config_mgr.cpp +++ b/common/vc_config_mgr.cpp @@ -105,6 +105,11 @@ static void notify_language_changed(const char* before_lang, const char* current return; } + if (nullptr == g_VoiceControlClients) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] No clients exist"); + return; + } + auto clients = g_VoiceControlClients->getClients(); for (auto &clientInfo : clients) { if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { -- 2.7.4 From 21d4d7f5d04f839b0cf97cdb6c5d5701ff92d64b Mon Sep 17 00:00:00 2001 From: ulgal-park Date: Mon, 13 Mar 2023 12:54:48 +0900 Subject: [PATCH 05/16] Update version to 1.75.1 Change-Id: Id348d0e8a8c010910bd274f455133c499906f48b --- packaging/voice-control.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index db9e989..ce6a942 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.75.0 +Version: 1.75.1 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 50c7766f821535255f2c22b79cce0a1774bdf9ff Mon Sep 17 00:00:00 2001 From: sooyeon Date: Tue, 14 Mar 2023 14:50:47 +0900 Subject: [PATCH 06/16] Fix Svace issues by removing unused codes Change-Id: I4b6d194faacd074305ab7a6968c715e94d0994ba Signed-off-by: sooyeon --- client/CMakeLists.txt | 1 - client/vc_mgr.c | 35 +---- client/vc_mgr_player.c | 413 ------------------------------------------------- client/vc_mgr_player.h | 25 --- 4 files changed, 2 insertions(+), 472 deletions(-) delete mode 100644 client/vc_mgr_player.c delete mode 100644 client/vc_mgr_player.h diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 6c62f69..0195eb3 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -56,7 +56,6 @@ SET(MANAGER_SRCS vc_mgr_core.c vc_mgr_client.c vc_mgr_data.cpp - vc_mgr_player.c vc_mgr_tidl.c vc_mgr_proxy.c vc_mgr_stub.c diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 72f264b..2fc2d44 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -32,7 +32,6 @@ #include "vc_mgr_client.h" #include "vc_mgr_tidl.h" #include "vc_mgr_data.h" -#include "vc_mgr_player.h" #include "vc_mgr_ducking.h" #include "voice_control_command.h" #include "voice_control_command_expand.h" @@ -293,13 +292,6 @@ int vc_mgr_initialize(void) return ret; } - /* for TTS feedback */ -/* ret = vc_mgr_player_init(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to initialize VC mgr player : %d", ret); - } -*/ - ret = vc_mgr_ducking_create(); if (VC_ERROR_NONE != ret) { SLOG(LOG_INFO, TAG_VCM, "[INFO] Fail to ducking create : %d", ret); @@ -382,13 +374,6 @@ int vc_mgr_deinitialize(void) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to finalize DB, ret(%d)", ret); } - /* for TTS feedback */ -/* ret = vc_mgr_player_release(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to release VC mgr player(%d)", ret); - } -*/ - ret = vc_mgr_ducking_destroy(); if (VC_ERROR_NONE != ret) { SLOG(LOG_INFO, TAG_VCM, "[INFO] Fail to ducking destroy : %d", ret); @@ -2750,20 +2735,12 @@ int vc_mgr_start_feedback(void) /* check state */ RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Start feedback : Current state is not 'Ready' (%d)", state); -#if 1 bool is_exist = ecore_thread_check(g_feedback_thread); if (NULL == g_feedback_thread || TRUE == is_exist) { SLOG(LOG_INFO, TAG_VCM, "[INFO] ecore thread run : __tts_feedback_thread"); g_feedback_thread = ecore_thread_run(__tts_feedback_thread, __end_tts_feedback_thread, __cancel_tts_feedback_thread, NULL); } -#else - /* start playing TTS feedback */ - int ret = -1; - ret = vc_mgr_player_play(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to player play, ret(%d)", ret); - } -#endif + return VC_ERROR_NONE; } @@ -2787,7 +2764,6 @@ int vc_mgr_stop_feedback(void) /* check state */ RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state); -#if 1 if (g_feedback_thread) { ecore_thread_cancel(g_feedback_thread); g_feedback_thread = NULL; @@ -2810,14 +2786,7 @@ int vc_mgr_stop_feedback(void) break; } } -#else - /* request to stop playing TTS feedback */ - int ret = -1; - ret = vc_mgr_player_stop(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to player stop, ret(%d)", ret); - } -#endif + return ret; } diff --git a/client/vc_mgr_player.c b/client/vc_mgr_player.c deleted file mode 100644 index 5bfd5be..0000000 --- a/client/vc_mgr_player.c +++ /dev/null @@ -1,413 +0,0 @@ -/* -* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include -#include -#include -#include -#include -#include - -#include "vc_main.h" -#include "vc_mgr_player.h" -#include "vc_mgr_data.h" - -typedef enum { - AUDIO_STATE_NONE = 0, - AUDIO_STATE_READY, - AUDIO_STATE_PLAY -} audio_state_e; - -typedef struct { - vc_feedback_state_e state; - - vc_feedback_event_e event; - int idx; -} player_s; - -#define SOUND_BUFFER_LENGTH 2048 - -static bool g_player_init = false; - -static player_s* g_playing_info; - -static audio_state_e g_audio_state; - -static vc_audio_type_e g_audio_type; - -static vc_audio_channel_e g_audio_channel; - -static int g_sampling_rate; - -static audio_out_h g_audio_h; - - -static int __create_audio_out(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type) -{ - int ret = -1; - audio_channel_e sample_channel = 0; - audio_sample_type_e sample_type = 0; - - if (VC_AUDIO_CHANNEL_MONO == channel) { - sample_channel = AUDIO_CHANNEL_MONO; - } else if (VC_AUDIO_CHANNEL_STEREO == channel) { - sample_channel = AUDIO_CHANNEL_STEREO; - } - - if (VC_AUDIO_TYPE_PCM_S16_LE == audio_type) { - sample_type = AUDIO_SAMPLE_TYPE_S16_LE; - } else { - sample_type = AUDIO_SAMPLE_TYPE_U8; - } - - /* create audio_out new */ - ret = audio_out_create_new(rate, sample_channel, sample_type, &g_audio_h); - if (AUDIO_IO_ERROR_NONE != ret) { - g_audio_state = AUDIO_STATE_NONE; - g_audio_h = NULL; - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio. ret(%d)", ret); - return -1; - } else { - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Create audio"); - } - - g_audio_channel = channel; - g_audio_type = audio_type; - g_sampling_rate = rate; - - g_audio_state = AUDIO_STATE_READY; - - return 0; -} - -static int __destroy_audio_out() -{ - if (NULL == g_audio_h) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Current handle is not valid"); - return -1; - } - - int ret = -1; - ret = audio_out_destroy(g_audio_h); - if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to destroy audio. ret(%d)", ret); - return -1; - } else { - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Destroy audio"); - } - - g_audio_channel = 0; - g_audio_type = 0; - g_sampling_rate = 0; - - g_audio_state = AUDIO_STATE_NONE; - g_audio_h = NULL; - - return 0; -} - -int vc_mgr_player_init(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type) -{ - g_audio_state = AUDIO_STATE_NONE; - g_audio_h = NULL; - - ecore_thread_max_set(1); - - int ret = -1; - - - ret = __create_audio_out(rate, channel, audio_type); - if (0 != ret) { - return VC_ERROR_OPERATION_FAILED; - } - - g_player_init = true; - - return VC_ERROR_NONE; -} - -int vc_mgr_player_release() -{ - if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Not initialized"); - return VC_ERROR_OPERATION_FAILED; - } - - int ret = -1; - - int thread_count = ecore_thread_active_get(); - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Active thread count : %d", thread_count); - int count = 0; - while (0 < thread_count) { - usleep(10000); - - count++; - if (20 == count) { - SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Thread is blocked. Player release continue"); - break; - } - - thread_count = ecore_thread_active_get(); - } - - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Thread is release"); - - ret = __destroy_audio_out(); - if (0 != ret) { - return VC_ERROR_OPERATION_FAILED; - } - - g_player_init = false; - - return VC_ERROR_NONE; -} - -static void __play_feedback_thread(void* data, Ecore_Thread* thread) -{ - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Start thread"); - - if (NULL == g_playing_info) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] No current player"); - return; - } - - player_s* player = g_playing_info; - vc_feedback_data_s* feedback_data = NULL; - - int ret = -1; - int len = SOUND_BUFFER_LENGTH; - int idx = 0; - - while (1) { - /* get feedback data */ - ret = vc_mgr_data_get_feedback_data(&feedback_data); - if (0 != ret || NULL == feedback_data) { - /* empty queue */ - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] No feedback data. Waiting mode"); - - /* waiting */ - while (1) { - usleep(10000); - if (0 < vc_mgr_data_get_feedback_data_size()) { - SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Resume thread"); - break; - } - - if (AUDIO_STATE_PLAY == g_audio_state) { - /* release audio & recover session */ - ret = audio_out_unprepare(g_audio_h); - if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio"); - } else { - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Unprepare audio"); - } - g_audio_state = AUDIO_STATE_READY; - } - } - - SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Finish to wait for new feedback data come"); - - /* resume play thread */ - player->state = VC_FEEDBACK_STATE_PLAYING; - continue; - } - - if (VC_FEEDBACK_EVENT_START == feedback_data->event || - (VC_FEEDBACK_EVENT_FINISH == player->event && VC_FEEDBACK_EVENT_FINISH == feedback_data->event)) { - int pid = vc_mgr_data_get_pid(); - SLOG(LOG_INFO, TAG_VCM, "[Player DEBUG] Start utterance (%d)", pid); - } - - player->event = feedback_data->event; - idx = 0; - /* If no feedback data and EVENT_FINISH */ - if (NULL == feedback_data->data || 0 >= feedback_data->data_size) { - if (VC_FEEDBACK_EVENT_FINISH == feedback_data->event) { - int pid = vc_mgr_data_get_pid(); - if (pid <= 0) { - return; - } - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] No sound data"); - } - SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Finish utterance"); - vc_mgr_data_clear_feedback_data(&feedback_data); - continue; - } - - if (g_sampling_rate != feedback_data->rate || g_audio_type != feedback_data->audio_type || g_audio_channel != feedback_data->channel) { - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] change audio handle"); - if (NULL != g_audio_h) { - __destroy_audio_out(); - } - - if (0 > __create_audio_out(feedback_data->rate, feedback_data->channel, feedback_data->audio_type)) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio out"); - vc_mgr_data_clear_feedback_data(&feedback_data); - - return; - } - } - - while (VC_FEEDBACK_STATE_PLAYING == player->state) { - if ((unsigned int)idx >= feedback_data->data_size) - break; - - if ((unsigned int)idx + SOUND_BUFFER_LENGTH > feedback_data->data_size) { - len = feedback_data->data_size - idx; - } else { - len = SOUND_BUFFER_LENGTH; - } - - if (AUDIO_STATE_READY == g_audio_state) { - /* request prepare */ - ret = audio_out_prepare(g_audio_h); - if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to prepare audio"); - vc_mgr_data_clear_feedback_data(&feedback_data); - return; - } - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Prepare audio"); - g_audio_state = AUDIO_STATE_PLAY; - } - - char* temp_data = feedback_data->data; - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] data(%p), idx(%d), len(%d)", temp_data, idx, len); - - ret = audio_out_write(g_audio_h, &temp_data[idx], len); - if (0 > ret) { - SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Fail to audio write - %d", ret); - } else { - idx += len; - } - - if (NULL == g_playing_info) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Current player is NULL"); - g_audio_state = AUDIO_STATE_READY; - ret = audio_out_unprepare(g_audio_h); - if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio"); - } - - vc_mgr_data_clear_feedback_data(&feedback_data); - - return; - } - } - - if (NULL == g_playing_info && VC_FEEDBACK_STATE_READY == player->state) { - /* player stop */ - g_audio_state = AUDIO_STATE_READY; - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Stop play thread"); - - /* request to unprepare audio */ - ret = audio_out_unprepare(g_audio_h); - if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio"); - } else { - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Unprepare audio"); - } - - vc_mgr_data_clear_feedback_data(&feedback_data); - return; - } - - if ((VC_FEEDBACK_STATE_PLAYING == player->state) && (VC_FEEDBACK_EVENT_FINISH == feedback_data->event)) { - int pid = vc_mgr_data_get_pid(); - if (pid <= 0) { - return; - } - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Finish utterance"); - } - - vc_mgr_data_clear_feedback_data(&feedback_data); - - if (NULL == g_playing_info) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Current player is NULL"); - g_audio_state = AUDIO_STATE_READY; - ret = audio_out_unprepare(g_audio_h); - if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio"); - } - - return; - } - - } - -} - -static void __end_play_feedback_thread(void* data, Ecore_Thread* thread) -{ - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] End thread"); -} - -int vc_mgr_player_play() -{ - if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Not initialized"); - return VC_ERROR_OPERATION_FAILED; - } - - if (NULL != g_playing_info) { - SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Stop old player"); - vc_mgr_player_stop(); - } - - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] start play"); - - /* check sound queue size */ - int data_size = vc_mgr_data_get_feedback_data_size(); - if (0 == data_size) { - SLOG(LOG_WARN, TAG_VCM, "[Player WARN] A sound queue of current player is empty"); - } else if (0 < data_size) { - SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Run thread"); - ecore_thread_run(__play_feedback_thread, __end_play_feedback_thread, NULL, NULL); - } - - return VC_ERROR_NONE; -} - -int vc_mgr_player_stop() -{ - if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Not initialized"); - return VC_ERROR_OPERATION_FAILED; - } - - if (NULL != g_playing_info) { - g_playing_info = NULL; - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] No more current playing"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] stop play"); - - int thread_count = ecore_thread_active_get(); - int count = 0; - - while (0 < thread_count) { - usleep(10000); - - count++; - if (30 == count) { - SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Thread is blocked. Player release continue"); - break; - } - - thread_count = ecore_thread_active_get(); - } - - return VC_ERROR_NONE; -} diff --git a/client/vc_mgr_player.h b/client/vc_mgr_player.h deleted file mode 100644 index 6cf550c..0000000 --- a/client/vc_mgr_player.h +++ /dev/null @@ -1,25 +0,0 @@ - -#ifndef __VC_MGR_PLAYER_H__ -#define __VC_MGR_PLAYER_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int vc_mgr_player_init(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type); - -int vc_mgr_player_release(); - -int vc_mgr_player_play(); - -int vc_mgr_player_stop(); - - -#ifdef __cplusplus -} -#endif - -#endif /* __VC_MGR_PLAYER_H__ */ -- 2.7.4 From 346d4ee111f2b2c517a46858a9b0a5604275c743 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Tue, 14 Mar 2023 15:06:56 +0900 Subject: [PATCH 07/16] Update version (1.75.2) Change-Id: I6ab67a569f0ebf740037bb74aaf6d1075fd3a9f0 Signed-off-by: sooyeon --- packaging/voice-control.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index ce6a942..d10e747 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.75.1 +Version: 1.75.2 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From b6945fa0b3451bf8fc9f3132b2d9ae19d14e5ebb Mon Sep 17 00:00:00 2001 From: ulgal-park Date: Tue, 14 Mar 2023 21:19:13 +0900 Subject: [PATCH 08/16] add guard clause when use tidl info Change-Id: If1b530d30def44840a7f56238bab420bcc65f5fd --- client/vc_mgr_tidl.c | 6 ++++++ client/vc_widget_tidl.c | 6 ++++++ server/vcd_tidl.c | 15 +++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index 4d1937c..a4cec35 100644 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -277,6 +277,8 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_ static void __on_connected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data) { + RETM_IF(NULL == g_proxy_tidl_info, TAG_VCM, "[ERROR] Fail to get tidl info"); + g_proxy_tidl_info->connected = true; g_proxy_tidl_info->connection_requesting = false; g_proxy_tidl_info->register_callback_invoked = false; @@ -286,6 +288,8 @@ static void __on_connected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_da static void __on_disconnected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data) { + RETM_IF(NULL == g_proxy_tidl_info, TAG_VCM, "[ERROR] Fail to get tidl info"); + g_proxy_tidl_info->connected = false; g_proxy_tidl_info->connection_requesting = false; g_proxy_tidl_info->register_callback_invoked = false; @@ -297,6 +301,8 @@ static void __on_disconnected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user static void __on_rejected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data) { + RETM_IF(NULL == g_proxy_tidl_info, TAG_VCM, "[ERROR] Fail to get tidl info"); + g_proxy_tidl_info->connection_requesting = false; g_proxy_tidl_info->register_callback_invoked = false; diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index d6fbbc9..b099088 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -144,6 +144,8 @@ static void __notify_cb(void *user_data, bundle *msg) static void __on_connected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data) { + RETM_IF(NULL == g_proxy_tidl_info, TAG_VCW, "[ERROR] Fail to get tidl info"); + g_proxy_tidl_info->connected = true; g_proxy_tidl_info->connection_requesting = false; g_proxy_tidl_info->register_callback_invoked = false; @@ -153,6 +155,8 @@ static void __on_connected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *u static void __on_disconnected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data) { + RETM_IF(NULL == g_proxy_tidl_info, TAG_VCW, "[ERROR] Fail to get tidl info"); + g_proxy_tidl_info->connected = false; g_proxy_tidl_info->connection_requesting = false; g_proxy_tidl_info->register_callback_invoked = false; @@ -164,6 +168,8 @@ static void __on_disconnected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void static void __on_rejected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data) { + RETM_IF(NULL == g_proxy_tidl_info, TAG_VCW, "[ERROR] Fail to get tidl info"); + g_proxy_tidl_info->connection_requesting = false; g_proxy_tidl_info->register_callback_invoked = false; diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 0940cd0..bef79d8 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -1378,6 +1378,11 @@ static void __widget_on_connected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h int pid = (intptr_t)user_data; widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); + if (NULL == widget_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + return; + } + widget_tidl_info->connected = true; widget_tidl_info->connection_requesting = false; @@ -1389,6 +1394,11 @@ static void __widget_on_disconnected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_ int pid = (intptr_t)user_data; widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); + if (NULL == widget_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + return; + } + widget_tidl_info->connected = false; widget_tidl_info->connection_requesting = false; @@ -1400,6 +1410,11 @@ static void __widget_on_rejected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, int pid = (intptr_t)user_data; widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); + if (NULL == widget_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + return; + } + widget_tidl_info->connection_requesting = false; SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Rejected from widget"); -- 2.7.4 From 98b772f4324cd5483a346a882ea3c346de60d1a7 Mon Sep 17 00:00:00 2001 From: ulgal-park Date: Tue, 14 Mar 2023 21:26:44 +0900 Subject: [PATCH 09/16] Update version to 1.75.3 Change-Id: Ide3c6b0833559c11759c1afccb3a846eaba642f1 --- packaging/voice-control.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index d10e747..39f30d7 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.75.2 +Version: 1.75.3 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 3da5984f05918108d467f56f3eba214e4e1f7260 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 4 Apr 2023 18:16:17 +0900 Subject: [PATCH 10/16] Unregister TIDL stub port when connection is closed - Issue: Connected event callback is invoked even though the connection is closed. - Solution: Previous code does not invoke unregister method of TIDL stub, so the connection callback still can be invoked even if the client succeeds to deinitialize. And this is no intended behavior, so this patch fixes this behaivor. Through this patch, widget module will properly call unregister method. And also, widget module will check first if the stub information is valid. Change-Id: I1864824237218468b5341eb32c23c17e9f278651 Signed-off-by: Suyeon Hwang --- client/vc_widget_tidl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index b099088..55b2e09 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -197,6 +197,8 @@ static rpc_port_proxy_vc_widget_proxy_vc_widget_h __create_rpc_port(const char* static void __vcd_widget_create_cb(rpc_port_stub_vc_widget_stub_vcd_widget_context_h context, void *user_data) { + RETM_IF(NULL == g_stub_tidl_info, TAG_VCW, "[ERROR] Fail to get tidl stub info"); + g_stub_tidl_info->connected = true; g_stub_tidl_info->register_callback_requesting = false; @@ -216,6 +218,8 @@ static void __vcd_widget_create_cb(rpc_port_stub_vc_widget_stub_vcd_widget_conte static void __vcd_widget_terminate_cb(rpc_port_stub_vc_widget_stub_vcd_widget_context_h context, void *user_data) { + RETM_IF(NULL == g_stub_tidl_info, TAG_VCW, "[ERROR] Fail to get tidl stub info"); + g_stub_tidl_info->connected = false; g_stub_tidl_info->register_callback_requesting = false; @@ -243,6 +247,8 @@ static int __vcd_widget_asr_result_cb(rpc_port_stub_vc_widget_stub_vcd_widget_co static void __register_stub_callback() { + RETM_IF(NULL == g_stub_tidl_info, TAG_VCW, "[TIDL ERROR] g_stub_tidl_info is not allocated"); + if (g_stub_tidl_info->register_callback_requesting) { return; } @@ -344,6 +350,12 @@ int vc_widget_tidl_close_connection() free(g_proxy_tidl_info); g_proxy_tidl_info = NULL; + if (0 != rpc_port_stub_vc_widget_stub_vcd_widget_unregister()) { + SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Fail to unregister stub"); + pthread_mutex_unlock(&g_w_tidl_mutex); + return VC_ERROR_OPERATION_FAILED; + } + free(g_stub_tidl_info); g_stub_tidl_info = NULL; -- 2.7.4 From b8511f431544f16a05aad1bf87658e00fb38f6cb Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 4 Apr 2023 18:24:07 +0900 Subject: [PATCH 11/16] Update version (1.75.4) Change-Id: Ibd6321eb00b938a8811e031bee00469c62e3a85d Signed-off-by: Suyeon Hwang --- packaging/voice-control.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 39f30d7..467a94a 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.75.3 +Version: 1.75.4 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 18b00a7cc7518a781638a7751523824d8578f3dc Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 6 Apr 2023 14:09:29 +0900 Subject: [PATCH 12/16] Rearrange the scope of each temporary variables This patch is for solving static analysis issues. Through this patch, the scope of each temporary variables will become as smaller as they can. This change can reduce the possibility of mistakes such as accessing invalid pointer. Change-Id: I93aaef1711ddc27663812fd0c089c9be4c277f23 Signed-off-by: Suyeon Hwang --- common/vc_cmd_db.c | 8 +++----- common/vc_command.c | 11 ++++------- server/vcd_client_data.c | 7 ++----- server/vcd_server.c | 13 ++++--------- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 2ddbb47..9a30848 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -2172,12 +2172,10 @@ static int __vc_db_insert_command(sqlite3* db_handle, int pid, vc_cmd_type_e typ } if (0 != g_slist_length(cmd_list)) { - GSList *iter = NULL; - char* temp_command = NULL; - iter = g_slist_nth(cmd_list, 0); + GSList *iter = g_slist_nth(cmd_list, 0); while (NULL != iter) { - temp_command = iter->data; + char *temp_command = iter->data; if (NULL != temp_command) { if (NULL != tmp_cmd->command) { @@ -2219,7 +2217,7 @@ static int __vc_db_insert_command(sqlite3* db_handle, int pid, vc_cmd_type_e typ if (VC_DB_ERROR_NONE != ret) { while (NULL != iter) { - temp_command = iter->data; + char *temp_command = iter->data; if (NULL != temp_command) { cmd_list = g_slist_remove(cmd_list, temp_command); diff --git a/common/vc_command.c b/common/vc_command.c index 1c63b22..e6b5767 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -1763,8 +1763,6 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) int hour = -1; int min = -1; - char *tempstr = NULL; - *exist = 0; ret = regexec(®[3], str, 1, pmatch, 0); if (0 == ret) { @@ -1782,7 +1780,7 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length"); return VC_ERROR_OPERATION_FAILED; } - tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); + char *tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); @@ -1808,7 +1806,7 @@ static int __vc_cmd_trelative_check(const char *str, struct tm *td, int *exist) SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length"); return VC_ERROR_OPERATION_FAILED; } - tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); + char *tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); @@ -1861,7 +1859,6 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) int min = -1; int sidx = -1; int eidx = -1; - char *tempstr = NULL; *exist = 0; ret = regexec(®[0], str, 5, pmatch, 0); @@ -1882,7 +1879,7 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid string length"); return VC_ERROR_OPERATION_FAILED; } - tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); + char *tempstr = strndup(str + pmatch[1].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); @@ -1922,7 +1919,7 @@ static int __vc_cmd_tabsolute_check(const char *str, struct tm *td, int *exist) idx = 1; len = pmatch[idx].rm_eo - pmatch[idx].rm_so; if (0 < len) { - tempstr = strndup(str + pmatch[idx].rm_so, (size_t)len); + char *tempstr = strndup(str + pmatch[idx].rm_so, (size_t)len); if (NULL == tempstr) { SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Memory allocation is failed"); diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index de4c8cf..ab42c56 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -396,13 +396,10 @@ manager_tidl_info_s* vcd_client_manager_get_tidl_info() static void __vcd_client_release_each_commands(GSList** cmds) { - GSList *iter = NULL; - vc_cmd_s* temp_cmd; - if (0 < g_slist_length(*cmds)) { - iter = g_slist_nth(*cmds, 0); + GSList *iter = g_slist_nth(*cmds, 0); while (NULL != iter) { - temp_cmd = iter->data; + vc_cmd_s *temp_cmd = iter->data; if (NULL != temp_cmd) { if (NULL != temp_cmd->command) { diff --git a/server/vcd_server.c b/server/vcd_server.c index ebdfaf8..9945e0c 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -342,12 +342,9 @@ static bool __vcd_launch_app(const char* result) if (0 != g_slist_length(app_list)) { /* release data */ - GSList *iter = NULL; - vc_deactivated_app_s* temp_app = NULL; - iter = g_slist_nth(app_list, 0); - + GSList *iter = g_slist_nth(app_list, 0); while (NULL != iter) { - temp_app = iter->data; + vc_deactivated_app_s *temp_app = iter->data; if (NULL != temp_app && NULL != temp_app->appid) { int ret = -1; @@ -402,15 +399,13 @@ static Eina_Bool __vcd_send_selected_result(void *data) SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to get pid list. No result"); } else { if (0 < g_slist_length(pid_list)) { - GSList* iter = NULL; - vc_cmd_s* temp_cmd = NULL; int ret = 0; int pre_pid = -1; int pre_type = -1; - iter = g_slist_nth(pid_list, 0); + GSList *iter = g_slist_nth(pid_list, 0); while (NULL != iter) { - temp_cmd = iter->data; + vc_cmd_s *temp_cmd = iter->data; if (NULL != temp_cmd && (pre_pid != temp_cmd->pid || pre_type == VC_COMMAND_TYPE_WIDGET || temp_cmd->type == VC_COMMAND_TYPE_WIDGET)) { /* Launch deactivated several apps that is matched with result */ -- 2.7.4 From 950c1845dbade6cec1a31306247eb75d03ad60ef Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 7 Apr 2023 17:31:36 +0900 Subject: [PATCH 13/16] Invoke changed callbacks using ecore idler - Requirements: Each callbacks should not prevent main loop for a long time. - Contents: This patch fixes the logic of changed callback invocation. Through this patch, each callbacks will be invoked by ecore idler. This makes the code blocks the main loop for reasonable time. And this makes each callbacks behavior become asynchronous. Change-Id: I482e5168f3f9ff44398b5b7d067a68f37e511fd0 Signed-off-by: Suyeon Hwang --- common/vc_config_mgr.cpp | 175 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 154 insertions(+), 21 deletions(-) diff --git a/common/vc_config_mgr.cpp b/common/vc_config_mgr.cpp index e502e7e..3986088 100644 --- a/common/vc_config_mgr.cpp +++ b/common/vc_config_mgr.cpp @@ -53,6 +53,11 @@ typedef struct { int dir_wd; } vc_engine_inotify_s; +typedef struct { + char* before_lang; + char* current_lang; +} language_changed_cb_parameters_s; + static const char* vc_config_tag() { return TAG_VCCONFIG; @@ -66,6 +71,10 @@ static VoiceControlClients *g_VoiceControlClients = nullptr; static VoiceControlConfig *g_VoiceControlConfig = nullptr; +static Ecore_Idler *g_engine_changed_event_idler = NULL; +static Ecore_Idler *g_language_changed_event_idler = NULL; +static Ecore_Idler *g_enabled_changed_event_idler = NULL; + static int g_lang_ref_count; static Ecore_Fd_Handler* g_fd_handler_lang = NULL; static int g_fd_lang = -1; @@ -78,6 +87,45 @@ static int register_engine_config_updated_event(const char* path); static int unregister_engine_config_updated_event(); static int set_current_language(const char* language); +static Eina_Bool notify_engine_changed_event_by_idler(void *data) +{ + char *engine_appid = static_cast(data); + [&engine_appid]() { + if (nullptr == engine_appid) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Engine is not specified."); + return; + } + + if (nullptr == g_VoiceControlClients) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] No clients exist"); + return; + } + + auto clients = g_VoiceControlClients->getClients(); + for (auto &clientInfo : clients) { + if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { + SLOG(LOG_WARN, vc_config_tag(), "[ERROR] Skip invalid client (%u)", clientInfo.getUid()); + continue; + } + + clientInfo.invokeEngineChangedCallback(engine_appid); + } + }(); + + free(engine_appid); + g_engine_changed_event_idler = nullptr; + return EINA_FALSE; +} + +static inline void delete_engine_changed_event_invoker() +{ + if (nullptr != g_engine_changed_event_idler) { + void *param = ecore_idler_del(g_engine_changed_event_idler); + g_engine_changed_event_idler = nullptr; + free(static_cast(param)); + } +} + static void notify_engine_changed(const char *engine_appid) { SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke engine changed callback"); @@ -86,14 +134,63 @@ static void notify_engine_changed(const char *engine_appid) return; } - auto clients = g_VoiceControlClients->getClients(); - for (auto &clientInfo : clients) { - if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { - SLOG(LOG_WARN, vc_config_tag(), "[ERROR] Skip invalid client (%u)", clientInfo.getUid()); - continue; + char *param = strdup(engine_appid); + if (nullptr == param) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to allocate the memory for parameter"); + return; + } + + delete_engine_changed_event_invoker(); + g_engine_changed_event_idler = ecore_idler_add(notify_engine_changed_event_by_idler, static_cast(param)); +} + +static inline void release_language_changed_cb_params(language_changed_cb_parameters_s *params) +{ + if (nullptr == params) { + return; + } + + free(params->before_lang); + free(params->current_lang); + delete params; +} + +static Eina_Bool notify_language_changed_event_by_idler(void *data) +{ + language_changed_cb_parameters_s *params = static_cast(data); + [¶ms]() { + if (nullptr == params) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Parameters are not specified."); + return; + } + + if (nullptr == g_VoiceControlClients) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] No clients exist"); + return; + } + + auto clients = g_VoiceControlClients->getClients(); + for (auto &clientInfo : clients) { + if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { + SLOG(LOG_WARN, vc_config_tag(), "[ERROR] Skip invalid client (%u)", clientInfo.getUid()); + continue; + } + + clientInfo.invokeLanguageChangedCallback(params->before_lang, params->current_lang); } + }(); - clientInfo.invokeEngineChangedCallback(engine_appid); + release_language_changed_cb_params(params); + g_language_changed_event_idler = nullptr; + return EINA_FALSE; +} + +static inline void delete_language_changed_event_invoker() +{ + if (nullptr != g_language_changed_event_idler) { + void *params = ecore_idler_del(g_language_changed_event_idler); + g_language_changed_event_idler = nullptr; + release_language_changed_cb_params(static_cast(params)); } } @@ -105,34 +202,70 @@ static void notify_language_changed(const char* before_lang, const char* current return; } - if (nullptr == g_VoiceControlClients) { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] No clients exist"); + auto *params = new language_changed_cb_parameters_s(); + if (nullptr == params) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to allocate the memory for parameter"); return; } - auto clients = g_VoiceControlClients->getClients(); - for (auto &clientInfo : clients) { - if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { - SLOG(LOG_WARN, vc_config_tag(), "[ERROR] Skip invalid client (%u)", clientInfo.getUid()); - continue; + params->before_lang = strdup(before_lang); + params->current_lang = strdup(current_lang); + + delete_language_changed_event_invoker(); + g_engine_changed_event_idler = ecore_idler_add(notify_language_changed_event_by_idler, static_cast(params)); +} + +static Eina_Bool notify_enabled_changed_event_by_idler(void *data) +{ + bool *enable = static_cast(data); + [&enable]() { + if (nullptr == enable) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Engine is not specified."); + return; + } + + if (nullptr == g_VoiceControlClients) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] No clients exist"); + return; + } + + auto clients = g_VoiceControlClients->getClients(); + for (auto &clientInfo : clients) { + if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { + SLOG(LOG_WARN, vc_config_tag(), "[ERROR] Skip invalid client (%u)", clientInfo.getUid()); + continue; + } + + clientInfo.invokeEnabledChangedCallback(*enable); } + }(); - clientInfo.invokeLanguageChangedCallback(before_lang, current_lang); + free(enable); + g_enabled_changed_event_idler = nullptr; + return EINA_FALSE; +} + +static inline void delete_enabled_changed_event_invoker() +{ + if (nullptr != g_enabled_changed_event_idler) { + void *param = ecore_idler_del(g_enabled_changed_event_idler); + g_enabled_changed_event_idler = nullptr; + free(static_cast(param)); } } static void notify_enabled_changed(bool enable) { SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke enabled callback"); - auto clients = g_VoiceControlClients->getClients(); - for (auto &clientInfo : clients) { - if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { - SLOG(LOG_WARN, vc_config_tag(), "[ERROR] Skip invalid client (%u)", clientInfo.getUid()); - continue; - } - clientInfo.invokeEnabledChangedCallback(enable); + bool *param = new bool(enable); + if (nullptr == param) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to allocate the memory for parameter"); + return; } + + delete_enabled_changed_event_invoker(); + g_engine_changed_event_idler = ecore_idler_add(notify_enabled_changed_event_by_idler, static_cast(param)); } static int initialize_config_info() -- 2.7.4 From 63b20272cccf74dc3e86da7f39f2c0e4b0397800 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 7 Apr 2023 18:09:12 +0900 Subject: [PATCH 14/16] Invoke config changed callback directly - Issue: If the app changes the config using setting API, the framework did not invoke config changed callbacks. - Solution: In previous code, vc_config_mgr module could know the changes of the configuration through checking the difference between the values in the memory and actual configuration file. However, the values in the memory and configuration file are the same if the app uses the setting API. This is beecause the setting API sets the value in both the memory and file. So, this patch adds a new logic for invoking the callbacks. Through this patch, vc_config_mgr module will directly invoke the callbacks related to changed values when the app changes the configuration using setting API. Change-Id: Ic8023395889021501d8528401f9058b743699c72 Signed-off-by: Suyeon Hwang --- common/vc_config_mgr.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/common/vc_config_mgr.cpp b/common/vc_config_mgr.cpp index 3986088..9fb301e 100644 --- a/common/vc_config_mgr.cpp +++ b/common/vc_config_mgr.cpp @@ -89,6 +89,7 @@ static int set_current_language(const char* language); static Eina_Bool notify_engine_changed_event_by_idler(void *data) { + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke engine changed callback by idler"); char *engine_appid = static_cast(data); [&engine_appid]() { if (nullptr == engine_appid) { @@ -101,6 +102,7 @@ static Eina_Bool notify_engine_changed_event_by_idler(void *data) return; } + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Engine ID : %s", engine_appid); auto clients = g_VoiceControlClients->getClients(); for (auto &clientInfo : clients) { if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { @@ -157,6 +159,7 @@ static inline void release_language_changed_cb_params(language_changed_cb_parame static Eina_Bool notify_language_changed_event_by_idler(void *data) { + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke language changed callback by idler"); language_changed_cb_parameters_s *params = static_cast(data); [¶ms]() { if (nullptr == params) { @@ -169,6 +172,7 @@ static Eina_Bool notify_language_changed_event_by_idler(void *data) return; } + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Before : %s, Current : %s", params->before_lang, params->current_lang); auto clients = g_VoiceControlClients->getClients(); for (auto &clientInfo : clients) { if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { @@ -217,6 +221,7 @@ static void notify_language_changed(const char* before_lang, const char* current static Eina_Bool notify_enabled_changed_event_by_idler(void *data) { + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke enabled changed callback by idler"); bool *enable = static_cast(data); [&enable]() { if (nullptr == enable) { @@ -229,6 +234,7 @@ static Eina_Bool notify_enabled_changed_event_by_idler(void *data) return; } + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Enabled : %s", *enable ? "True" : "False"); auto clients = g_VoiceControlClients->getClients(); for (auto &clientInfo : clients) { if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) { @@ -323,6 +329,7 @@ static int check_and_set_default_engine_id(const char* engine_id) SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config"); return VC_CONFIG_ERROR_OPERATION_FAILED; } + notify_engine_changed(engineId.c_str()); g_VoiceControlConfig->setEngineId(engineId.c_str()); return VC_CONFIG_ERROR_NONE; @@ -737,6 +744,7 @@ static int set_language_by_automatic_selection() SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save default language"); return VC_CONFIG_ERROR_OPERATION_FAILED; } + notify_language_changed(before_language.c_str(), candidate_lang); g_VoiceControlConfig->setCurrentLanguage(candidate_lang); SLOG(LOG_DEBUG, vc_config_tag(), "[Config] Default language change : before(%s) current(%s)", @@ -763,6 +771,7 @@ static int set_language_by_automatic_selection() SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config"); return VC_CONFIG_ERROR_OPERATION_FAILED; } + notify_language_changed(before_language.c_str(), tmp_language); g_VoiceControlConfig->setCurrentLanguage(tmp_language); SLOG(LOG_DEBUG, vc_config_tag(), "[Config] Default language change : before(%s) current(%s)", @@ -1304,6 +1313,7 @@ int vc_config_mgr_set_engine(const char* engine) SLOG(LOG_ERROR, vc_config_tag(), " Fail to save config"); return VC_CONFIG_ERROR_OPERATION_FAILED; } + notify_engine_changed(engine); g_VoiceControlConfig->setEngineId(engine); /* Engine is valid*/ @@ -1406,6 +1416,7 @@ static int set_current_language(const char* language) SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save engine id"); return VC_CONFIG_ERROR_OPERATION_FAILED; } + notify_language_changed(default_language.c_str(), language); g_VoiceControlConfig->setCurrentLanguage(language); return VC_CONFIG_ERROR_NONE; @@ -1443,7 +1454,7 @@ int vc_config_mgr_set_enabled(bool value) SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to set enabled"); return VC_CONFIG_ERROR_OPERATION_FAILED; } - + notify_enabled_changed(value); g_VoiceControlConfig->setEnabled(value); return VC_CONFIG_ERROR_NONE; -- 2.7.4 From aafdb2a1c449bb176b4196cd1674bac736109d8a Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 7 Apr 2023 18:16:04 +0900 Subject: [PATCH 15/16] Update version (1.75.5) Change-Id: I2c5592f9bebc39379ce7e1c6d54235b74d7b3feb Signed-off-by: Suyeon Hwang --- packaging/voice-control.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 467a94a..515634c 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.75.4 +Version: 1.75.5 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From e03fd5910dd4e0c85da5602444629d6364fe3de5 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 7 Apr 2023 20:42:08 +0900 Subject: [PATCH 16/16] Use ecore timer for config changed callbacks Change-Id: I489807ea63d7d16529bcaf7ffa563b45c2635f56 Signed-off-by: Suyeon Hwang --- common/vc_config_mgr.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/common/vc_config_mgr.cpp b/common/vc_config_mgr.cpp index 9fb301e..6977544 100644 --- a/common/vc_config_mgr.cpp +++ b/common/vc_config_mgr.cpp @@ -71,9 +71,9 @@ static VoiceControlClients *g_VoiceControlClients = nullptr; static VoiceControlConfig *g_VoiceControlConfig = nullptr; -static Ecore_Idler *g_engine_changed_event_idler = NULL; -static Ecore_Idler *g_language_changed_event_idler = NULL; -static Ecore_Idler *g_enabled_changed_event_idler = NULL; +static Ecore_Timer *g_engine_changed_event_invoker = NULL; +static Ecore_Timer *g_language_changed_event_invoker = NULL; +static Ecore_Timer *g_enabled_changed_event_invoker = NULL; static int g_lang_ref_count; static Ecore_Fd_Handler* g_fd_handler_lang = NULL; @@ -87,9 +87,9 @@ static int register_engine_config_updated_event(const char* path); static int unregister_engine_config_updated_event(); static int set_current_language(const char* language); -static Eina_Bool notify_engine_changed_event_by_idler(void *data) +static Eina_Bool notify_engine_changed_event_by_invoker(void *data) { - SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke engine changed callback by idler"); + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke engine changed callback asynchronously"); char *engine_appid = static_cast(data); [&engine_appid]() { if (nullptr == engine_appid) { @@ -115,15 +115,15 @@ static Eina_Bool notify_engine_changed_event_by_idler(void *data) }(); free(engine_appid); - g_engine_changed_event_idler = nullptr; + g_engine_changed_event_invoker = nullptr; return EINA_FALSE; } static inline void delete_engine_changed_event_invoker() { - if (nullptr != g_engine_changed_event_idler) { - void *param = ecore_idler_del(g_engine_changed_event_idler); - g_engine_changed_event_idler = nullptr; + if (nullptr != g_engine_changed_event_invoker) { + void *param = ecore_timer_del(g_engine_changed_event_invoker); + g_engine_changed_event_invoker = nullptr; free(static_cast(param)); } } @@ -143,7 +143,7 @@ static void notify_engine_changed(const char *engine_appid) } delete_engine_changed_event_invoker(); - g_engine_changed_event_idler = ecore_idler_add(notify_engine_changed_event_by_idler, static_cast(param)); + g_engine_changed_event_invoker = ecore_timer_add(0.0, notify_engine_changed_event_by_invoker, static_cast(param)); } static inline void release_language_changed_cb_params(language_changed_cb_parameters_s *params) @@ -157,9 +157,9 @@ static inline void release_language_changed_cb_params(language_changed_cb_parame delete params; } -static Eina_Bool notify_language_changed_event_by_idler(void *data) +static Eina_Bool notify_language_changed_event_by_invoker(void *data) { - SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke language changed callback by idler"); + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke language changed callback asynchronously"); language_changed_cb_parameters_s *params = static_cast(data); [¶ms]() { if (nullptr == params) { @@ -185,15 +185,15 @@ static Eina_Bool notify_language_changed_event_by_idler(void *data) }(); release_language_changed_cb_params(params); - g_language_changed_event_idler = nullptr; + g_language_changed_event_invoker = nullptr; return EINA_FALSE; } static inline void delete_language_changed_event_invoker() { - if (nullptr != g_language_changed_event_idler) { - void *params = ecore_idler_del(g_language_changed_event_idler); - g_language_changed_event_idler = nullptr; + if (nullptr != g_language_changed_event_invoker) { + void *params = ecore_timer_del(g_language_changed_event_invoker); + g_language_changed_event_invoker = nullptr; release_language_changed_cb_params(static_cast(params)); } } @@ -216,12 +216,12 @@ static void notify_language_changed(const char* before_lang, const char* current params->current_lang = strdup(current_lang); delete_language_changed_event_invoker(); - g_engine_changed_event_idler = ecore_idler_add(notify_language_changed_event_by_idler, static_cast(params)); + g_language_changed_event_invoker = ecore_timer_add(0.0, notify_language_changed_event_by_invoker, static_cast(params)); } -static Eina_Bool notify_enabled_changed_event_by_idler(void *data) +static Eina_Bool notify_enabled_changed_event_by_invoker(void *data) { - SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke enabled changed callback by idler"); + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke enabled changed callback asynchronously"); bool *enable = static_cast(data); [&enable]() { if (nullptr == enable) { @@ -247,15 +247,15 @@ static Eina_Bool notify_enabled_changed_event_by_idler(void *data) }(); free(enable); - g_enabled_changed_event_idler = nullptr; + g_enabled_changed_event_invoker = nullptr; return EINA_FALSE; } static inline void delete_enabled_changed_event_invoker() { - if (nullptr != g_enabled_changed_event_idler) { - void *param = ecore_idler_del(g_enabled_changed_event_idler); - g_enabled_changed_event_idler = nullptr; + if (nullptr != g_enabled_changed_event_invoker) { + void *param = ecore_timer_del(g_enabled_changed_event_invoker); + g_enabled_changed_event_invoker = nullptr; free(static_cast(param)); } } @@ -271,7 +271,7 @@ static void notify_enabled_changed(bool enable) } delete_enabled_changed_event_invoker(); - g_engine_changed_event_idler = ecore_idler_add(notify_enabled_changed_event_by_idler, static_cast(param)); + g_enabled_changed_event_invoker = ecore_timer_add(0.0, notify_enabled_changed_event_by_invoker, static_cast(param)); } static int initialize_config_info() -- 2.7.4