From: Suyeon Hwang Date: Wed, 16 Jun 2021 05:34:19 +0000 (+0900) Subject: Fix name of function and remove unused function X-Git-Tag: submit/tizen/20210628.060348~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dfde1c62cfbfd8ccff789a89e8033af044bd27bd;p=platform%2Fcore%2Fuifw%2Ftts.git Fix name of function and remove unused function This patch reflects the review content of https://review.tizen.org/gerrit/c/platform/core/uifw/tts/+/257109 To remove ambiguous function name 'tts_core_set_current_state()', this patch remove unused function 'tts_core_notify_state_changed()' and reuse this name. 'tts_core_set_current_state()' invokes the state changed callback, so I think using verbe 'notify' gives more clear meaning. Change-Id: I126fdd646ae435788797a9a60cb777ef3a4df3ca Signed-off-by: Suyeon Hwang --- diff --git a/client/tts.c b/client/tts.c index 89073545..77405e9b 100644 --- a/client/tts.c +++ b/client/tts.c @@ -649,7 +649,7 @@ int tts_unprepare(tts_h tts) return ret; } - tts_core_set_current_state(client, TTS_STATE_CREATED); + tts_core_notify_state_changed(client, TTS_STATE_CREATED); SLOG(LOG_DEBUG, TAG_TTSC, "@@@"); return TTS_ERROR_NONE; diff --git a/client/tts_core.c b/client/tts_core.c index 5df2cbe7..026b2d79 100644 --- a/client/tts_core.c +++ b/client/tts_core.c @@ -560,7 +560,7 @@ static Eina_Bool __prepare_sync_cb(tts_client_s* client) } // TODO: make function duplicated block - tts_core_set_current_state(client, TTS_STATE_READY); + tts_core_notify_state_changed(client, TTS_STATE_READY); SLOG(LOG_DEBUG, TAG_TTSC, "@@@"); return EINA_FALSE; @@ -691,7 +691,7 @@ static inline int __request_play(tts_client_s* client) } SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_dbus_request_play"); - return tts_core_set_current_state(client, TTS_STATE_PLAYING); + return tts_core_notify_state_changed(client, TTS_STATE_PLAYING); } int tts_core_initialize() @@ -749,13 +749,21 @@ int tts_core_deinitialize() return TTS_ERROR_NONE; } -int tts_core_notify_state_changed(tts_client_s* client, tts_state_e before_state, tts_state_e current_state) +int tts_core_notify_state_changed(tts_client_s* client, tts_state_e current_state) { if (false == tts_client_is_valid_client(client)) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid."); + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is invalid."); return TTS_ERROR_INVALID_PARAMETER; } + tts_state_e before_state = tts_client_get_current_state(client); + if (before_state == current_state) { + SLOG(LOG_INFO, TAG_TTSC, "[INFO] State is not changed. before(%s), current(%s)", __convert_state(before_state), __convert_state(current_state)); + return TTS_ERROR_NONE; + } + + SLOG(LOG_DEBUG, TAG_TTSC, "State changed to (%s).", __convert_state(current_state)); + tts_client_set_current_state(client, current_state); __client_state_changed_cb(client, before_state, current_state); return TTS_ERROR_NONE; @@ -897,26 +905,6 @@ int tts_core_notify_engine_changed(tts_client_s* client, const char* engine_id, return TTS_ERROR_NONE; } -int tts_core_set_current_state(tts_client_s* client, tts_state_e state) -{ - if (false == tts_client_is_valid_client(client)) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is invalid."); - return TTS_ERROR_INVALID_PARAMETER; - } - - tts_state_e before_state = tts_client_get_current_state(client); - if (before_state == state) { - SLOG(LOG_INFO, TAG_TTSC, "[INFO] State is not changed. before(%s), current(%s)", __convert_state(before_state), __convert_state(state)); - return TTS_ERROR_NONE; - } - - SLOG(LOG_DEBUG, TAG_TTSC, "State changed to (%s).", __convert_state(state)); - tts_client_set_current_state(client, state); - __client_state_changed_cb(client, before_state, state); - - return TTS_ERROR_NONE; -} - int tts_core_set_mode(tts_client_s* client, tts_mode_e mode) { if (false == tts_client_is_valid_client(client)) { @@ -1277,7 +1265,7 @@ int tts_core_stop(tts_client_s* client) return ret; } - return tts_core_set_current_state(client, TTS_STATE_READY); + return tts_core_notify_state_changed(client, TTS_STATE_READY); } int tts_core_pause(tts_client_s* client) @@ -1303,7 +1291,7 @@ int tts_core_pause(tts_client_s* client) } SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_dbus_request_pause"); - return tts_core_set_current_state(client, TTS_STATE_PAUSED); + return tts_core_notify_state_changed(client, TTS_STATE_PAUSED); } int tts_core_repeat(tts_client_s* client, char** text_repeat, int* utt_id) @@ -1394,7 +1382,7 @@ int tts_core_play_pcm(tts_client_s* client) } SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_dbus_request_play_pcm"); - return tts_core_set_current_state(client, TTS_STATE_PLAYING); + return tts_core_notify_state_changed(client, TTS_STATE_PLAYING); } int tts_core_stop_pcm(tts_client_s* client) @@ -1420,7 +1408,7 @@ int tts_core_stop_pcm(tts_client_s* client) } SLOG(LOG_INFO, TAG_TTSC, "[INFO] Success tts_dbus_request_stop_pcm"); - return tts_core_set_current_state(client, TTS_STATE_READY); + return tts_core_notify_state_changed(client, TTS_STATE_READY); } int tts_core_set_private_data(tts_client_s* client, const char* key, const char* data) diff --git a/client/tts_core.h b/client/tts_core.h index 81d09961..33a30a55 100644 --- a/client/tts_core.h +++ b/client/tts_core.h @@ -22,7 +22,7 @@ extern "C" { #include "tts_client.h" // common function -int tts_core_notify_state_changed(tts_client_s* client, tts_state_e before_state, tts_state_e current_state); +int tts_core_notify_state_changed(tts_client_s* client, tts_state_e current_state); int tts_core_notify_state_changed_async(tts_client_s* client, tts_state_e before_state, tts_state_e current_state); int tts_core_notify_utt_started(tts_client_s* client, int utt_id); int tts_core_notify_utt_completeted(tts_client_s* client, int utt_id); @@ -30,7 +30,6 @@ int tts_core_notify_error_async(tts_client_s* client, tts_error_e reason, int ut int tts_core_notify_default_voice_changed(tts_client_s* client, const char* before_lang, int before_voice_type, const char* language, int voice_type); int tts_core_notify_engine_changed(tts_client_s* client, const char* engine_id, const char* language, int voice_type, bool need_credential); -int tts_core_set_current_state(tts_client_s* client, tts_state_e state); int tts_core_set_mode(tts_client_s* client, tts_mode_e mode); bool tts_core_is_valid_text(const char* text);