From: Suyeon Hwang Date: Thu, 20 Jan 2022 02:26:47 +0000 (+0900) Subject: Rearrange code to stop all client X-Git-Tag: submit/tizen/20220325.021820~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f594d9e30f3b47959121e70ff88a86d8e86538e;p=platform%2Fcore%2Fuifw%2Ftts.git Rearrange code to stop all client Change-Id: I1395e10b466b998a6b14d4d17ccb2cf6839b20e4 Signed-off-by: Suyeon Hwang --- diff --git a/server/ttsd_player.cpp b/server/ttsd_player.cpp index 2e59bc4e..5a520c94 100644 --- a/server/ttsd_player.cpp +++ b/server/ttsd_player.cpp @@ -12,7 +12,6 @@ */ #include "ttsd_main.h" -#include "ttsd_server.h" #include "ttsd_data.h" #include "ttsd_ipc.h" #include "ttsd_player.h" @@ -546,11 +545,11 @@ int ttsd_player_all_stop() return TTSD_ERROR_OPERATION_FAILED; } - ttsd_data_foreach_clients(__stop_all_client_callback, nullptr); g_player_thread->requestStop(); + ttsd_data_foreach_clients(__stop_all_client_callback, nullptr); SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] player all stop!!"); - return 0; + return TTSD_ERROR_NONE; } int ttsd_player_get_background_volume_ratio(double* ratio) diff --git a/server/ttsd_server.c b/server/ttsd_server.c index c310737f..a1611bfe 100644 --- a/server/ttsd_server.c +++ b/server/ttsd_server.c @@ -284,25 +284,40 @@ int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int d return TTSD_ERROR_NONE; } -bool __get_client_cb(int pid, unsigned int uid, app_tts_state_e state, void* user_data) +static bool __get_client_cb(int pid, unsigned int uid, app_tts_state_e state, void* user_data) { + if (0 > ttsd_data_is_client(uid)) { + SLOG(LOG_ERROR, tts_tag(), "[Server] Client(%d) is not valid.", uid); + ttsd_data_delete_client(uid); + return true; + } + /* clear client data */ ttsd_data_clear_data(uid); if (APP_STATE_READY != state) { ttsd_data_set_client_state(uid, APP_STATE_READY); - - /* send message */ - if (0 != ttsdc_ipc_send_set_state_message(pid, uid, APP_STATE_READY)) { - /* remove client */ - ttsd_data_delete_client(uid); - } + ttsdc_ipc_send_set_state_message(pid, uid, APP_STATE_READY); } return true; } -void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_param, double double_param) +static void __stop_all_client() +{ + SLOG(LOG_INFO, tts_tag(), "[Server] Send to stop all requests"); + + ttsd_engine_cancel_synthesis(); + ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED); + + /* stop all player */ + ttsd_player_all_stop(); + + /* send interrupt message to all clients */ + ttsd_data_foreach_clients(__get_client_cb, NULL); +} + +static void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_param, double double_param) { switch (type) { case TTS_CONFIG_TYPE_ENGINE: @@ -328,14 +343,7 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_ return; } - /* stop all player */ - ttsd_player_all_stop(); - - /* send interrupt message to all clients */ - ttsd_data_foreach_clients(__get_client_cb, NULL); - - ttsd_engine_cancel_synthesis(); - + __stop_all_client(); break; } @@ -454,19 +462,6 @@ void __screen_reader_changed_cb(bool value) return; } -int ttsd_send_all_stop() -{ - SLOG(LOG_INFO, tts_tag(), "[Server] Send to stop all requests"); - - /* stop all player */ - ttsd_player_all_stop(); - - /* send interrupt message to all clients */ - ttsd_data_foreach_clients(__get_client_cb, NULL); - - return TTSD_ERROR_NONE; -} - /* * Server APIs */ diff --git a/server/ttsd_server.h b/server/ttsd_server.h index dea4c041..ee9c120a 100644 --- a/server/ttsd_server.h +++ b/server/ttsd_server.h @@ -40,7 +40,6 @@ Eina_Bool ttsd_get_daemon_exist(); int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data); int ttsd_send_error(ttse_error_e error, const char* msg); -int ttsd_send_all_stop(); int ttsd_set_private_data_set_cb(ttse_private_data_set_cb callback); int ttsd_set_private_data_requested_cb(ttse_private_data_requested_cb callback);