From: Suyeon Hwang Date: Mon, 21 Dec 2020 11:47:13 +0000 (+0900) Subject: Fix loop statement from 'while' to 'for' X-Git-Tag: submit/tizen/20210628.060348~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f3d5c94bb448c8fcefb25b3c44a5ad4d7c6a49d;p=platform%2Fcore%2Fuifw%2Ftts.git Fix loop statement from 'while' to 'for' Change-Id: I2f42eb7943d6ddd2c56e75eb91eb5e913fe344d3 Signed-off-by: Suyeon Hwang --- diff --git a/client/tts_core.c b/client/tts_core.c index 77b88604..5df2cbe7 100644 --- a/client/tts_core.c +++ b/client/tts_core.c @@ -652,17 +652,15 @@ static inline int __request_add_text(tts_client_s* client, const char* text, con return TTS_ERROR_OPERATION_FAILED; } + // TODO: If use cpp, remove dupliceated code using command class pattern int uid = tts_client_get_uid(client); int ret = -1; - int count = 0; bool is_prepared = false; - while (TTS_RETRY_COUNT > count) { + for (int count = 0; count < TTS_RETRY_COUNT; count++) { ret = tts_ipc_request_add_text(uid, text, convert_language, voice_type, speed, new_utt_id, client->credential); if (false == __handle_dbus_request_result(client, ret, &is_prepared)) { break; } - - count++; } if (TTS_ERROR_NONE != ret) { @@ -679,15 +677,12 @@ static inline int __request_play(tts_client_s* client) { int uid = tts_client_get_uid(client); int ret = -1; - int count = 0; bool is_prepared = false; - while (TTS_RETRY_COUNT > count) { + for (int count = 0; count < TTS_RETRY_COUNT; count++) { ret = tts_ipc_request_play(uid, client->credential); if (false == __handle_dbus_request_result(client, ret, &is_prepared)) { break; } - - count++; } if (TTS_ERROR_NONE != ret) { @@ -699,7 +694,6 @@ static inline int __request_play(tts_client_s* client) return tts_core_set_current_state(client, TTS_STATE_PLAYING); } -/* Public functions */ int tts_core_initialize() { ecore_main_loop_thread_safe_call_async(__pkgmgr_thread, NULL); @@ -1120,7 +1114,6 @@ int tts_core_unprepare(tts_client_s* client) SLOG(LOG_INFO, TAG_TTSC, "[INFO] screen_reader(%s), mode(%d)", (true == g_is_screen_reader_on) ? "True" : "False", mode); int ret = -1; - int count = 0; if (false == g_is_screen_reader_on && TTS_MODE_SCREEN_READER == mode) { SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize : is_screen_reader(%d) mode(%d)", g_is_screen_reader_on, mode); @@ -1130,14 +1123,11 @@ int tts_core_unprepare(tts_client_s* client) } } else { bool is_prepared = false; - - while(TTS_RETRY_COUNT > count) { + for (int count = 0; count < TTS_RETRY_COUNT; count++) { ret = tts_ipc_request_finalize(uid); if (false == __handle_dbus_request_result(client, ret, &is_prepared)) { break; } - - count++; } if (TTS_ERROR_NONE == ret) { @@ -1298,16 +1288,13 @@ int tts_core_pause(tts_client_s* client) } int uid = tts_client_get_uid(client); - int ret = 0; - int count = 0; + int ret = -1; bool is_prepared = false; - while (TTS_RETRY_COUNT > count) { + for (int count = 0; count < TTS_RETRY_COUNT; count++) { ret = tts_ipc_request_pause(uid); if (false == __handle_dbus_request_result(client, ret, &is_prepared)) { break; } - - count++; } if (TTS_ERROR_NONE != ret) { @@ -1366,16 +1353,13 @@ int tts_core_add_pcm(tts_client_s* client, int event, const void* data, unsigned } int uid = tts_client_get_uid(client); - int ret = 0; - int count = 0; + int ret = -1; bool is_prepared = false; - while (TTS_RETRY_COUNT > count) { + for (int count = 0; count < TTS_RETRY_COUNT; count++) { ret = tts_ipc_request_add_pcm(uid, event, data, data_size, audio_type, rate); if (false == __handle_dbus_request_result(client, ret, &is_prepared)) { break; } - - count++; } if (TTS_ERROR_NONE != ret) { @@ -1395,16 +1379,13 @@ int tts_core_play_pcm(tts_client_s* client) } int uid = tts_client_get_uid(client); - int ret = 0; - int count = 0; + int ret = -1; bool is_prepared = false; - while (TTS_RETRY_COUNT > count) { + for (int count = 0; count < TTS_RETRY_COUNT; count++) { ret = tts_ipc_request_play_pcm(uid); if (false == __handle_dbus_request_result(client, ret, &is_prepared)) { break; } - - count++; } if (TTS_ERROR_NONE != ret) { @@ -1424,16 +1405,13 @@ int tts_core_stop_pcm(tts_client_s* client) } int uid = tts_client_get_uid(client); - int ret = 0; - int count = 0; + int ret = -1; bool is_prepared = false; - while (TTS_RETRY_COUNT > count) { + for (int count = 0; count < TTS_RETRY_COUNT; count++) { ret = tts_ipc_request_stop_pcm(uid); if (false == __handle_dbus_request_result(client, ret, &is_prepared)) { break; } - - count++; } if (TTS_ERROR_NONE != ret) { @@ -1454,15 +1432,12 @@ int tts_core_set_private_data(tts_client_s* client, const char* key, const char* int uid = tts_client_get_uid(client); int ret = -1; - int count = 0; bool is_prepared = false; - while (TTS_RETRY_COUNT > count) { + for (int count = 0; count < TTS_RETRY_COUNT; count++) { ret = tts_ipc_request_set_private_data(uid, key, data); if (false == __handle_dbus_request_result(client, ret, &is_prepared)) { break; } - - count++; } if (TTS_ERROR_NONE != ret) { @@ -1483,15 +1458,12 @@ int tts_core_get_private_data(tts_client_s* client, const char* key, char** data int uid = tts_client_get_uid(client); int ret = -1; - int count = 0; bool is_prepared = false; - while (TTS_RETRY_COUNT > count) { + for (int count = 0; count < TTS_RETRY_COUNT; count++) { ret = tts_ipc_request_get_private_data(uid, key, data); if (false == __handle_dbus_request_result(client, ret, &is_prepared)) { break; } - - count++; } if (TTS_ERROR_NONE != ret) {