Fix name of function and remove unused function 66/259866/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Wed, 16 Jun 2021 05:34:19 +0000 (14:34 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Wed, 16 Jun 2021 05:34:19 +0000 (14:34 +0900)
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 <stom.hwang@samsung.com>
client/tts.c
client/tts_core.c
client/tts_core.h

index 8907354568da73c0d616faa0dd287f7f188c27d0..77405e9b515e1d5bf1b988b064ea8c2ea675b9d6 100644 (file)
@@ -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;
index 5df2cbe76f1872bc3e5cb7dd64c61d0cb2b4fcab..026b2d790100567c6526f9c840787e018febb968 100644 (file)
@@ -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)
index 81d099613422f67da7c0c17320c3e83c9c8d7d32..33a30a5502fa821ce1cd99a3b75db8f2a0c2f756 100644 (file)
@@ -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);