From e06a52a1f77dfefe9ef7b99f058cba4595ac07c3 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 20 Jul 2021 18:34:00 +0900 Subject: [PATCH 01/16] Allocate memory for output command list handle 'vc_get_system_command_list()' should return system command list with memory for handle for this list. However previous code does not allocate memory. This patch allocates new memory for output command list handle. System commands would be included this new handle. And also, this patch fixes the description of 'vc_get_system_command_list()' to deallocate memory using 'vc_cmd_list_destroy()'. Change-Id: Ie9d474d2115681b27c7f51f4da3f5487e7109eca Signed-off-by: Suyeon Hwang --- client/vc.c | 15 ++++++++++++--- include/voice_control.h | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/vc.c b/client/vc.c index 2cb5930..a2691c0 100644 --- a/client/vc.c +++ b/client/vc.c @@ -934,6 +934,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; } + *vc_sys_cmd_list = NULL; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -995,23 +996,31 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) return VC_ERROR_OPERATION_FAILED; } - vc_cmd_list_s* list = NULL; - list = (vc_cmd_list_s*)(*vc_sys_cmd_list); if (true == is_sys_cmd_valid) { + vc_cmd_list_s* list = NULL; + ret = vc_cmd_list_create((vc_cmd_list_h*)&list); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create command list"); //LCOV_EXCL_LINE + return ret; + } + ret = vc_cmd_parser_get_commands(mgr_pid, VC_COMMAND_TYPE_SYSTEM, &(list->list)); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get parsing commands"); //LCOV_EXCL_LINE + vc_cmd_list_destroy((vc_cmd_list_h)list, true); return ret; } + ret = vc_cmd_parser_get_commands(mgr_pid, VC_COMMAND_TYPE_SYSTEM_BACKGROUND, &(list->list)); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get parsing commands"); //LCOV_EXCL_LINE + vc_cmd_list_destroy((vc_cmd_list_h)list, true); return ret; } + *vc_sys_cmd_list = (vc_cmd_list_h)list; } else { SLOG(LOG_WARN, TAG_VCC, "[WARNING] No system commands"); //LCOV_EXCL_LINE - *vc_sys_cmd_list = NULL; return VC_ERROR_NONE; } diff --git a/include/voice_control.h b/include/voice_control.h index 69172d2..ab80ca2 100644 --- a/include/voice_control.h +++ b/include/voice_control.h @@ -245,7 +245,7 @@ int vc_get_service_state(vc_service_state_e* state); * @privilege %http://tizen.org/privilege/recorder * @remarks In the system command list, there are system commands predefined by product manufacturers. Those commands have the highest priority. * Therefore, the user can not set any commands same with the system commands. - * The @a vc_sys_cmd_list must be released using free() when it is no longer required. + * The @a vc_sys_cmd_list must be released using vc_cmd_list_destroy() when it is no longer required. * @param[out] vc_sys_cmd_list System command list handle * @return @c 0 on success, * otherwise a negative error value @@ -255,7 +255,7 @@ int vc_get_service_state(vc_service_state_e* state); * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported * @pre The service state should be #VC_SERVICE_STATE_READY. - * @see vc_unset_command_list() + * @see vc_cmd_list_destroy() */ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list); -- 2.7.4 From 6b513a92a6d451837c58da4573ad0e836ce93ac6 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 20 Jul 2021 20:23:02 +0900 Subject: [PATCH 02/16] Remove memory leak on new TC for vc_get_system_command_list() Change-Id: Ieeb48b4aee90a4b9bf50f0b2dc3d43bcdab90cb6 Signed-off-by: Suyeon Hwang --- tests/src/vc_unittests.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/src/vc_unittests.cpp b/tests/src/vc_unittests.cpp index 0320972..780b61e 100644 --- a/tests/src/vc_unittests.cpp +++ b/tests/src/vc_unittests.cpp @@ -106,6 +106,13 @@ static bool __vc_cmd_list_cb(vc_cmd_h vc_command, void* user_data) static void __vc_mgr_ready() { + EXPECT_EQ(vc_mgr_initialize(), VC_ERROR_NONE); + EXPECT_EQ(vc_mgr_set_state_changed_cb(__vc_mgr_state_changed_cb, nullptr), VC_ERROR_NONE); + EXPECT_EQ(vc_mgr_set_service_state_changed_cb(__vc_mgr_service_state_changed_cb, nullptr), VC_ERROR_NONE); + EXPECT_EQ(vc_mgr_prepare(), VC_ERROR_NONE); + ASSERT_EQ(true, __is_mgr_state_changed(VC_STATE_READY, 5)); + ASSERT_EQ(true, __is_mgr_service_state_changed(VC_SERVICE_STATE_READY, 5)); + vc_cmd_h system_command = nullptr; EXPECT_EQ(vc_cmd_create(&system_command), VC_ERROR_NONE); EXPECT_EQ(vc_cmd_set_command(system_command, "test"), VC_ERROR_NONE); @@ -115,14 +122,17 @@ static void __vc_mgr_ready() EXPECT_EQ(vc_cmd_list_create(&commands), VC_ERROR_NONE); EXPECT_EQ(vc_cmd_list_add(commands, system_command), VC_ERROR_NONE); - EXPECT_EQ(vc_mgr_initialize(), VC_ERROR_NONE); - EXPECT_EQ(vc_mgr_set_state_changed_cb(__vc_mgr_state_changed_cb, nullptr), VC_ERROR_NONE); - EXPECT_EQ(vc_mgr_set_service_state_changed_cb(__vc_mgr_service_state_changed_cb, nullptr), VC_ERROR_NONE); - EXPECT_EQ(vc_mgr_prepare(), VC_ERROR_NONE); - ASSERT_EQ(true, __is_mgr_state_changed(VC_STATE_READY, 5)); - ASSERT_EQ(true, __is_mgr_service_state_changed(VC_SERVICE_STATE_READY, 5)); - EXPECT_EQ(vc_mgr_set_command_list(commands), VC_ERROR_NONE); + + EXPECT_EQ(vc_cmd_list_destroy(commands, true), VC_ERROR_NONE); +} + +static void __vc_mgr_finish() +{ + EXPECT_EQ(vc_mgr_unprepare(), VC_ERROR_NONE); + EXPECT_EQ(vc_mgr_unset_state_changed_cb(), VC_ERROR_NONE); + EXPECT_EQ(vc_mgr_unset_service_state_changed_cb(), VC_ERROR_NONE); + EXPECT_EQ(vc_mgr_deinitialize(), VC_ERROR_NONE); } namespace { @@ -750,6 +760,10 @@ TEST_F(VCTest, vc_get_system_command_list_p) ret = vc_get_system_command_list(&list); EXPECT_EQ(ret, VC_ERROR_NONE); + if (NULL != list) { + EXPECT_EQ(vc_cmd_list_destroy(list, true), VC_ERROR_NONE); + } + ret = vc_unprepare(); EXPECT_EQ(ret, VC_ERROR_NONE); } @@ -791,6 +805,9 @@ TEST_F(VCTest, vc_get_system_command_list_p2) EXPECT_EQ(ret, VC_ERROR_NONE); EXPECT_GT(count, 0); + EXPECT_EQ(vc_cmd_list_destroy(list, true), VC_ERROR_NONE); + + __vc_mgr_finish(); ret = vc_unprepare(); EXPECT_EQ(ret, VC_ERROR_NONE); } -- 2.7.4 From 083728aa20a379fb7ff181a5283e58ed3214aca7 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 23 Jul 2021 10:53:31 +0900 Subject: [PATCH 03/16] Update version (1.65.2) Change-Id: I40c7242de4d22b5ce2bb89c6bac462d74453edf7 Signed-off-by: Suyeon Hwang --- CMakeLists.txt | 2 +- packaging/voice-control.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca3789f..61458e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.65.1) +SET(VERSION 1.65.2) FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index e13906d..767318f 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.65.1 +Version: 1.65.2 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 20d98b6e237b19d2a45d0e9bac17892540eb5bb5 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Tue, 14 Sep 2021 10:58:47 +0900 Subject: [PATCH 04/16] Extend waiting time for response from engine Previous waiting time was 2 sec, because 200 ms x 10 retry time was. But, in TW3, VC Engine was launched after almost 3 sec. Therefore, waiting time will be extended to 4 sec by this patch. Change-Id: I0aa8077663bd345e17f2bf8bf11373d3921dd470 --- client/vc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/vc.c b/client/vc.c index a2691c0..2f21d9c 100644 --- a/client/vc.c +++ b/client/vc.c @@ -609,7 +609,7 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) /* Send hello */ while (0 != ret) { - if (retry_count == 10) { + if (retry_count == 20) { // 200 ms * 20 = 4 sec SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request hello !!"); //LCOV_EXCL_LINE return; } -- 2.7.4 From 1d206f54a56d957cd2a5201012dd940c0014caf9 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 1 Oct 2021 17:51:29 +0900 Subject: [PATCH 05/16] Fix memory leak when remove item from g_list Change-Id: Iea82db5c35455bbf180bb160d217a7188780ec72 Signed-off-by: Suyeon Hwang --- common/vc_command.c | 4 ++-- common/vc_config_mgr.c | 3 +-- server/vcd_server.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/common/vc_command.c b/common/vc_command.c index 665f8d9..25eabf9 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -244,7 +244,7 @@ int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool release_command) return VC_ERROR_INVALID_PARAMETER; } - g_cmdlist_list = g_list_remove_link(g_cmdlist_list, iter); + g_cmdlist_list = g_list_delete_link(g_cmdlist_list, iter); vc_cmd_list_remove_all((vc_cmd_list_h)list, release_command); free(list); @@ -751,7 +751,7 @@ int vc_cmd_destroy(vc_cmd_h vc_command) return VC_ERROR_INVALID_PARAMETER; } - g_cmd_list = g_list_remove_link(g_cmd_list, iter); + g_cmd_list = g_list_delete_link(g_cmd_list, iter); if (command->command) free(command->command); diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index 5d5fd12..f1c351b 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -564,8 +564,7 @@ static int __vc_config_mgr_unregister_engine_config_updated_event() tmp = NULL; } - g_ino_list = g_list_remove_link(g_ino_list, iter); - + g_ino_list = g_list_delete_link(g_ino_list, iter); iter = g_list_first(g_ino_list); } } diff --git a/server/vcd_server.c b/server/vcd_server.c index a89732f..e80bc14 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1347,7 +1347,7 @@ bool vcd_finalize() if (0 < g_list_length(g_proc_list)) { iter = g_list_first(g_proc_list); while (NULL != iter) { - g_proc_list = g_list_remove_link(g_proc_list, iter); + g_proc_list = g_list_delete_link(g_proc_list, iter); iter = g_list_first(g_proc_list); } } @@ -1430,7 +1430,7 @@ static void __read_proc() if (0 < g_list_length(g_proc_list)) { iter = g_list_first(g_proc_list); while (NULL != iter) { - g_proc_list = g_list_remove_link(g_proc_list, iter); + g_proc_list = g_list_delete_link(g_proc_list, iter); iter = g_list_first(g_proc_list); } } -- 2.7.4 From 559da73cb540c27550965d72e3bb2a7384834a26 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Wed, 6 Oct 2021 15:13:49 +0900 Subject: [PATCH 06/16] Update version (1.65.3) Change-Id: I23bf5095f893033867694b62506acd2c3d2861b7 Signed-off-by: Suyeon Hwang --- CMakeLists.txt | 2 +- packaging/voice-control.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61458e3..7d761a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.65.2) +SET(VERSION 1.65.3) FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 767318f..6eebef0 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.65.2 +Version: 1.65.3 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 2292c36a6462296642e62e5b4cc74389029ab971 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Thu, 28 Oct 2021 17:45:49 +0900 Subject: [PATCH 07/16] Release memory when open connection is failed Change-Id: I3172ee394b75ea8a63e747f24dfc0797ee6a0fad --- server/vcd_server.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/server/vcd_server.c b/server/vcd_server.c index e80bc14..486b6cb 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1285,6 +1285,9 @@ int vcd_initialize(vce_request_callback_s *callback) ret = vc_db_initialize_for_daemon(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize DB : %d", ret); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return ret; } @@ -1299,17 +1302,26 @@ int vcd_initialize(vce_request_callback_s *callback) ret = vcd_engine_agent_init(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to engine agent initialize : result(%d)", ret); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return ret; } if (0 != vcd_recorder_create(__server_recorder_callback, __server_recorder_interrupt_callback)) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to create recorder"); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return VCD_ERROR_OPERATION_FAILED; } /* Load engine */ if (0 != vcd_engine_agent_load_current_engine(callback)) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to load current engine"); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return VCD_ERROR_OPERATION_FAILED; } @@ -1319,7 +1331,10 @@ int vcd_initialize(vce_request_callback_s *callback) // if (TRUE == __is_default_engine()) { /* Open dbus connection */ if (0 != vcd_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to open connection"); + if (TRUE != vcd_finalize()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + } return VCD_ERROR_OPERATION_FAILED; } // } @@ -1363,7 +1378,7 @@ bool vcd_finalize() } vcd_state_e state = vcd_config_get_service_state(); - if (VCD_STATE_READY != state) { + if (VCD_STATE_NONE != state && VCD_STATE_READY != state) { if (VCD_STATE_RECORDING == state) { vcd_recorder_stop(); } @@ -1396,8 +1411,10 @@ bool vcd_finalize() SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to finalize DB : %d", ret); } - vcd_config_set_service_state(VCD_STATE_NONE); - vcdc_send_service_state(VCD_STATE_NONE); + if (VCD_STATE_NONE != state) { + vcd_config_set_service_state(VCD_STATE_NONE); + vcdc_send_service_state(VCD_STATE_NONE); + } /* Open dbus connection */ if (0 != vcd_dbus_close_connection()) { -- 2.7.4 From c14e207d0a49a2e3a331e17a139b4b0bb484032c Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 15 Nov 2021 16:32:23 +0900 Subject: [PATCH 08/16] Call deinitialize() if error occurs after initialize() Change-Id: I275c7f0724d6a7676d0c68ba6c5554ac822c0795 Signed-off-by: Suyeon Hwang --- server/vcd_engine_agent.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 2ebb68b..531dbdf 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -314,6 +314,7 @@ int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback) ret = g_dynamic_engine.callbacks->set_language(g_default_lang); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set the supported language"); + g_dynamic_engine.callbacks->deinitialize(); return ret; } @@ -321,6 +322,7 @@ int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback) g_dynamic_engine.is_loaded = true; } else { SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent WARNING] This engine do not support default language : lang(%s)", g_default_lang); + g_dynamic_engine.callbacks->deinitialize(); g_dynamic_engine.is_loaded = false; return VCD_ERROR_OPERATION_FAILED; } -- 2.7.4 From 3d7abd5f8ecba9a7a08257dc3875666d9c9e818a Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 15 Nov 2021 16:32:53 +0900 Subject: [PATCH 09/16] Update version (1.65.4) Change-Id: I2c50f8620a8dbec3067ae9e70b310e95c62d2ddd Signed-off-by: Suyeon Hwang --- CMakeLists.txt | 2 +- packaging/voice-control.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d761a2..bfc1247 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.65.3) +SET(VERSION 1.65.4) FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 6eebef0..6d76313 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.65.3 +Version: 1.65.4 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 9c9ac37d85f65241f792bd366180e617f05c5975 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 19 Nov 2021 18:32:02 +0900 Subject: [PATCH 10/16] Check the streaming mode properly There is two cases to get sound data. One is recording sound data from dependency audio manager. And the other is getting from manager app using IPC. Streaming mode helps to identify this two situation. - Using dependency audio manager : VCD_AUDIO_STREAMING_MODE_VC_SERVICE, VCD_AUDIO_STREAMING_MODE_MULTI_ASSISTANT - Using IPC from voice control manager : VCD_AUDIO_STREAMING_MODE_OUTSIDE This patch fixes the check code to make each function works with proper streaming mode. Change-Id: Ief6c07e18ba3ba7a8c10f210fa868ff7948ce046 Signed-off-by: Suyeon Hwang --- server/vcd_recorder.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index fc06fec..cadb81d 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -431,7 +431,7 @@ int vcd_recorder_start_streaming() vcd_audio_streaming_mode_e streaming_mode; vcd_config_get_audio_streaming_mode(&streaming_mode); - if (VCD_AUDIO_STREAMING_MODE_VC_SERVICE == streaming_mode) { + if (VCD_AUDIO_STREAMING_MODE_OUTSIDE != streaming_mode) { SLOG(LOG_INFO, TAG_VCD, "[Recorder] Current audio streaming mode(%d)", streaming_mode); return VCD_ERROR_NONE; } @@ -473,7 +473,7 @@ int vcd_recorder_send_streaming(const void* buffer, const unsigned int length) { vcd_audio_streaming_mode_e streaming_mode; vcd_config_get_audio_streaming_mode(&streaming_mode); - if (VCD_AUDIO_STREAMING_MODE_VC_SERVICE == streaming_mode) { + if (VCD_AUDIO_STREAMING_MODE_OUTSIDE != streaming_mode) { SLOG(LOG_INFO, TAG_VCD, "[Recorder] Current audio streaming mode(%d)", streaming_mode); return VCD_ERROR_NONE; } @@ -502,7 +502,7 @@ int vcd_recorder_stop_streaming() vcd_audio_streaming_mode_e streaming_mode; vcd_config_get_audio_streaming_mode(&streaming_mode); - if (VCD_AUDIO_STREAMING_MODE_VC_SERVICE == streaming_mode) { + if (VCD_AUDIO_STREAMING_MODE_OUTSIDE != streaming_mode) { SLOG(LOG_INFO, TAG_VCD, "[Recorder] Current audio streaming mode(%d)", streaming_mode); return VCD_ERROR_NONE; } @@ -576,11 +576,9 @@ int vcd_recorder_recover_system_volume() int vcd_recorder_start() { - int ret = -1; - vcd_audio_streaming_mode_e streaming_mode; vcd_config_get_audio_streaming_mode(&streaming_mode); - if (VCD_AUDIO_STREAMING_MODE_MULTI_ASSISTANT == streaming_mode || VCD_AUDIO_STREAMING_MODE_OUTSIDE == streaming_mode) { + if (VCD_AUDIO_STREAMING_MODE_OUTSIDE == streaming_mode) { SLOG(LOG_INFO, TAG_VCD, "[Recorder] Current audio streaming mode(%d)", streaming_mode); return VCD_ERROR_NONE; } @@ -596,7 +594,7 @@ int vcd_recorder_start() // For testing ecore_main_loop_thread_safe_call_async(__timer_read_test_func, NULL); } else { - ret = dependency_audio_manager_start_recording(); + int ret = dependency_audio_manager_start_recording(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to start recording, [ret(%d)]", ret); return VCD_ERROR_OPERATION_FAILED; @@ -611,7 +609,7 @@ int vcd_recorder_start() while (1) { snprintf(normal_file_name, sizeof(normal_file_name), "/tmp/vc_normal_%d_%d", getpid(), g_count); - ret = access(normal_file_name, 0); + int ret = access(normal_file_name, 0); if (0 == ret) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] File is already exist"); @@ -639,10 +637,9 @@ int vcd_recorder_start() int vcd_recorder_stop() { - int ret = -1; vcd_audio_streaming_mode_e streaming_mode; vcd_config_get_audio_streaming_mode(&streaming_mode); - if (VCD_AUDIO_STREAMING_MODE_MULTI_ASSISTANT == streaming_mode || VCD_AUDIO_STREAMING_MODE_OUTSIDE == streaming_mode) { + if (VCD_AUDIO_STREAMING_MODE_OUTSIDE == streaming_mode) { SLOG(LOG_INFO, TAG_VCD, "[Recorder] Current audio streaming mode(%d)", streaming_mode); return VCD_ERROR_NONE; } @@ -668,7 +665,7 @@ int vcd_recorder_stop() free(g_pcm_path); g_pcm_path = NULL; } else { - ret = dependency_audio_manager_stop_recording(); + int ret = dependency_audio_manager_stop_recording(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to stop audio : %d", ret); return ret; -- 2.7.4 From c248389d0e55c08ea78fa1d3530d612be2d9b7f6 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 19 Nov 2021 20:09:42 +0900 Subject: [PATCH 11/16] Clean up and Add log into dependency audio manager Change-Id: Ic19d1d18c9737e35985db7ff80ea4b0b5c1d026b Signed-off-by: Suyeon Hwang --- audio-manager/src/vc_audio_manager.cpp | 54 ++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/audio-manager/src/vc_audio_manager.cpp b/audio-manager/src/vc_audio_manager.cpp index 79cf981..51c7a97 100644 --- a/audio-manager/src/vc_audio_manager.cpp +++ b/audio-manager/src/vc_audio_manager.cpp @@ -109,25 +109,27 @@ static Eina_Bool __recorder_timer_func(void *data) const int FRAME_LENGTH = 160; const int BUFFER_LENGTH = FRAME_LENGTH * 2; - if (g_is_recording) { - unsigned char buffer[BUFFER_LENGTH]; - memset(buffer, '\0', BUFFER_LENGTH); + if (!g_is_recording) { + VCAM_LOGD("[DEBUG] Recording is finished"); + return ECORE_CALLBACK_DONE; + } - int read_bytes = audio_in_read(g_audio_h, buffer, BUFFER_LENGTH); - if (0 > read_bytes) { - VCAM_LOGW("Fail to read audio : %d", read_bytes); - return ECORE_CALLBACK_DONE; - } + unsigned char buffer[BUFFER_LENGTH]; + memset(buffer, '\0', BUFFER_LENGTH); - // TODO: check return value? - if (nullptr != g_feed_audio_data) { - g_feed_audio_data(buffer, read_bytes); - } - } else { - VCAM_LOGD("[DEBUG] Recording is finished"); + int read_bytes = audio_in_read(g_audio_h, buffer, BUFFER_LENGTH); + if (0 > read_bytes) { + VCAM_LOGW("Fail to read audio : %d", read_bytes); return ECORE_CALLBACK_DONE; } + if (nullptr != g_feed_audio_data) { + int ret = g_feed_audio_data(buffer, read_bytes); + if (VCE_ERROR_NONE != ret) { + VCAM_LOGW("[WARN] Fail to feed audio data (%d)", ret); + } + } + return ECORE_CALLBACK_RENEW; } @@ -168,6 +170,7 @@ int vcd_dependency_initialize(sound_stream_info_h stream_info_h, dependency_audi if (AUDIO_IO_ERROR_NONE != ret) { VCAM_LOGE("[ERROR] Fail to set stream info : %d", ret); audio_in_destroy(g_audio_h); + g_audio_h = nullptr; return VCE_ERROR_OPERATION_FAILED; } @@ -207,7 +210,7 @@ int vcd_dependency_deinitialize(void) g_audio_rate = 0; g_audio_channel = 0; - return ret; + return VCE_ERROR_NONE; } int vcd_dependency_set_audio_info(sound_stream_info_h stream_info_h, const char* audio_source_type, vce_audio_type_e type, int rate, int channel) @@ -287,6 +290,7 @@ int vcd_dependency_set_streaming_mode(vc_audio_streaming_mode_e mode) return VCE_ERROR_INVALID_STATE; } + VCAM_LOGI("[INFO] Set streaming mode (%d)", mode); g_streaming_mode = mode; return VCE_ERROR_NONE; @@ -295,33 +299,32 @@ int vcd_dependency_set_streaming_mode(vc_audio_streaming_mode_e mode) int vcd_dependency_start_recording(void) { VCAM_LOGI(""); - int ret = 0; - if (nullptr == g_audio_h) { VCAM_LOGE("[ERROR] Audio in handle is not valid."); return VCE_ERROR_INVALID_STATE; } - ret = audio_in_prepare(g_audio_h); + int ret = audio_in_prepare(g_audio_h); if (AUDIO_IO_ERROR_NONE != ret) { if (AUDIO_IO_ERROR_SOUND_POLICY == ret) { VCAM_LOGE("[ERROR] Audio is busy."); - } else { - VCAM_LOGE("[ERROR] Fail to start audio : %d", ret); } - return ret; + VCAM_LOGE("[ERROR] Fail to start audio : %d", ret); + return VCE_ERROR_OPERATION_FAILED; } g_is_recording = true; /* 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); - }, NULL); + { + ecore_timer_add(0, __recorder_timer_func, NULL); + }, + NULL); - return ret; + VCAM_LOGI(""); + return VCE_ERROR_NONE; } int vcd_dependency_stop_recording(void) @@ -342,5 +345,6 @@ int vcd_dependency_stop_recording(void) return VCE_ERROR_OPERATION_FAILED; } + VCAM_LOGI(""); return VCE_ERROR_NONE; } \ No newline at end of file -- 2.7.4 From e8abf8a189817b48dcc287b6dc35aecf019f77e1 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 22 Nov 2021 19:32:13 +0900 Subject: [PATCH 12/16] [ACR-1670] Add error enum for tts operation Change-Id: Id48b92cab2b55b96f88fe4597ff46ecd0c874bad Signed-off-by: Suyeon Hwang --- include/vce.h | 3 ++- include/voice_control_common.h | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/vce.h b/include/vce.h index fab8f26..a504a94 100644 --- a/include/vce.h +++ b/include/vce.h @@ -45,7 +45,8 @@ typedef enum { VCE_ERROR_INVALID_LANGUAGE = TIZEN_ERROR_VOICE_CONTROL | 0x012, /**< Invalid language */ VCE_ERROR_OPERATION_FAILED = TIZEN_ERROR_VOICE_CONTROL | 0x014, /**< Operation failed */ VCE_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ - VCE_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_VOICE_CONTROL | 0x022 /**< Not supported feature of current engine */ + VCE_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_VOICE_CONTROL | 0x022, /**< Not supported feature of current engine */ + VCE_ERROR_TTS_FAILED = TIZEN_ERROR_VOICE_CONTROL | 0x024 /**< TTS operation failed (Since 7.0) */ } vce_error_e; /** diff --git a/include/voice_control_common.h b/include/voice_control_common.h index 136e628..400dce9 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -41,23 +41,24 @@ typedef enum { VC_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ VC_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */ VC_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */ - VC_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + VC_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ VC_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from service */ VC_ERROR_RECORDER_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Busy recorder */ - VC_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + VC_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ VC_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< VC NOT supported */ VC_ERROR_INVALID_STATE = TIZEN_ERROR_VOICE_CONTROL | 0x011, /**< Invalid state */ VC_ERROR_INVALID_LANGUAGE = TIZEN_ERROR_VOICE_CONTROL | 0x012, /**< Invalid language */ VC_ERROR_ENGINE_NOT_FOUND = TIZEN_ERROR_VOICE_CONTROL | 0x013, /**< No available engine */ VC_ERROR_OPERATION_FAILED = TIZEN_ERROR_VOICE_CONTROL | 0x014, /**< Operation failed */ - VC_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ + VC_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset (Since 3.0) */ VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In progress to ready (Since 3.0) */ VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In progress to recording (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021, /**< In progress to processing (Since 3.0) */ - VC_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_VOICE_CONTROL | 0x022 /**< Not supported feature of current engine (Since 4.0) */ + VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021, /**< In progress to processing (Since 3.0) */ + VC_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_VOICE_CONTROL | 0x022, /**< Not supported feature of current engine (Since 4.0) */ + VC_ERROR_TTS_FAILED = TIZEN_ERROR_VOICE_CONTROL | 0x024 /**< TTS operation failed (Since 7.0) */ } vc_error_e; @@ -179,7 +180,7 @@ typedef void (*vc_current_language_changed_cb)(const char* previous, const char* * followed by ISO 639-1 for the two-letter language code. * For example, "ko_KR" for Korean, "en_US" for American English * @param[in] user_data The user data passed from the foreach function - * @return @c true to continue with the next iteration of the loop, + * @return @c true to continue with the next iteration of the loop, * @c false to break out of the loop * @pre The function will invoke this callback. */ -- 2.7.4 From a981fb57fe044ac432ec9745b67a333ef6d95e22 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Thu, 9 Dec 2021 21:37:04 +0900 Subject: [PATCH 13/16] Change type of uid from signed int to unsigned int Change-Id: I4c3754d4a468afa9fa1b7091eb65a8124869ba0e --- client/vc.c | 4 ++-- client/vc_client.c | 8 ++++---- client/vc_client.h | 6 +++--- client/vc_mgr.c | 6 +++--- client/vc_mgr_client.c | 8 ++++---- client/vc_mgr_client.h | 6 +++--- client/vc_setting.c | 2 +- client/vc_widget.c | 2 +- client/vc_widget_client.c | 6 +++--- client/vc_widget_client.h | 8 ++++---- common/vc_command.c | 4 ++-- common/vc_config_mgr.c | 20 ++++++++++---------- common/vc_config_mgr.h | 16 ++++++++-------- server/vcd_server.c | 14 +++++++------- server/vcd_server_data.cpp | 4 ++-- server/vcd_server_data.h | 6 +++--- server/vce.c | 4 ++-- 17 files changed, 62 insertions(+), 62 deletions(-) diff --git a/client/vc.c b/client/vc.c index 2f21d9c..60143a2 100644 --- a/client/vc.c +++ b/client/vc.c @@ -164,8 +164,8 @@ static int __vc_check_privilege() //LCOV_EXCL_STOP } - char uid[16]; - snprintf(uid, 16, "%d", getuid()); + char uid[32]; + snprintf(uid, 32, "%d", getuid()); ret = true; ret = __check_privilege(uid, VC_PRIVILEGE); __check_privilege_deinitialize(); diff --git a/client/vc_client.c b/client/vc_client.c index c7db4cc..60194c0 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -21,7 +21,7 @@ typedef struct { /* base info */ vc_h vc; int pid; - int uid; /*<< unique id = pid + handle */ + unsigned int uid; /*<< unique id = pid + handle */ int xid; /*<< main X window id */ vc_result_cb result_cb; @@ -224,7 +224,7 @@ bool vc_client_is_valid(vc_h vc) return true; } -bool vc_client_is_valid_by_uid(int uid) +bool vc_client_is_valid_by_uid(unsigned int uid) { vc_client_s *data = NULL; @@ -246,7 +246,7 @@ bool vc_client_is_valid_by_uid(int uid) } //LCOV_EXCL_START -int vc_client_get_handle(int uid, vc_h* vc) +int vc_client_get_handle(unsigned int uid, vc_h* vc) { vc_client_s *data = NULL; @@ -473,7 +473,7 @@ int vc_client_get_client_state(vc_h vc, vc_state_e* state) return 0; } -int vc_client_get_client_state_by_uid(int uid, vc_state_e* state) +int vc_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) { vc_client_s *data = NULL; diff --git a/client/vc_client.h b/client/vc_client.h index e084fe7..7c22e2c 100644 --- a/client/vc_client.h +++ b/client/vc_client.h @@ -38,9 +38,9 @@ int vc_client_destroy(vc_h vc); bool vc_client_is_valid(vc_h vc); -bool vc_client_is_valid_by_uid(int uid); +bool vc_client_is_valid_by_uid(unsigned int uid); -int vc_client_get_handle(int uid, vc_h* vc); +int vc_client_get_handle(unsigned int uid, vc_h* vc); /* * set/get callback function @@ -77,7 +77,7 @@ int vc_client_set_client_state(vc_h vc, vc_state_e state); int vc_client_get_client_state(vc_h vc, vc_state_e* state); -int vc_client_get_client_state_by_uid(int uid, vc_state_e* state); +int vc_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state); int vc_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state); diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 5c0a44f..0c82dc8 100755 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -42,7 +42,7 @@ #include "voice_control_manager_internal.h" -#define VC_MANAGER_CONFIG_HANDLE 100000 +#define VC_MANAGER_CONFIG_HANDLE 10000000 static Ecore_Timer* g_send_hello_timer = NULL; static Ecore_Timer* g_request_init_timer = NULL; @@ -226,8 +226,8 @@ static int __vc_mgr_check_privilege() return VC_ERROR_PERMISSION_DENIED; } - char uid[16]; - snprintf(uid, 16, "%d", getuid()); + char uid[32]; + snprintf(uid, 32, "%d", getuid()); ret = true; ret = __check_privilege(uid, VC_PRIVILEGE); if (false == ret) { diff --git a/client/vc_mgr_client.c b/client/vc_mgr_client.c index 4ccb0c3..f463c48 100644 --- a/client/vc_mgr_client.c +++ b/client/vc_mgr_client.c @@ -22,7 +22,7 @@ typedef struct { /* base info */ vc_h vc; int pid; - int uid; /*<< unique id = pid + handle */ + unsigned int uid; /*<< unique id = pid + handle */ vc_mgr_all_result_cb all_result_cb; void* all_result_user_data; @@ -308,7 +308,7 @@ bool vc_mgr_client_is_valid(vc_h vc) return true; } -bool vc_mgr_client_is_valid_by_uid(int uid) +bool vc_mgr_client_is_valid_by_uid(unsigned int uid) { vc_mgr_client_s *data = NULL; @@ -329,7 +329,7 @@ bool vc_mgr_client_is_valid_by_uid(int uid) return false; } -int vc_mgr_client_get_handle(int uid, vc_h* vc) +int vc_mgr_client_get_handle(unsigned int uid, vc_h* vc) { vc_mgr_client_s *data = NULL; @@ -838,7 +838,7 @@ int vc_mgr_client_get_client_state(vc_h vc, vc_state_e* state) return 0; } -int vc_mgr_client_get_client_state_by_uid(int uid, vc_state_e* state) +int vc_mgr_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) { vc_mgr_client_s *data = NULL; diff --git a/client/vc_mgr_client.h b/client/vc_mgr_client.h index 800ba0f..dfcfde1 100644 --- a/client/vc_mgr_client.h +++ b/client/vc_mgr_client.h @@ -43,9 +43,9 @@ int vc_mgr_client_destroy(vc_h vc); bool vc_mgr_client_is_valid(vc_h vc); -bool vc_mgr_client_is_valid_by_uid(int uid); +bool vc_mgr_client_is_valid_by_uid(unsigned int uid); -int vc_mgr_client_get_handle(int uid, vc_h* vc); +int vc_mgr_client_get_handle(unsigned int uid, vc_h* vc); int vc_mgr_client_get_pid(vc_h vc, int* pid); @@ -127,7 +127,7 @@ int vc_mgr_client_set_client_state(vc_h vc, vc_state_e state); int vc_mgr_client_get_client_state(vc_h vc, vc_state_e* state); -int vc_mgr_client_get_client_state_by_uid(int uid, vc_state_e* state); +int vc_mgr_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state); int vc_mgr_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state); diff --git a/client/vc_setting.c b/client/vc_setting.c index 4a8ca0e..238480f 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -29,7 +29,7 @@ typedef enum { VC_SETTING_STATE_READY } vc_setting_state_e; -#define VC_SETTING_CONFIG_HANDLE 300000 +#define VC_SETTING_CONFIG_HANDLE 30000000 static vc_setting_state_e g_state = VC_SETTING_STATE_NONE; diff --git a/client/vc_widget.c b/client/vc_widget.c index c6dcd8a..e5e7be4 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -30,7 +30,7 @@ #include "voice_control_widget.h" -#define VC_WIDGET_CONFIG_HANDLE 200000 +#define VC_WIDGET_CONFIG_HANDLE 20000000 static Ecore_Event_Handler* g_focus_in_handler = NULL; static Ecore_Event_Handler* g_focus_out_handler = NULL; diff --git a/client/vc_widget_client.c b/client/vc_widget_client.c index 5c13f16..0907406 100644 --- a/client/vc_widget_client.c +++ b/client/vc_widget_client.c @@ -190,7 +190,7 @@ bool vc_widget_client_is_valid(vc_h vc) return true; } -bool vc_widget_client_is_valid_by_uid(int uid) +bool vc_widget_client_is_valid_by_uid(unsigned int uid) { vc_widget_s *data = NULL; @@ -215,7 +215,7 @@ bool vc_widget_client_is_valid_by_uid(int uid) return false; } -int vc_widget_client_get_handle(int uid, vc_h* vc) +int vc_widget_client_get_handle(unsigned int uid, vc_h* vc) { vc_widget_s *data = NULL; @@ -546,7 +546,7 @@ int vc_widget_client_get_state(vc_h vc, vc_state_e* state) return 0; } -int vc_widget_client_get_state_by_uid(int uid, vc_state_e* state) +int vc_widget_client_get_state_by_uid(unsigned int uid, vc_state_e* state) { vc_widget_s *data = NULL; diff --git a/client/vc_widget_client.h b/client/vc_widget_client.h index 55a44e3..5ef3a55 100644 --- a/client/vc_widget_client.h +++ b/client/vc_widget_client.h @@ -30,7 +30,7 @@ typedef struct { /* base info */ vc_h vc; int pid; - int uid; /*<< unique id = pid + handle */ + unsigned int uid; /*<< unique id = pid + handle */ int xid; /*<< main Wayland window id */ vc_result_cb result_cb; @@ -80,9 +80,9 @@ int vc_widget_client_destroy(vc_h vc); bool vc_widget_client_is_valid(vc_h vc); -bool vc_widget_client_is_valid_by_uid(int uid); +bool vc_widget_client_is_valid_by_uid(unsigned int uid); -int vc_widget_client_get_handle(int uid, vc_h* vc); +int vc_widget_client_get_handle(unsigned int uid, vc_h* vc); vc_widget_s* widget_get(vc_h vc); @@ -136,7 +136,7 @@ int vc_widget_client_set_state(vc_h vc, vc_state_e state); int vc_widget_client_get_state(vc_h vc, vc_state_e* state); -int vc_widget_client_get_state_by_uid(int uid, vc_state_e* state); +int vc_widget_client_get_state_by_uid(unsigned int uid, vc_state_e* state); int vc_widget_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state); diff --git a/common/vc_command.c b/common/vc_command.c index 25eabf9..9d7f9d6 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -157,8 +157,8 @@ static int __vc_cmd_check_privilege() return VC_ERROR_PERMISSION_DENIED; } - char uid[16]; - snprintf(uid, 16, "%d", getuid()); + char uid[32]; + snprintf(uid, 32, "%d", getuid()); ret = true; ret = __check_privilege(uid, VC_PRIVILEGE); __check_privilege_deinitialize(); diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index f1c351b..cf3bbda 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -37,7 +37,7 @@ #define BUF_LEN (EVENT_SIZE + 16) typedef struct { - int uid; + unsigned int uid; vc_config_engine_changed_cb engine_cb; vc_config_lang_changed_cb lang_cb; vc_config_enabled_cb enabled_cb; @@ -274,7 +274,7 @@ int __vc_config_mgr_select_lang(const char* engine_id, char** language) return VC_ERROR_OPERATION_FAILED; } -int __vc_config_release_client(int uid) +int __vc_config_release_client(unsigned int uid) { GSList *iter = NULL; vc_config_client_s* temp_client = NULL; @@ -828,7 +828,7 @@ void __vc_config_language_changed_cb(keynode_t *key, void *data) return; } -int vc_config_mgr_initialize(int uid) +int vc_config_mgr_initialize(unsigned int uid) { GSList *iter = NULL; int* get_uid; @@ -1044,7 +1044,7 @@ int vc_config_mgr_initialize(int uid) return 0; } -int vc_config_mgr_finalize(int uid) +int vc_config_mgr_finalize(unsigned int uid) { SLOG(LOG_INFO, vc_config_tag(), "[WARNING] Enter critical section"); @@ -1133,7 +1133,7 @@ int __vc_config_mgr_unregister_config_event() return 0; } -int vc_config_mgr_set_engine_cb(int uid, vc_config_engine_changed_cb engine_cb) +int vc_config_mgr_set_engine_cb(unsigned int uid, vc_config_engine_changed_cb engine_cb) { GSList *iter = NULL; vc_config_client_s* temp_client = NULL; @@ -1165,7 +1165,7 @@ int vc_config_mgr_set_engine_cb(int uid, vc_config_engine_changed_cb engine_cb) return 0; } -int vc_config_mgr_unset_engine_cb(int uid) +int vc_config_mgr_unset_engine_cb(unsigned int uid) { GSList *iter = NULL; vc_config_client_s* temp_client = NULL; @@ -1194,7 +1194,7 @@ int vc_config_mgr_unset_engine_cb(int uid) } -int vc_config_mgr_set_lang_cb(int uid, vc_config_lang_changed_cb lang_cb) +int vc_config_mgr_set_lang_cb(unsigned int uid, vc_config_lang_changed_cb lang_cb) { GSList *iter = NULL; vc_config_client_s* temp_client = NULL; @@ -1226,7 +1226,7 @@ int vc_config_mgr_set_lang_cb(int uid, vc_config_lang_changed_cb lang_cb) return 0; } -int vc_config_mgr_unset_lang_cb(int uid) +int vc_config_mgr_unset_lang_cb(unsigned int uid) { GSList *iter = NULL; vc_config_client_s* temp_client = NULL; @@ -1254,7 +1254,7 @@ int vc_config_mgr_unset_lang_cb(int uid) return 0; } -int vc_config_mgr_set_enabled_cb(int uid, vc_config_enabled_cb enabled_cb) +int vc_config_mgr_set_enabled_cb(unsigned int uid, vc_config_enabled_cb enabled_cb) { if (NULL == enabled_cb) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] enabled cb is NULL : uid(%d) ", uid); @@ -1286,7 +1286,7 @@ int vc_config_mgr_set_enabled_cb(int uid, vc_config_enabled_cb enabled_cb) return VC_CONFIG_ERROR_INVALID_PARAMETER; } -int vc_config_mgr_unset_enabled_cb(int uid) +int vc_config_mgr_unset_enabled_cb(unsigned int uid) { GSList *iter = NULL; vc_config_client_s* temp_client = NULL; diff --git a/common/vc_config_mgr.h b/common/vc_config_mgr.h index 647da0f..ce623d1 100644 --- a/common/vc_config_mgr.h +++ b/common/vc_config_mgr.h @@ -45,25 +45,25 @@ typedef void (*vc_config_enabled_cb)(bool enable); typedef bool (*vc_config_supported_engine_cb)(const char *engine_name, const char *engine_appid, const char *setting, const char *default_lang, bool non_fixed_support, void *user_data); -int vc_config_mgr_initialize(int uid); +int vc_config_mgr_initialize(unsigned int uid); -int vc_config_mgr_finalize(int uid); +int vc_config_mgr_finalize(unsigned int uid); /* Set / Unset callback */ -int vc_config_mgr_set_engine_cb(int uid, vc_config_engine_changed_cb engine_cb); +int vc_config_mgr_set_engine_cb(unsigned int uid, vc_config_engine_changed_cb engine_cb); -int vc_config_mgr_unset_engine_cb(int uid); +int vc_config_mgr_unset_engine_cb(unsigned int uid); -int vc_config_mgr_set_lang_cb(int uid, vc_config_lang_changed_cb lang_cb); +int vc_config_mgr_set_lang_cb(unsigned int uid, vc_config_lang_changed_cb lang_cb); -int vc_config_mgr_unset_lang_cb(int uid); +int vc_config_mgr_unset_lang_cb(unsigned int uid); -int vc_config_mgr_set_enabled_cb(int uid, vc_config_enabled_cb enabled_cb); +int vc_config_mgr_set_enabled_cb(unsigned int uid, vc_config_enabled_cb enabled_cb); -int vc_config_mgr_unset_enabled_cb(int uid); +int vc_config_mgr_unset_enabled_cb(unsigned int uid); int vc_config_mgr_get_auto_language(bool* value); diff --git a/server/vcd_server.c b/server/vcd_server.c index 486b6cb..853597c 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -45,7 +45,7 @@ static Ecore_Timer *g_check_widget_client_timer = NULL; static Ecore_Timer *g_check_client_timer = NULL; static Ecore_Thread* g_tts_thread = NULL; -static int g_current_uid = -1; +static unsigned int g_current_uid = 0; static int g_current_utt_id = -1; /** @@ -1137,7 +1137,7 @@ int vcd_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_au /* send TTS feedback audio format to VC manager */ int ret = VCD_ERROR_NONE; int pid = g_current_uid / 1000; - if (-1 == g_current_uid || vcd_client_manager_get_pid() == pid) { + if (0 == g_current_uid || vcd_client_manager_get_pid() == pid) { ret = vcdc_send_feedback_audio_format_to_manager(vcd_client_manager_get_pid(), rate, channel, audio_type); if (VCD_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send TTS feedback audio format to VC manager"); @@ -1151,7 +1151,7 @@ int vcd_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_au int vcd_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int len) { - if (-1 == g_current_uid && VCE_FEEDBACK_EVENT_START == event) { + if (0 == g_current_uid && VCE_FEEDBACK_EVENT_START == event) { g_current_utt_id = (g_current_utt_id + 1) % 1000; g_current_uid = vcd_client_manager_get_pid() * 1000 + g_current_utt_id; SLOG(LOG_INFO, TAG_VCD, "[Server info] set current uid and utt_id as manager pid(%d)", vcd_client_manager_get_pid()); @@ -1179,7 +1179,7 @@ int vcd_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int le if (VCE_FEEDBACK_EVENT_FINISH == event) { /* reset current uid */ - g_current_uid = -1; + g_current_uid = 0; /* Set service state to ready if state is synthesizing */ vcd_state_e state = vcd_config_get_service_state(); @@ -1348,7 +1348,7 @@ int vcd_initialize(vce_request_callback_s *callback) SLOG(LOG_WARN, TAG_VCD, "[Server Warning] Fail to create timer of client check"); } - g_current_uid = -1; + g_current_uid = 0; g_current_utt_id = -1; SLOG(LOG_ERROR, TAG_VCD, "[Server SUCCESS] initialize"); @@ -2684,7 +2684,7 @@ int vcd_server_request_tts(int pid, const char* text, const char* language, int return VCD_ERROR_INVALID_STATE; } - int uid = -1; + unsigned int uid = 0; g_current_utt_id = (g_current_utt_id + 1) % 1000; *utt_id = g_current_utt_id; if (0 == to_vcm) { @@ -2737,7 +2737,7 @@ int vcd_server_cancel_tts(int pid, int utt_id) vc_tts_text_data_s* tts_text_data = NULL; - int uid = pid * 1000 + utt_id; + unsigned int uid = pid * 1000 + utt_id; int ret = vcd_data_get_tts_text_data(uid, &tts_text_data); if (0 != ret) { SLOG(LOG_WARN, TAG_VCD, "[Server WARN] No data in vcd tts text queue"); diff --git a/server/vcd_server_data.cpp b/server/vcd_server_data.cpp index 6f5906e..9cf6da5 100644 --- a/server/vcd_server_data.cpp +++ b/server/vcd_server_data.cpp @@ -51,7 +51,7 @@ static int __data_show_text_list(void) return VCD_ERROR_NONE; } -int vcd_data_add_tts_text_data(int uid, vc_tts_text_data_s* data) +int vcd_data_add_tts_text_data(unsigned int uid, vc_tts_text_data_s* data) { if (NULL == data) { SLOG(LOG_ERROR, TAG_VCD, "[DATA ERROR] feedback data is NULL"); @@ -110,7 +110,7 @@ int vcd_data_clear_tts_text_data(vc_tts_text_data_s** tts_text_data) return VCD_ERROR_NONE; } -int vcd_data_get_tts_text_data(int uid, vc_tts_text_data_s** data) +int vcd_data_get_tts_text_data(unsigned int uid, vc_tts_text_data_s** data) { SLOG(LOG_INFO, TAG_VCD, "[DATA] Get tts text data : uid(%d)", uid); diff --git a/server/vcd_server_data.h b/server/vcd_server_data.h index af2f055..86e4ece 100644 --- a/server/vcd_server_data.h +++ b/server/vcd_server_data.h @@ -30,7 +30,7 @@ extern "C" { typedef struct { - int uid; + unsigned int uid; int pid; int utt_id; char* text; @@ -38,11 +38,11 @@ typedef struct { } vc_tts_text_data_s; -int vcd_data_add_tts_text_data(int uid, vc_tts_text_data_s* data); +int vcd_data_add_tts_text_data(unsigned int uid, vc_tts_text_data_s* data); int vcd_data_clear_tts_text_data(vc_tts_text_data_s** tts_text_data); -int vcd_data_get_tts_text_data(int uid, vc_tts_text_data_s** data); +int vcd_data_get_tts_text_data(unsigned int uid, vc_tts_text_data_s** data); int vcd_data_get_first_tts_text_data(vc_tts_text_data_s** data); diff --git a/server/vce.c b/server/vce.c index 970f521..5d71383 100644 --- a/server/vce.c +++ b/server/vce.c @@ -127,8 +127,8 @@ static int __vce_check_privilege() return VCE_ERROR_PERMISSION_DENIED; } - char uid[16]; - snprintf(uid, 16, "%d", getuid()); + char uid[32]; + snprintf(uid, 32, "%d", getuid()); ret = true; ret = __check_privilege(uid, VC_PRIVILEGE); __check_privilege_deinitialize(); -- 2.7.4 From e7e10aa04912a7409c6e780eb526b347443c90c7 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Thu, 9 Dec 2021 22:18:59 +0900 Subject: [PATCH 14/16] Update version to 1.65.5 Change-Id: Ie91a2bdc2fb1955f30e1b6f539f794b43edfed4b --- CMakeLists.txt | 2 +- packaging/voice-control.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfc1247..d997670 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.65.4) +SET(VERSION 1.65.5) FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 6d76313..01b059c 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.65.4 +Version: 1.65.5 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 7eefa39a5fcadd5a783e143227832cea5cb191ce Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 22 Nov 2021 19:32:57 +0900 Subject: [PATCH 15/16] Send error about tts failed to client app Change-Id: Ic7736f0f2381bc873f87da0f8d455b61ebd87d1a Signed-off-by: Suyeon Hwang --- client/vc.c | 18 ++++++++++++++++++ client/vc_client.c | 9 +++++++-- client/vc_client.h | 2 +- client/vc_dbus.c | 25 +++++++++++++++++++++++++ common/vc_defs.h | 1 + server/vcd_dbus.c | 40 ++++++++++++++++++++++++++++++++++++++++ server/vcd_dbus.h | 2 ++ server/vcd_server.c | 16 ++++++++++++---- 8 files changed, 106 insertions(+), 7 deletions(-) diff --git a/client/vc.c b/client/vc.c index 60143a2..f42cc66 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1713,6 +1713,24 @@ int __vc_cb_error(int reason, int daemon_pid, char* msg) return 0; } +int __vc_cb_error_to_app(int pid, int reason, const char* msg) +{ + SLOG(LOG_INFO, TAG_VCC, "[INFO] send error to app(%d)", pid); + + vc_h vc; + if (0 != vc_client_get_handle(pid, &vc)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get vc handle"); + return VC_ERROR_INVALID_PARAMETER; + } + + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Error reason(%d), msg(%s)", reason, msg); + + vc_client_set_error(vc, reason); + ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)vc); + + return VC_ERROR_NONE; +} + static void __vc_notify_state_changed(void *data) { vc_h vc = (vc_h)data; diff --git a/client/vc_client.c b/client/vc_client.c index 60194c0..fe116b0 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -164,6 +164,8 @@ int vc_client_create(vc_h* vc) client->is_foreground = false; client->invocation_name = NULL; + SLOG(LOG_INFO, TAG_VCC, "[INFO] client create. uid(%u)", client->uid); + g_client_list = g_slist_append(g_client_list, client); *vc = temp; @@ -246,18 +248,21 @@ bool vc_client_is_valid_by_uid(unsigned int uid) } //LCOV_EXCL_START -int vc_client_get_handle(unsigned int uid, vc_h* vc) +int vc_client_get_handle(int pid, vc_h* vc) { vc_client_s *data = NULL; int count = g_slist_length(g_client_list); int i; + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] The number of VC clients(%d)", count); + for (i = 0; i < count; i++) { data = g_slist_nth_data(g_client_list, i); if (NULL != data) { - if (uid == data->vc->handle) { + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] pid(%d), handle(%d)", pid, data->vc->handle); + if (pid == data->vc->handle) { *vc = data->vc; return 0; } diff --git a/client/vc_client.h b/client/vc_client.h index 7c22e2c..cfc8d4b 100644 --- a/client/vc_client.h +++ b/client/vc_client.h @@ -40,7 +40,7 @@ bool vc_client_is_valid(vc_h vc); bool vc_client_is_valid_by_uid(unsigned int uid); -int vc_client_get_handle(unsigned int uid, vc_h* vc); +int vc_client_get_handle(int pid, vc_h* vc); /* * set/get callback function diff --git a/client/vc_dbus.c b/client/vc_dbus.c index e41b7ef..05e5bed 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -31,6 +31,8 @@ static DBusConnection* g_conn_listener = NULL; extern int __vc_cb_error(int reason, int daemon_pid, char* msg); +extern int __vc_cb_error_to_app(int pid, int reason, char* msg); + extern void __vc_cb_result(); extern int __vc_cb_service_state(int state); @@ -163,6 +165,29 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle SLOG(LOG_DEBUG, TAG_VCC, "@@@"); } /* VCD_METHOD_ERROR */ + else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR_TO_APP)) { + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Error and send to client app"); + int pid; + int reason; + char* err_msg; + + dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INT32, &reason, + DBUS_TYPE_STRING, &err_msg, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCC, "@@ vc Get Error message : Get arguments error (%s)", err.message); + dbus_error_free(&err); + } else { + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", reason, pid, err_msg); + __vc_cb_error_to_app(pid, reason, err_msg); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + } /* VCD_METHOD_ERROR_TO_APP */ + else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_FEEDBACK_STREAMING)) { SLOG(LOG_INFO, TAG_VCC, "@@@ Get TTS feedback streaming"); int utt_id; diff --git a/common/vc_defs.h b/common/vc_defs.h index 21c2e58..121950e 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -82,6 +82,7 @@ extern "C" { #define VCD_METHOD_RESULT "vcd_method_result" #define VCD_METHOD_ERROR "vcd_method_error" +#define VCD_METHOD_ERROR_TO_APP "vcd_method_error_to_app" #define VCD_METHOD_HELLO "vcd_method_hello" #define VCD_METHOD_SET_SERVICE_STATE "vcd_method_set_service_state" #define VCD_METHOD_SEND_MANAGER_PID "vcd_method_send_manager_pid" diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 7811988..9ac4f0c 100755 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -864,6 +864,46 @@ int vcdc_send_error_signal(int reason, char *err_msg) return 0; } +int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) +{ + if (NULL == err_msg) { + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Input parameter is NULL"); + return VCD_ERROR_INVALID_PARAMETER; + } + + if (VCD_ERROR_NONE != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + + DBusError err; + dbus_error_init(&err); + + SLOG(LOG_ERROR, TAG_VCD, "@@ Send error to app(%d)", pid); + + DBusMessage* msg = __get_message(pid, VCD_METHOD_ERROR_TO_APP, VCD_CLIENT_TYPE_NORMAL); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &reason, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); + + dbus_message_set_no_reply(msg, TRUE); + + if (TRUE != dbus_connection_send(g_conn_sender, msg, NULL)) { + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); + dbus_message_unref(msg); + return VCD_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCD, "@@ Send error to app: pid(%d), reason(%d), Error Msg(%s)", pid, reason, err_msg); + dbus_connection_flush(g_conn_sender); + } + + dbus_message_unref(msg); + + return VCD_ERROR_NONE; +} + int vcdc_send_request_set_private_data(int pid, const char* key, const char* data) { if (0 != __dbus_check()) { diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h index a6d97a5..5fd1b7b 100644 --- a/server/vcd_dbus.h +++ b/server/vcd_dbus.h @@ -58,6 +58,8 @@ int vcdc_send_error_signal(int reason, char *err_msg); int vcdc_send_error_signal_to_manager(int manager_pid, int reason, char *err_msg); +int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); + int vcdc_send_service_state(vcd_state_e state); int vcdc_send_dialog(int manger_pid, int pid, const char* disp_text, const char* utt_text, int continuous); diff --git a/server/vcd_server.c b/server/vcd_server.c index 853597c..19b3950 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1114,7 +1114,14 @@ int vcd_send_error(vce_error_e error, const char* msg, void *user_data) } int ret = VCD_ERROR_NONE; - ret = vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg); + if (VCE_ERROR_TTS_FAILED == error) { + int pid = g_current_uid / 1000; + ret = vcdc_send_error_signal_to_app(pid, error, error_msg); + } else { + ret = vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg); + ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL); + } + if (VCD_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send error signal"); } @@ -1124,8 +1131,6 @@ int vcd_send_error(vce_error_e error, const char* msg, void *user_data) error_msg = NULL; } - ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL); - return ret; } @@ -2759,7 +2764,10 @@ int vcd_server_cancel_tts(int pid, int utt_id) SLOG(LOG_INFO, TAG_VCD, "[Server SUCCESS] request tts, pid(%d), utt_id(%d)", pid, utt_id); } - return 0; + /* Set service state */ + vcd_config_set_service_state(VCD_STATE_READY); + + return VCD_ERROR_NONE; } int vcd_server_get_tts_audio_format(int pid, int* rate, int* channel, int* audio_type) -- 2.7.4 From 898a61de2c08ba50ecd84be38be4542b6e53e90f Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 22 Nov 2021 19:50:37 +0900 Subject: [PATCH 16/16] Make function for get pid that requests tts play Change-Id: Ica6e6c058814f06a3e276dc65474d175a21f837a Signed-off-by: Suyeon Hwang --- server/vcd_server.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/vcd_server.c b/server/vcd_server.c index 19b3950..fbeab48 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -63,6 +63,11 @@ static int __start_internal_recognition(); /* * VC Server Internal Functions */ +static inline int __get_tts_played_pid() +{ + return g_current_uid > 0 ? g_current_uid / 1000 : 0; +} + static Eina_Bool __stop_by_silence(void *data) { SLOG(LOG_INFO, TAG_VCD, "@@@ Silence Detected "); @@ -1115,7 +1120,7 @@ int vcd_send_error(vce_error_e error, const char* msg, void *user_data) int ret = VCD_ERROR_NONE; if (VCE_ERROR_TTS_FAILED == error) { - int pid = g_current_uid / 1000; + int pid = __get_tts_played_pid(); ret = vcdc_send_error_signal_to_app(pid, error, error_msg); } else { ret = vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg); @@ -1141,8 +1146,8 @@ int vcd_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_au /* send TTS feedback audio format to VC manager */ int ret = VCD_ERROR_NONE; - int pid = g_current_uid / 1000; - if (0 == g_current_uid || vcd_client_manager_get_pid() == pid) { + int pid = __get_tts_played_pid(); + if (0 == pid || vcd_client_manager_get_pid() == pid) { ret = vcdc_send_feedback_audio_format_to_manager(vcd_client_manager_get_pid(), rate, channel, audio_type); if (VCD_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send TTS feedback audio format to VC manager"); @@ -1163,7 +1168,7 @@ int vcd_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int le } int ret = VCD_ERROR_NONE; - int pid = g_current_uid / 1000; + int pid = __get_tts_played_pid(); int utt_id = g_current_uid % 1000; SLOG(LOG_INFO, TAG_VCD, "[Server DEBUG] Engine - Send TTS feedback streaming event(%d), uid(%d), is_mgr_client(%d)", event, g_current_uid, (pid == vcd_client_manager_get_pid() ? true : false)); -- 2.7.4