From 898a61de2c08ba50ecd84be38be4542b6e53e90f Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 22 Nov 2021 19:50:37 +0900 Subject: [PATCH] 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