From: Suyeon Hwang Date: Thu, 20 May 2021 06:08:19 +0000 (+0900) Subject: Fix ttsd_data_get_client_state() returns state value directly X-Git-Tag: submit/tizen/20220307.201852~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ca6e14046b84ea94e50f45a89602aa861533910;p=platform%2Fcore%2Fuifw%2Ftts.git Fix ttsd_data_get_client_state() returns state value directly Change-Id: I4ae4bbe95e236e2f957fa40b855b6ecd92958664 Signed-off-by: Suyeon Hwang --- diff --git a/server/ttsd_data.cpp b/server/ttsd_data.cpp index c779083b..340a8cb8 100644 --- a/server/ttsd_data.cpp +++ b/server/ttsd_data.cpp @@ -723,18 +723,16 @@ int ttsd_data_clear_data(unsigned int uid) return TTSD_ERROR_NONE; } -int ttsd_data_get_client_state(unsigned int uid, app_tts_state_e* state) +app_tts_state_e ttsd_data_get_client_state(unsigned int uid) { lock_guard lock(g_app_data_mutex); app_data_s* app_data = __get_client_app_data(uid); if (nullptr == app_data) { SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); - return TTSD_ERROR_INVALID_PARAMETER; + return APP_STATE_NONE; } - *state = app_data->state; - - return TTSD_ERROR_NONE; + return app_data->state; } static unsigned int __get_playing_app_uid() diff --git a/server/ttsd_data.h b/server/ttsd_data.h index 8c9a1b60..1cb42e33 100644 --- a/server/ttsd_data.h +++ b/server/ttsd_data.h @@ -26,6 +26,7 @@ extern "C" { typedef enum { + APP_STATE_NONE = -1, APP_STATE_CREATED = 0, APP_STATE_READY, APP_STATE_PLAYING, @@ -118,7 +119,7 @@ int ttsd_data_set_used_voice(unsigned int uid, const char* lang, int type); int ttsd_data_reset_used_voice(unsigned int uid, ttsd_used_voice_cb callback); -int ttsd_data_get_client_state(unsigned int uid, app_tts_state_e* state); +app_tts_state_e ttsd_data_get_client_state(unsigned int uid); int ttsd_data_set_client_state(unsigned int uid, app_tts_state_e state); diff --git a/server/ttsd_player.cpp b/server/ttsd_player.cpp index cf84d6a7..657a4ff9 100644 --- a/server/ttsd_player.cpp +++ b/server/ttsd_player.cpp @@ -1005,8 +1005,8 @@ int ttsd_player_all_stop() /* Get handle data from list */ data = (player_s*)iter->data; - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(data->uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(data->uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[player ERROR] uid(%u) is not valid", data->uid); iter = g_list_next(iter); diff --git a/server/ttsd_server.c b/server/ttsd_server.c index 715b9fe3..7e428904 100644 --- a/server/ttsd_server.c +++ b/server/ttsd_server.c @@ -222,8 +222,8 @@ int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int d } /* check the current state */ - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE); SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid is not valid"); return TTSD_ERROR_INVALID_PARAMETER; @@ -784,8 +784,7 @@ int ttsd_server_finalize(unsigned int uid) SLOG(LOG_INFO, tts_tag(), "[Server] Server finalize"); SLOG(LOG_INFO, tts_tag(), "[Server] File num(%d), Avg Latency(%lf), Min(%lf), Max(%lf)", g_file_num, (g_avg_latency / (double)g_file_num), g_min_latency, g_max_latency); - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + if (0 > ttsd_data_is_client(uid)) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_finalize : uid is not valid"); } @@ -817,8 +816,8 @@ int ttsd_server_finalize(unsigned int uid) int ttsd_server_set_mode(unsigned int uid, ttsd_mode_e mode) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid(%u) is NOT valid", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -860,8 +859,8 @@ static bool __is_connected_to_network() int ttsd_server_add_queue(unsigned int uid, const char* text, const char* lang, int voice_type, int speed, int utt_id, const char* credential) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_add_queue : uid is not valid"); return TTSD_ERROR_INVALID_PARAMETER; } @@ -975,9 +974,8 @@ void __send_interrupt_client(unsigned int uid) return; } - app_tts_state_e state = APP_STATE_CREATED; - - if (0 != ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get state. uid(%u), pid(%d)", uid, pid); return; } @@ -989,8 +987,8 @@ void __send_interrupt_client(unsigned int uid) int ttsd_server_play(unsigned int uid, const char* credential) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid(%u) is NOT valid", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1085,8 +1083,8 @@ int ttsd_server_play(unsigned int uid, const char* credential) int ttsd_server_stop(unsigned int uid) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid is not valid"); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1121,8 +1119,8 @@ int ttsd_server_stop(unsigned int uid) int ttsd_server_pause(unsigned int uid, int* utt_id) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_pause : uid is not valid"); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1148,8 +1146,7 @@ int ttsd_server_pause(unsigned int uid, int* utt_id) int ttsd_server_get_support_voices(unsigned int uid, GList** voice_list) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + if (0 > ttsd_data_is_client(uid)) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid is not valid"); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1168,8 +1165,7 @@ int ttsd_server_get_support_voices(unsigned int uid, GList** voice_list) int ttsd_server_get_current_voice(unsigned int uid, char** language, int* voice_type) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + if (0 > ttsd_data_is_client(uid)) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_get_current_voice : uid is not valid"); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1188,8 +1184,8 @@ int ttsd_server_get_current_voice(unsigned int uid, char** language, int* voice_ int ttsd_server_set_private_data(unsigned int uid, const char* key, const char* data) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid(%u) is NOT valid", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1211,8 +1207,8 @@ int ttsd_server_set_private_data(unsigned int uid, const char* key, const char* int ttsd_server_get_private_data(unsigned int uid, const char* key, char** data) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid(%u) is NOT valid", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1260,8 +1256,8 @@ int ttsd_set_private_data_requested_cb(ttse_private_data_requested_cb callback) int ttsd_server_play_pcm(unsigned int uid) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid(%u) is NOT valid", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1325,8 +1321,8 @@ int ttsd_server_play_pcm(unsigned int uid) int ttsd_server_stop_pcm(unsigned int uid) { - app_tts_state_e state; - if (0 > ttsd_data_get_client_state(uid, &state)) { + app_tts_state_e state = ttsd_data_get_client_state(uid); + if (APP_STATE_NONE == state) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid is not valid"); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1342,7 +1338,6 @@ int ttsd_server_stop_pcm(unsigned int uid) ttsd_player_stop(uid); - return TTSD_ERROR_NONE; }