Merge "Add error type for converting string" into tizen
authorWonnam Jang <wn.jang@samsung.com>
Tue, 2 Aug 2022 01:27:38 +0000 (01:27 +0000)
committerGerrit Code Review <gerrit@review>
Tue, 2 Aug 2022 01:27:38 +0000 (01:27 +0000)
12 files changed:
client/tts.c
client/tts_client.c
client/tts_client.h
client/tts_core.c
client/tts_core.h
client/tts_ipc.c
client/tts_ipc.h
client/tts_tidl.c
server/ttsd_server.c
server/ttsd_tidl.c
tests/org.tizen.tts-unittests.xml
tests/src/tts_unittests.cpp

index 9ce0353..21469fa 100644 (file)
@@ -38,29 +38,27 @@ static int g_feature_enabled = -1;
 
 static int __tts_get_feature_enabled()
 {
-       if (0 == g_feature_enabled) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS feature NOT supported");
+       RETV_IF(1 == g_feature_enabled, TTS_ERROR_NONE);
+       RETVM_IF(0 == g_feature_enabled, TTS_ERROR_NOT_SUPPORTED, "[ERROR] TTS feature NOT supported");
+
+       bool tts_supported = false;
+       if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get feature value");
                return TTS_ERROR_NOT_SUPPORTED;
-       } else if (-1 == g_feature_enabled) {
-               bool tts_supported = false;
-               if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
-                       if (false == tts_supported) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS feature NOT supported");
-                               g_feature_enabled = 0;
-                               return TTS_ERROR_NOT_SUPPORTED;
-                       }
+       }
 
-                       g_feature_enabled = 1;
-               } else {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get feature value");
-                       return TTS_ERROR_NOT_SUPPORTED;
-               }
+       if (false == tts_supported) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS feature NOT supported");
+               g_feature_enabled = 0;
+               return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       return 0;
+       g_feature_enabled = 1;
+       return TTS_ERROR_NONE;
 }
 
 // TODO: move into tts_core to make common function
+//LCOV_EXCL_START
 static int __tts_convert_config_error_code(tts_config_error_e code)
 {
        if (code == TTS_CONFIG_ERROR_NONE)                      return TTS_ERROR_NONE;
@@ -76,7 +74,6 @@ static int __tts_convert_config_error_code(tts_config_error_e code)
        return code;
 }
 
-//LCOV_EXCL_START
 static void __tts_config_voice_changed_cb(const char* before_lang, int before_voice_type, const char* language, int voice_type, bool auto_voice, void* user_data)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "Voice changed : Before lang(%s) type(%d) , Current lang(%s), type(%d)",
@@ -184,6 +181,7 @@ static void __tts_config_engine_changed_cb(const char* engine_id, const char* se
        tts_core_notify_engine_changed(client, engine_id, language, voice_type, need_credential);
        return;
 }
+//LCOV_EXCL_STOP
 
 static void __tts_config_screen_reader_changed_cb(bool value, void* user_data)
 {
@@ -198,13 +196,34 @@ static void __tts_config_screen_reader_changed_cb(bool value, void* user_data)
        tts_core_notify_screen_reader_changed(client, value);
 }
 
-//LCOV_EXCL_STOP
+static int __initialize_tts_config(unsigned int uid, tts_h new_tts)
+{
+       int ret = tts_config_mgr_initialize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
+       if (TTS_CONFIG_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to init config manager : %d", ret);
+               return __tts_convert_config_error_code(ret);
+       }
+
+       ret = tts_config_mgr_set_callback(uid, __tts_config_engine_changed_cb, __tts_config_voice_changed_cb, NULL, NULL, NULL, new_tts);
+       if (TTS_CONFIG_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
+               tts_config_mgr_finalize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
+               return __tts_convert_config_error_code(ret);
+       }
+
+       ret = tts_config_mgr_set_screen_reader_callback(uid, __tts_config_screen_reader_changed_cb, new_tts);
+       if (TTS_CONFIG_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
+               tts_config_mgr_finalize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
+               return __tts_convert_config_error_code(ret);
+       }
+
+       return TTS_ERROR_NONE;
+}
 
 int tts_create(tts_h* tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Create TTS");
 
@@ -255,27 +274,11 @@ int tts_create(tts_h* tts)
                return TTS_ERROR_OPERATION_FAILED;
        }
 
-       int ret = tts_config_mgr_initialize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
-       if (0 != ret) {
+       int ret = __initialize_tts_config(uid, new_tts);
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to init config manager : %d", ret);
                tts_client_destroy(new_tts);
-               return __tts_convert_config_error_code(ret);
-       }
-
-       ret = tts_config_mgr_set_callback(uid, __tts_config_engine_changed_cb, __tts_config_voice_changed_cb, NULL, NULL, NULL, new_tts);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
-               tts_config_mgr_finalize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
-               tts_client_destroy(new_tts);
-               return __tts_convert_config_error_code(ret);
-       }
-
-       ret = tts_config_mgr_set_screen_reader_callback(uid, __tts_config_screen_reader_changed_cb, new_tts);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
-               tts_config_mgr_finalize(uid, TTS_CONFIG_CLIENT_TYPE_DEFAULT);
-               tts_client_destroy(new_tts);
-               return __tts_convert_config_error_code(ret);
+               return ret;
        }
 
        if (is_first_client) {
@@ -295,9 +298,7 @@ int tts_create(tts_h* tts)
 
 int tts_destroy(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Destroy TTS");
 
@@ -375,9 +376,7 @@ int tts_destroy(tts_h tts)
 
 int tts_set_mode(tts_h tts, tts_mode_e mode)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Set TTS mode(%d)", mode);
 
@@ -397,9 +396,7 @@ int tts_set_mode(tts_h tts, tts_mode_e mode)
 
 int tts_get_mode(tts_h tts, tts_mode_e* mode)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Get TTS mode");
 
@@ -419,9 +416,7 @@ int tts_get_mode(tts_h tts, tts_mode_e* mode)
 
 int tts_set_credential(tts_h tts, const char* credential)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        RETVM_IF(NULL == credential, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is null");
 
@@ -437,12 +432,9 @@ int tts_set_credential(tts_h tts, const char* credential)
        return TTS_ERROR_NONE;
 }
 
-//LCOV_EXCL_START
 int tts_set_server_tts(tts_h tts, const char* credential)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -492,13 +484,10 @@ int tts_set_server_tts(tts_h tts, const char* credential)
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
        return TTS_ERROR_NONE;
 }
-// LCOV_EXCL_STOP
 
 int tts_prepare(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -519,9 +508,7 @@ int tts_prepare(tts_h tts)
 
 int tts_prepare_sync(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -542,9 +529,7 @@ int tts_prepare_sync(tts_h tts)
 
 int tts_unprepare(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -567,9 +552,7 @@ int tts_unprepare(tts_h tts)
 
 int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, void* user_data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Foreach supported voices");
 
@@ -600,9 +583,7 @@ int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, voi
 
 int tts_get_default_voice(tts_h tts, char** lang, int* vctype)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Get default voice");
 
@@ -626,9 +607,7 @@ int tts_get_default_voice(tts_h tts, char** lang, int* vctype)
 
 int tts_get_max_text_size(tts_h tts, unsigned int* size)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        RETVM_IF(NULL == size, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Get max text count : Input parameter is null");
 
@@ -650,9 +629,7 @@ int tts_get_max_text_size(tts_h tts, unsigned int* size)
 
 int tts_get_state(tts_h tts, tts_state_e* state)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        RETVM_IF(NULL == state, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Get state : Input parameter is null");
 
@@ -676,9 +653,7 @@ int tts_get_state(tts_h tts, tts_state_e* state)
 
 int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        RETVM_IF(NULL == min || NULL == normal || NULL == max, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is null");
 
@@ -694,9 +669,7 @@ int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max)
 
 int tts_get_error_message(tts_h tts, char** err_msg)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        RETVM_IF(NULL == err_msg, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is null");
 
@@ -718,9 +691,7 @@ int tts_get_error_message(tts_h tts, char** err_msg)
 
 int tts_check_screen_reader_on(tts_h tts, bool* is_on)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        RETVM_IF(NULL == is_on, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is null");
 
@@ -740,9 +711,7 @@ int tts_check_screen_reader_on(tts_h tts, bool* is_on)
 
 int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Add text: text(%s), language(%s), type(%d)", (NULL == text) ? "NULL" : text, (NULL == language) ? "NULL" : language, voice_type);
 
@@ -791,9 +760,7 @@ static void __tts_play_async(void *data)
 
 int tts_play_async(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Play asynchronously tts");
 
@@ -815,9 +782,7 @@ int tts_play_async(tts_h tts)
 
 int tts_play(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Play tts");
 
@@ -861,9 +826,7 @@ static void __tts_stop_async(void *data)
 
 int tts_stop_aync(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Stop asynchronously tts");
 
@@ -884,9 +847,7 @@ int tts_stop_aync(tts_h tts)
 
 int tts_stop(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Stop tts");
 
@@ -907,8 +868,8 @@ int tts_stop(tts_h tts)
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
        return TTS_ERROR_NONE;
 }
-//LCOV_EXCL_START
 
+//LCOV_EXCL_START
 static void __tts_pause_async(void *data)
 {
        tts_h tts = (tts_h)data;
@@ -929,9 +890,7 @@ static void __tts_pause_async(void *data)
 
 int tts_pause_async(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Pause asynchronously tts");
 
@@ -951,9 +910,7 @@ int tts_pause_async(tts_h tts)
 //LCOV_EXCL_STOP
 int tts_pause(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Pause tts");
 
@@ -977,9 +934,7 @@ int tts_pause(tts_h tts)
 
 int tts_set_private_data(tts_h tts, const char* key, const char* data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Set private data, key(%s), data(%s)", key, data);
 
@@ -1008,9 +963,7 @@ int tts_set_private_data(tts_h tts, const char* key, const char* data)
 
 int tts_get_private_data(tts_h tts, const char* key, char** data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Get private data, key(%s)", key);
 
@@ -1034,9 +987,7 @@ int tts_get_private_data(tts_h tts, const char* key, char** data)
 
 int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1054,9 +1005,7 @@ int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* use
 
 int tts_unset_state_changed_cb(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1072,9 +1021,7 @@ int tts_unset_state_changed_cb(tts_h tts)
 
 int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, void* user_data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1093,9 +1040,7 @@ int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, v
 
 int tts_unset_utterance_started_cb(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1112,9 +1057,7 @@ int tts_unset_utterance_started_cb(tts_h tts)
 
 int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callback, void* user_data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1133,9 +1076,7 @@ int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callbac
 
 int tts_unset_utterance_completed_cb(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1151,9 +1092,7 @@ int tts_unset_utterance_completed_cb(tts_h tts)
 
 int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1172,9 +1111,7 @@ int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data)
 
 int tts_unset_error_cb(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1191,9 +1128,7 @@ int tts_unset_error_cb(tts_h tts)
 
 int tts_set_default_voice_changed_cb(tts_h tts, tts_default_voice_changed_cb callback, void* user_data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1212,9 +1147,7 @@ int tts_set_default_voice_changed_cb(tts_h tts, tts_default_voice_changed_cb cal
 
 int tts_unset_default_voice_changed_cb(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1231,9 +1164,7 @@ int tts_unset_default_voice_changed_cb(tts_h tts)
 
 int tts_set_engine_changed_cb(tts_h tts, tts_engine_changed_cb callback, void* user_data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1252,9 +1183,7 @@ int tts_set_engine_changed_cb(tts_h tts, tts_engine_changed_cb callback, void* u
 
 int tts_unset_engine_changed_cb(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1271,9 +1200,7 @@ int tts_unset_engine_changed_cb(tts_h tts)
 
 int tts_set_screen_reader_changed_cb(tts_h tts, tts_screen_reader_changed_cb callback, void* user_data)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1292,9 +1219,7 @@ int tts_set_screen_reader_changed_cb(tts_h tts, tts_screen_reader_changed_cb cal
 
 int tts_unset_screen_reader_changed_cb(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        tts_client_s* client = tts_client_get(tts);
        RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
@@ -1309,13 +1234,9 @@ int tts_unset_screen_reader_changed_cb(tts_h tts)
        return 0;
 }
 
-
-//LCOV_EXCL_START
 int tts_add_pcm(tts_h tts, int event, const void* data, unsigned int data_size, int audio_type, int rate)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Add pcm tts");
 
@@ -1339,9 +1260,7 @@ int tts_add_pcm(tts_h tts, int event, const void* data, unsigned int data_size,
 
 int tts_play_pcm(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Play pcm tts");
 
@@ -1365,9 +1284,7 @@ int tts_play_pcm(tts_h tts)
 
 int tts_stop_pcm(tts_h tts)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Stop pcm tts");
 
@@ -1388,13 +1305,10 @@ int tts_stop_pcm(tts_h tts)
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
        return TTS_ERROR_NONE;
 }
-//LCOV_EXCL_STOP
 
 int tts_repeat(tts_h tts, char** text_repeat, int* utt_id)
 {
-       if (0 != __tts_get_feature_enabled()) {
-               return TTS_ERROR_NOT_SUPPORTED;
-       }
+       RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Repeat TTS");
 
index 7fa9678..ee974f9 100644 (file)
@@ -318,57 +318,6 @@ int tts_client_get_use_callback(tts_client_s* client)
        return client->cb_ref_count;
 }
 
-//LCOV_EXCL_START
-int tts_client_get_connected_client_count()
-{
-       GList *iter = NULL;
-       tts_client_s *data = NULL;
-       int number = 0;
-
-       pthread_mutex_lock(&g_client_list_mutex);
-       if (g_list_length(g_client_list) > 0) {
-               /* Get a first item */
-               iter = g_list_first(g_client_list);
-
-               while (NULL != iter) {
-                       data = iter->data;
-                       if (0 < data->current_state) {
-                               number++;
-                       }
-
-                       /* Next item */
-                       iter = g_list_next(iter);
-               }
-       }
-       pthread_mutex_unlock(&g_client_list_mutex);
-       return number;
-}
-
-int tts_client_get_mode_client_count(tts_mode_e mode)
-{
-       GList *iter = NULL;
-       tts_client_s *data = NULL;
-       int number = 0;
-
-       pthread_mutex_lock(&g_client_list_mutex);
-       if (g_list_length(g_client_list) > 0) {
-               /* Get a first item */
-               iter = g_list_first(g_client_list);
-
-               while (NULL != iter) {
-                       data = iter->data;
-                       if (0 < data->current_state && data->mode == mode) {
-                               number++;
-                       }
-
-                       /* Next item */
-                       iter = g_list_next(iter);
-               }
-       }
-       pthread_mutex_unlock(&g_client_list_mutex);
-       return number;
-}
-
 GList* tts_client_get_client_list()
 {
        GList* copy_list = NULL;
@@ -378,7 +327,6 @@ GList* tts_client_get_client_list()
 
        return copy_list;
 }
-//LCOV_EXCL_STOP
 
 unsigned int tts_client_get_uid(tts_client_s* client)
 {
@@ -695,6 +643,7 @@ void* tts_client_get_error_user_data(tts_client_s* client)
        return client->error_user_data;
 }
 
+//LCOV_EXCL_START
 tts_default_voice_changed_cb tts_client_get_default_voice_changed_cb(tts_client_s* client)
 {
        if (false == tts_client_is_valid_client(client)) {
@@ -726,6 +675,7 @@ void* tts_client_get_engine_changed_user_data(tts_client_s* client)
        }
        return client->engine_changed_user_data;
 }
+//LCOV_EXCL_STOP
 
 tts_screen_reader_changed_cb tts_client_get_screen_reader_changed_cb(tts_client_s* client)
 {
index 32e05d5..59a74bb 100644 (file)
@@ -103,10 +103,6 @@ int tts_client_not_use_callback(tts_client_s* client);
 
 int tts_client_get_use_callback(tts_client_s* client);
 
-int tts_client_get_connected_client_count();
-
-int tts_client_get_mode_client_count(tts_mode_e mode);
-
 GList* tts_client_get_client_list();
 
 unsigned int tts_client_get_uid(tts_client_s* client);
index 3ae236c..fdc8ece 100644 (file)
@@ -22,6 +22,7 @@
 #include "tts_defs.h"
 #include "tts_core.h"
 #include "tts_ipc.h"
+#include "tts_dlog.h"
 
 
 static const int TTS_ERROR_FAIL_TO_SEND_HELLO = TIZEN_ERROR_TTS | 0xFF;
@@ -77,10 +78,7 @@ static char* __get_engine_appid() {
 static int __update_engine_name()
 {
        char* new_engine_name = vconf_get_str(TTS_ENGINE_DB_DEFAULT);
-       if (NULL == new_engine_name) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get engine name");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(NULL == new_engine_name, TTS_ERROR_OPERATION_FAILED, "[ERROR] Fail to get engine name");
 
        if (NULL != g_engine_name && 0 == strncmp(g_engine_name, new_engine_name, TTS_ENGINE_APPID_LEN)) {
                SLOG(LOG_INFO, TAG_TTSC, "[INFO] engine name is same");
@@ -130,12 +128,10 @@ static Eina_Bool __notify_error_timer_cb(void *data)
 {
        unsigned int uid = (uintptr_t)data;
        tts_client_s* client = tts_client_get_by_uid(uid);
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] UID is not valid. (%u)", uid);
-       } else {
-               __client_error_cb(client, client->utt_id, client->reason);
-               client->notify_error_timer = NULL;
-       }
+       RETVM_IF(NULL == client, EINA_FALSE, "[ERROR] uid(%u) is not valid.", uid);
+
+       __client_error_cb(client, client->utt_id, client->reason);
+       client->notify_error_timer = NULL;
 
        return EINA_FALSE;
 }
@@ -187,6 +183,7 @@ static bool __is_engine_launched()
        return is_running;
 }
 
+//LCOV_EXCL_START
 static int __pkgmgr_status_cb(uid_t target_uid, int req_id, const char *type, const char *pkgname, const char *key, const char *val, const void *pmsg, void *data)
 {
        // type (the type of the pkgname)
@@ -236,6 +233,7 @@ static int __pkgmgr_status_cb(uid_t target_uid, int req_id, const char *type, co
 
        return 0;
 }
+//LCOV_EXCL_STOP
 
 static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread)
 {
@@ -290,12 +288,14 @@ static void __finish_pkgmgr_thread(void* data, Ecore_Thread* thread)
        g_pkgmgr_thread = NULL;
 }
 
+//LCOV_EXCL_START
 static void __cancel_pkgmgr_thread(void* data, Ecore_Thread* thread)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[DEBUG] Cancel pkgmgr thread");
        g_is_thread_canceled = false;
        g_pkgmgr_thread = NULL;
 }
+//LCOV_EXCL_STOP
 
 static void __pkgmgr_thread(void* data)
 {
@@ -308,6 +308,7 @@ static void __pkgmgr_thread(void* data)
        return;
 }
 
+//LCOV_EXCL_START
 static void __start_reprepare_thread(void* data, Ecore_Thread* thread)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[DEBUG] start reprepare thread. engine update status(%d)", g_engine_update_status);
@@ -349,6 +350,7 @@ static void __start_reprepare_thread(void* data, Ecore_Thread* thread)
 
        return;
 }
+//LCOV_EXCL_STOP
 
 static void __end_reprepare_thread(void* data, Ecore_Thread* thread)
 {
@@ -381,12 +383,14 @@ static void __end_reprepare_thread(void* data, Ecore_Thread* thread)
        g_reprepare_thread = NULL;
 }
 
+//LCOV_EXCL_START
 static void __cancel_reprepare_thread(void* data, Ecore_Thread* thread)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[INFO] cancel reprepare thread");
        g_is_engine_name_changed = false;
        g_reprepare_thread = NULL;
 }
+//LCOV_EXCL_STOP
 
 static inline void __run_client_reprepare_thread()
 {
@@ -440,10 +444,7 @@ static Eina_Bool __prepare_cb(void *data)
 {
        unsigned int uid = (uintptr_t)data;
        tts_client_s* client = tts_client_get_by_uid(uid);
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return EINA_FALSE;
-       }
+       RETVM_IF(NULL == client, EINA_FALSE, "[ERROR] uid(%u) is not valid.", uid);
 
        int ret = __send_hello_msg(client);
        if (ret != TTS_ERROR_NONE) {
@@ -474,10 +475,7 @@ static Eina_Bool __prepare_first_cb(void *data)
        /* send first hello message */
        unsigned int uid = (uintptr_t)data;
        tts_client_s* client = tts_client_get_by_uid(uid);
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return EINA_FALSE;
-       }
+       RETVM_IF(NULL == client, EINA_FALSE, "[ERROR] uid(%u) is not valid.", uid);
 
        int ret = __send_hello_msg(client);
        if (ret != TTS_ERROR_NONE) {
@@ -553,10 +551,7 @@ static bool __supported_voice_cb(const char* engine_id, const char* language, in
 {
        unsigned int uid = (uintptr_t)user_data;
        tts_client_s* client = tts_client_get_by_uid(uid);
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Uid is not valid. (%d)", uid);
-               return false;
-       }
+       RETVM_IF(NULL == client, false, "[ERROR] uid(%u) is not valid.", uid);
 
        /* call callback function */
        tts_supported_voice_cb callback = tts_client_get_supported_voice_cb(client);
@@ -721,10 +716,7 @@ int tts_core_deinitialize()
 
 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] Client is invalid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        tts_state_e before_state = tts_client_get_current_state(client);
        if (before_state == current_state) {
@@ -741,10 +733,7 @@ int tts_core_notify_state_changed(tts_client_s* client, tts_state_e current_stat
 
 int tts_core_notify_utt_started(tts_client_s* client, int utt_id)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        client->utt_id = utt_id;
        SLOG(LOG_DEBUG, TAG_TTSC, "Utterance started data : utt_id(%d)", client->utt_id);
@@ -766,10 +755,7 @@ 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)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        client->utt_id = utt_id;
        SLOG(LOG_DEBUG, TAG_TTSC, "Utterance completed data : utt_id(%d)", utt_id);
@@ -791,10 +777,7 @@ int tts_core_notify_utt_completeted(tts_client_s* client, int utt_id)
 
 int tts_core_notify_error_async(tts_client_s* client, tts_error_e reason, int utt_id, const char* err_msg)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        SLOG(LOG_DEBUG, TAG_TTSC, "Error data : utt_id(%d) reason(%s)", utt_id, tts_core_covert_error_code(reason));
        client->utt_id = utt_id;
@@ -812,12 +795,10 @@ int tts_core_notify_error_async(tts_client_s* client, tts_error_e reason, int ut
        return TTS_ERROR_NONE;
 }
 
+//LCOV_EXCL_START
 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)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        SLOG(LOG_DEBUG, TAG_TTSC, "Default voice changed data : before_lang(%s), before_voice_type(%d), language(%s), voice_type(%d)",
                        before_lang, before_voice_type, language, voice_type);
@@ -839,10 +820,7 @@ int tts_core_notify_default_voice_changed(tts_client_s* client, const char* befo
 
 int tts_core_notify_engine_changed(tts_client_s* client, const char* engine_id, const char* language, int voice_type, bool need_credential)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        SLOG(LOG_DEBUG, TAG_TTSC, "Engine changed data : engine_id(%s) language(%s), voicd_type(%d), need_credential(%d)",
                        engine_id, language, voice_type, need_credential);
@@ -861,13 +839,11 @@ int tts_core_notify_engine_changed(tts_client_s* client, const char* engine_id,
 
        return TTS_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
 int tts_core_notify_screen_reader_changed(tts_client_s* client, bool value)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        SLOG(LOG_DEBUG, TAG_TTSC, "Screen reader is changed. Current status(%d)", value);
 
@@ -930,10 +906,7 @@ bool tts_core_is_valid_text(const char* text)
 
 bool tts_core_check_screen_reader(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] client is not valid");
-               return false;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), false, "[ERROR] Client is invalid.");
 
        tts_mode_e mode = tts_client_get_mode(client);
        if (TTS_MODE_SCREEN_READER == mode && false == __is_screen_reader_turned_on()) {
@@ -945,10 +918,7 @@ bool tts_core_check_screen_reader(tts_client_s* client)
 
 bool tts_core_check_credential(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] client is not valid");
-               return false;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), false, "[ERROR] Client is invalid.");
 
        if (true == client->credential_needed && NULL == tts_client_get_credential_key(client)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Do not have app credential for this engine");
@@ -958,6 +928,7 @@ bool tts_core_check_credential(tts_client_s* client)
        return true;
 }
 
+//LCOV_EXCL_START
 const char* tts_core_covert_error_code(tts_error_e err)
 {
        switch (err) {
@@ -982,20 +953,15 @@ const char* tts_core_covert_error_code(tts_error_e err)
        }
        return NULL;
 }
+//LCOV_EXCL_STOP
 
 int tts_core_receive_hello(unsigned int uid, int ret, int credential_needed)
 {
        tts_client_s* client = tts_client_get_by_uid(uid);
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get TTS client or ignore this uid(%u)", uid);
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(NULL == client, TTS_ERROR_OPERATION_FAILED, "Fail to get TTS client or ignore this uid(%u)", uid);
 
        tts_state_e current_state = tts_client_get_current_state(client);
-       if (TTS_STATE_CREATED != current_state) {
-               SLOG(LOG_INFO, TAG_TTSC, "[INFO] tts client is already READY");
-               return TTS_ERROR_NONE;
-       }
+       RETVM_IF(TTS_STATE_CREATED != current_state, TTS_ERROR_NONE, "[INFO] tts client is already READY");
 
        if (client->hello_timer) {
                ecore_timer_del(client->hello_timer);
@@ -1026,17 +992,9 @@ int tts_core_receive_hello(unsigned int uid, int ret, int credential_needed)
        return TTS_ERROR_NONE;
 }
 
-const char* tts_core_get_engine_name()
-{
-       return g_engine_name;
-}
-
 int tts_core_prepare(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        if (false == tts_core_check_screen_reader(client)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
@@ -1060,10 +1018,7 @@ int tts_core_prepare(tts_client_s* client)
 
 int tts_core_prepare_sync(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        unsigned int uid = tts_client_get_uid(client);
        SLOG(LOG_INFO, TAG_TTSC, "[INFO] Start core_prepare_sync. tts_h(%p), tts_client(%p), uid(%u)", tts_client_get_handle(client), client, uid);
@@ -1104,10 +1059,7 @@ int tts_core_prepare_sync(tts_client_s* client)
 
 int tts_core_unprepare(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        unsigned int uid = tts_client_get_uid(client);
        SLOG(LOG_INFO, TAG_TTSC, "[INFO] tts_h(%p), tts_client(%p), uid(%u)", tts_client_get_handle(client), client, uid);
@@ -1146,10 +1098,7 @@ int tts_core_unprepare(tts_client_s* client)
 int tts_core_reprepare()
 {
        GList* clients = tts_client_get_client_list();
-       if (NULL == clients) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get client list");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(NULL == clients, TTS_ERROR_OPERATION_FAILED, "[ERROR] Fail to get client list");
 
        GList *iter = NULL;
        if (g_list_length(clients) > 0) {
@@ -1173,10 +1122,7 @@ int tts_core_reprepare()
 
 int tts_core_foreach_supported_voices(tts_client_s* client, const char* engine_id, tts_supported_voice_cb callback, void* user_data)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] client is not valid");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        tts_client_set_supported_voice_cb(client, callback, user_data);
        uintptr_t uid = tts_client_get_uid(client);
@@ -1194,10 +1140,7 @@ int tts_core_foreach_supported_voices(tts_client_s* client, const char* engine_i
 int tts_core_handle_service_reset()
 {
        GList* client_list = tts_client_get_client_list();
-       if (NULL == client_list) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get client list");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(NULL == client_list, TTS_ERROR_OPERATION_FAILED, "[ERROR] Fail to get client list");
 
        if (g_list_length(client_list) > 0) {
                GList *iter = g_list_first(client_list);
@@ -1223,15 +1166,8 @@ int tts_core_handle_service_reset()
 
 int tts_core_add_text(tts_client_s* client, const char* text, const char* language, int voice_type, int speed, int* utt_id)
 {
-       if (NULL == text || NULL == utt_id) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Parameter is invalid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(NULL == text || NULL == utt_id, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Parameter is invalid.");
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        tts_client_set_repeat_text(client, text);
 
@@ -1249,20 +1185,14 @@ int tts_core_add_text(tts_client_s* client, const char* text, const char* langua
 
 int tts_core_play(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        return __request_play(client);
 }
 
 int tts_core_stop(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        unsigned int uid = tts_client_get_uid(client);
        int ret = -1;
@@ -1284,10 +1214,7 @@ int tts_core_stop(tts_client_s* client)
 
 int tts_core_pause(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        unsigned int uid = tts_client_get_uid(client);
        int ret = -1;
@@ -1310,15 +1237,8 @@ int tts_core_pause(tts_client_s* client)
 
 int tts_core_repeat(tts_client_s* client, char** text_repeat, int* utt_id)
 {
-       if (NULL == text_repeat || NULL == utt_id) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Parameter is invalid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(NULL == text_repeat || NULL == utt_id, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Parameter is invalid.");
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        const char* repeat_text = tts_client_get_repeat_text(client);
        if (NULL == repeat_text) {
@@ -1349,10 +1269,7 @@ int tts_core_repeat(tts_client_s* client, char** text_repeat, int* utt_id)
 
 int tts_core_add_pcm(tts_client_s* client, int event, const void* data, unsigned int data_size, int audio_type, int rate)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        unsigned int uid = tts_client_get_uid(client);
        int ret = -1;
@@ -1375,10 +1292,7 @@ int tts_core_add_pcm(tts_client_s* client, int event, const void* data, unsigned
 
 int tts_core_play_pcm(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        unsigned int uid = tts_client_get_uid(client);
        int ret = -1;
@@ -1401,10 +1315,7 @@ int tts_core_play_pcm(tts_client_s* client)
 
 int tts_core_stop_pcm(tts_client_s* client)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        unsigned int uid = tts_client_get_uid(client);
        int ret = -1;
@@ -1427,10 +1338,7 @@ int tts_core_stop_pcm(tts_client_s* client)
 
 int tts_core_set_private_data(tts_client_s* client, const char* key, const char* data)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        unsigned int uid = tts_client_get_uid(client);
        int ret = -1;
@@ -1453,10 +1361,7 @@ int tts_core_set_private_data(tts_client_s* client, const char* key, const char*
 
 int tts_core_get_private_data(tts_client_s* client, const char* key, char** data)
 {
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
+       RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
 
        unsigned int uid = tts_client_get_uid(client);
        int ret = -1;
index 41a7616..538d44f 100644 (file)
@@ -39,7 +39,6 @@ const char* tts_core_covert_error_code(tts_error_e err);
 // called by tts.c
 int tts_core_initialize();
 int tts_core_deinitialize();
-const char* tts_core_get_engine_name();
 
 int tts_core_prepare(tts_client_s* client);
 int tts_core_prepare_sync(tts_client_s* client);
index 15484f0..2e3c5db 100644 (file)
@@ -13,6 +13,7 @@
 #include "tts_ipc.h"
 #include "tts_dbus.h"
 #include "tts_tidl.h"
+#include "tts_dlog.h"
 
 
 typedef enum {
@@ -70,17 +71,6 @@ int tts_ipc_set_method(tts_ipc_method_e method)
        return TTS_ERROR_NONE;
 }
 
-int tts_ipc_get_method(tts_ipc_method_e* method)
-{
-       if (NULL == method) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] method is NULL");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
-       *method = g_ipc_method;
-       return TTS_ERROR_NONE;
-}
-
 bool tts_ipc_is_method_set()
 {
        SLOG(LOG_INFO, TAG_TTSC, "Set method (TIDL or DBUS) for ipc");
@@ -91,16 +81,8 @@ int tts_ipc_open_connection(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_open_connection");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_INVALID_STATE;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] IPC method is not set");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[OPEN_CONNECTION](uid);
 }
@@ -109,16 +91,8 @@ int tts_ipc_close_connection(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_close_connection");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[CLOSE_CONNECTION](uid);
 }
@@ -127,15 +101,8 @@ int tts_ipc_stop_listening(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_stop_listening");
 
-       if (false == tts_client_is_valid_uid(uid)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[STOP_LISTENING](uid);
 }
@@ -144,16 +111,8 @@ int tts_ipc_request_hello(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_hello");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_HELLO](uid);
 }
@@ -162,16 +121,8 @@ int tts_ipc_request_hello_sync(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_hello_sync");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_HELLO_SYNC](uid);
 }
@@ -180,16 +131,8 @@ int tts_ipc_request_initialize(unsigned int uid, bool* credential_needed)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_initialize");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_INITIALIZE](uid, credential_needed);
 }
@@ -198,16 +141,8 @@ int tts_ipc_request_finalize(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_finalize");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_FINALIZE](uid);
 }
@@ -216,16 +151,8 @@ int tts_ipc_request_add_text(unsigned int uid, const char* text, const char* lan
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_add_text");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_ADD_TEXT](uid, text, lang, vctype, speed, uttid, credential);
 }
@@ -234,16 +161,8 @@ int tts_ipc_request_set_private_data(unsigned int uid, const char* key, const ch
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_set_private_data");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_SET_PRIVATE_DATA](uid, key, data);
 }
@@ -252,15 +171,8 @@ int tts_ipc_request_get_private_data(unsigned int uid, const char* key, char** d
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_get_private_data");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_GET_PRIVATE_DATA](uid, key, data);
 }
@@ -269,16 +181,8 @@ int tts_ipc_request_play(unsigned int uid, const char* credential)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_play");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_PLAY](uid, credential);
 }
@@ -287,16 +191,8 @@ int tts_ipc_request_stop(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_stop");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_STOP](uid);
 }
@@ -305,35 +201,18 @@ int tts_ipc_request_pause(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_pause");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_PAUSE](uid);
 }
 
-//LCOV_EXCL_START
 int tts_ipc_request_play_pcm(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_play_pcm");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_PLAY_PCM](uid);
 }
@@ -342,16 +221,8 @@ int tts_ipc_request_stop_pcm(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_stop_pcm");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_STOP_PCM](uid);
 }
@@ -360,35 +231,18 @@ int tts_ipc_request_add_pcm(unsigned int uid, int event, const char* data, int d
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_add_pcm");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_ADD_PCM](uid, event, data, data_size, audio_type, rate);
 }
-// LCOV_EXCL_STOP
 
 int tts_ipc_request_set_mode(unsigned int uid, tts_mode_e mode)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_set_mode");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_vtable) {
-               SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
+       RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid);
+       RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set");
 
        return g_vtable[REQUEST_SET_MODE](uid, mode);
 }
index ac74325..df61fea 100644 (file)
@@ -22,8 +22,6 @@ extern "C" {
 
 int tts_ipc_set_method(tts_ipc_method_e method);
 
-int tts_ipc_get_method(tts_ipc_method_e* method);
-
 bool tts_ipc_is_method_set();
 
 int tts_ipc_open_connection(unsigned int uid);
index 40247cb..3c32134 100644 (file)
@@ -156,6 +156,7 @@ static void __on_disconnected(rpc_port_proxy_tts_h h, void *user_data)
        }
 }
 
+//LCOV_EXCL_START
 static void __on_rejected(rpc_port_proxy_tts_h h, void *user_data)
 {
        unsigned int uid = (uintptr_t)user_data;
@@ -169,6 +170,7 @@ static void __on_rejected(rpc_port_proxy_tts_h h, void *user_data)
 
        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Rejected from server(%d)", uid);
 }
+//LCOV_EXCL_STOP
 
 static void __get_engine_app_id(int size, char* app_id)
 {
@@ -196,7 +198,7 @@ static rpc_port_proxy_tts_h __create_rpc_port(unsigned int uid, const char* engi
 
        rpc_port_proxy_tts_h handle = NULL;
        uintptr_t ptr_uid = uid;
-       if (0 != rpc_port_proxy_tts_create(engine_app_id, &rpc_callback, (void*)ptr_uid, &handle)) {
+       if (RPC_PORT_ERROR_NONE != rpc_port_proxy_tts_create(engine_app_id, &rpc_callback, (void*)ptr_uid, &handle)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create proxy");
                return NULL;
        }
@@ -245,7 +247,7 @@ int tts_tidl_close_connection(unsigned int uid)
        tts_tidl_info_s* info = __get_tidl_info_s(uid);
        RETVM_IF(NULL == info, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
 
-       if (0 != rpc_port_proxy_tts_destroy(info->rpc_h)) {
+       if (RPC_PORT_ERROR_NONE != rpc_port_proxy_tts_destroy(info->rpc_h)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to disconnect");
                return TTS_ERROR_OPERATION_FAILED;
        }
@@ -315,7 +317,7 @@ static int __invoke_register_callback(int pid, tts_tidl_info_s* info)
        int ret = __create_notify_callback_handle(info);
        if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create callback handle. ret(%d)", ret);
-               return TTS_ERROR_OPERATION_FAILED;
+               return ret;
        }
 
        rpc_port_proxy_tts_invoke_register_cb(info->rpc_h, pid, info->uid, info->notify_cb_h);
@@ -338,7 +340,7 @@ int tts_tidl_request_hello(unsigned int uid)
 
        if (NULL == info->engine_app_id || 0 != strncmp(info->engine_app_id, engine_app_id, TTS_ENGINE_APPID_LEN)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[TIDL] tts engine is changed from (%s) to (%s)", info->engine_app_id, engine_app_id);
-               if (0 != rpc_port_proxy_tts_destroy(info->rpc_h)) {
+               if (RPC_PORT_ERROR_NONE != rpc_port_proxy_tts_destroy(info->rpc_h)) {
                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to destroy old rpc_port");
                        return TTS_ERROR_OPERATION_FAILED;
                }
@@ -382,6 +384,15 @@ static int __request_tidl_connect_sync(tts_tidl_info_s* info)
        return TTS_ERROR_OPERATION_FAILED;
 }
 
+static int __convert_unhandled_error(int ret)
+{
+       if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) {
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
 static int __invoke_register_callback_sync(int pid, tts_tidl_info_s* info)
 {
        if (info->register_callback_invoked) {
@@ -389,17 +400,22 @@ static int __invoke_register_callback_sync(int pid, tts_tidl_info_s* info)
                return TTS_ERROR_NONE;
        }
 
-       int ret = RPC_PORT_ERROR_NONE;
+       int ret = TTS_ERROR_NONE;
        ret = __create_notify_callback_handle(info);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create callback handle. ret(%d/%s)", ret, get_error_message(ret));
-               return TTS_ERROR_OPERATION_FAILED;
+               return ret;
        }
 
        ret = rpc_port_proxy_tts_invoke_register_cb_sync(info->rpc_h, pid, info->uid, info->notify_cb_h);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to register callback. ret(%d/%s)", ret, get_error_message(ret));
-               return TTS_ERROR_OPERATION_FAILED;
+               return ret;
        }
 
        info->register_callback_invoked = true;
@@ -437,15 +453,6 @@ int tts_tidl_request_hello_sync(unsigned int uid)
        return TTS_ERROR_NONE;
 }
 
-static int __covert_unhandled_error(int ret)
-{
-       if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) {
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       return ret;
-}
-
 int tts_tidl_request_initialize(unsigned int uid, bool* credential_needed)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_initialize");
@@ -460,9 +467,14 @@ int tts_tidl_request_initialize(unsigned int uid, bool* credential_needed)
 
        bool temp;
        int ret = rpc_port_proxy_tts_invoke_initialize(info->rpc_h, client->pid, uid, &temp);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to invoke message");
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        *credential_needed = temp;
@@ -486,9 +498,14 @@ int tts_tidl_request_finalize(unsigned int uid)
 
 
        int ret = rpc_port_proxy_tts_invoke_finalize(info->rpc_h, uid);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to invoke message");
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        tts_client_set_start_listening(uid, false);
@@ -512,9 +529,14 @@ int tts_tidl_request_add_text(unsigned int uid, const char* text, const char* la
 
        const char *not_null_credential = NULL == credential ? "NULL" : credential;
        int ret = rpc_port_proxy_tts_invoke_add_text(info->rpc_h, uid, text, lang, vctype, speed, uttid, not_null_credential);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request add text : Fail to invoke message");
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        return TTS_ERROR_NONE;
@@ -536,9 +558,14 @@ int tts_tidl_request_set_private_data(unsigned int uid, const char* key, const c
 
 
        int ret = rpc_port_proxy_tts_invoke_set_private(info->rpc_h, uid, key, data);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request set private data : Fail to invoke message");
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        return TTS_ERROR_NONE;
@@ -558,17 +585,21 @@ int tts_tidl_request_get_private_data(unsigned int uid, const char* key, char**
 
        RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
 
-
        char *tmp = NULL;
        int ret = rpc_port_proxy_tts_invoke_get_private(info->rpc_h, uid, key, &tmp);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request get private data : Fail to invoke message");
                free(tmp);
-               return __covert_unhandled_error(ret);
+               return ret;
        }
-       SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
 
        *data = tmp;
+       SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
 
        return TTS_ERROR_NONE;
 }
@@ -587,9 +618,14 @@ int tts_tidl_request_play(unsigned int uid, const char* credential)
 
        const char *not_null_credential = NULL == credential ? "NULL" : credential;
        int ret = rpc_port_proxy_tts_invoke_play(info->rpc_h, uid, not_null_credential);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request play : Fail to invoke message");
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
@@ -610,9 +646,14 @@ int tts_tidl_request_stop(unsigned int uid)
        RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
 
        int ret = rpc_port_proxy_tts_invoke_stop(info->rpc_h, uid);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request stop : Fail to invoke message");
-               return __covert_unhandled_error(ret);
+               return ret;
        }
        SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
 
@@ -632,9 +673,14 @@ int tts_tidl_request_pause(unsigned int uid)
        RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
 
        int ret = rpc_port_proxy_tts_invoke_pause(info->rpc_h, uid);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request pause : Fail to invoke message(%d)", ret);
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
@@ -642,7 +688,6 @@ int tts_tidl_request_pause(unsigned int uid)
        return TTS_ERROR_NONE;
 }
 
-//LCOV_EXCL_START
 int tts_tidl_request_play_pcm(unsigned int uid)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_play_pcm");
@@ -656,9 +701,14 @@ int tts_tidl_request_play_pcm(unsigned int uid)
        RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
 
        int ret = rpc_port_proxy_tts_invoke_play_pcm(info->rpc_h, uid);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request play pcm : Fail to invoke message(%d)", ret);
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
@@ -679,9 +729,14 @@ int tts_tidl_request_stop_pcm(unsigned int uid)
        RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
 
        int ret = rpc_port_proxy_tts_invoke_stop_pcm(info->rpc_h, uid);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request pause pcm : Fail to invoke message(%d)", ret);
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
@@ -716,16 +771,20 @@ int tts_tidl_request_add_pcm(unsigned int uid, int event, const char* data, int
 
        int ret = rpc_port_proxy_tts_invoke_add_pcm(info->rpc_h, uid, event, pcm_data, data_size, audio_type, rate);
        rpc_port_proxy_array_char_destroy(pcm_data);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request pause pcm : Fail to invoke message(%d)", ret);
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
 
        return TTS_ERROR_NONE;
 }
-// LCOV_EXCL_STOP
 
 int tts_tidl_request_set_mode(unsigned int uid, tts_mode_e mode)
 {
@@ -740,9 +799,14 @@ int tts_tidl_request_set_mode(unsigned int uid, tts_mode_e mode)
        RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
 
        int ret = rpc_port_proxy_tts_invoke_set_mode(info->rpc_h, uid, mode);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request set private data : Fail to invoke message(%d)", ret);
-               return __covert_unhandled_error(ret);
+               return ret;
        }
 
        return TTS_ERROR_NONE;
index 14fcb28..6b01702 100644 (file)
@@ -1146,13 +1146,19 @@ int ttsd_server_get_private_data(unsigned int uid, const char* key, char** data)
                return TTSD_ERROR_INVALID_STATE;
        }
 
-       int ret = ttsd_engine_get_private_data(key, data);
+       char* temp_data = NULL;
+       int ret = ttsd_engine_get_private_data(key, &temp_data);
        if (0 != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get private data : ret(%d)", ret);
        } else {
                SLOG(LOG_DEBUG, tts_tag(), "[Server] Get private data, key(%s), data(%s)", key, *data);
        }
 
+       if (NULL == temp_data) {
+               temp_data = strdup("NULL");
+       }
+       *data = temp_data;
+
        return ret;
 }
 
index f5cdca8..fe0cf2a 100644 (file)
@@ -421,16 +421,12 @@ static int __get_private_cb(rpc_port_stub_tts_context_h context, int uid, const
        unsigned int u_uid = (unsigned int)uid;
        SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET PRIVATE DATA (%u)", u_uid);
 
-       char *tmp = NULL;
-       int ret = ttsd_server_get_private_data(u_uid, key, &tmp);
+       int ret = ttsd_server_get_private_data(u_uid, key, data);
        if (TTSD_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] TTS GET PRIVATE DATA (%u) fail (%d/%s) <<<<<", u_uid, ret, get_error_message(ret));
-               free(tmp);
                return ret;
        }
 
-       *data = tmp;
-
        SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
        return TTSD_ERROR_NONE;
 }
index e366f42..540e5b8 100644 (file)
@@ -7,4 +7,7 @@
             <label>TTS unittests</label>
             <background-category value="media"/>
         </service-application>
+        <privileges>
+            <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        </privileges>
 </manifest>
index 7d26bbc..b978751 100644 (file)
@@ -18,6 +18,7 @@
 #include <Ecore.h>
 #include <system_info.h>
 #include <tzplatform_config.h>
+#include <vconf.h>
 
 #include <tts.h>
 #include <tts_internal.h>
@@ -27,11 +28,13 @@ static tts_h g_tts = NULL;
 static char *g_language = NULL;
 static int g_voice_type;
 static int is_created_hndl = -1;
-static void __tts_state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
 static bool g_supported = false;
 static tts_state_e g_current_state;
 static bool g_utterance_started_cb = false;
 static bool g_utterance_completed_cb = false;
+static bool g_screen_reader_changed_cb = false;
+static bool g_error_cb = false;
+static const char* g_test_engine = "test";
 static int g_utt_id = -1;
 static char* g_pcm_data = nullptr;
 static long g_pcm_size = 0;
@@ -51,6 +54,7 @@ static const char *g_text = "Speech Synthesis is the artificial production of hu
        of the target prosody (pitch contour, phoneme durations),[4] which is then imposed on the output speech. From Wikipedia";
 
 static const int g_sample_rate = 24000;
+static const char* ENGINE_VCONF_KEY = "db/voice/tts/engine/default";
 
 static bool __tts_supported_voice_cb(tts_h tts, const char* language, int voice_type, void* user_data)
 {
@@ -62,6 +66,13 @@ static void __tts_state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e
        g_current_state = current;
 }
 
+static void __tts_state_changed_cb_destroy_test(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data)
+{
+       g_current_state = current;
+
+       ASSERT_NE(tts_destroy(g_tts), TTS_ERROR_NONE);
+}
+
 static void __tts_utterance_started_cb(tts_h tts, int utt_id, void* user_data)
 {
        g_utterance_started_cb = true;
@@ -75,12 +86,22 @@ static void __tts_utterance_completed_cb(tts_h tts, int utt_id, void *user_data)
 
 static void __tts_error_cb(tts_h tts, int utt_id, tts_error_e reason, void* user_data)
 {
+       g_error_cb = true;
 }
 
 static void __tts_default_voice_changed_cb(tts_h tts, const char* previous_language, int previous_voice_type, const char* current_language, int current_voice_type, void* user_data)
 {
 }
 
+static void __tts_screen_reader_changed_cb(tts_h tts, bool is_on, void* user_data)
+{
+       g_screen_reader_changed_cb = true;
+}
+
+static void __tts_engine_changed_cb(tts_h tts, const char* engine_id, const char* language, int voice_type, bool need_credential, void* user_data)
+{
+}
+
 static bool __is_state_changed(tts_state_e state, int wait_delay)
 {
        int max_count = wait_delay * 10;
@@ -98,6 +119,32 @@ static bool __is_state_changed(tts_state_e state, int wait_delay)
        return true;
 }
 
+static bool __is_screen_reader_changed(int wait_delay)
+{
+       int max_count = wait_delay * 10;
+       int count = 0;
+       while (max_count > count && false == g_screen_reader_changed_cb) {
+               ecore_main_loop_iterate();
+               usleep(100000);
+               count++;
+       }
+
+       return g_screen_reader_changed_cb;
+}
+
+static bool __is_error_occur(int wait_delay)
+{
+       int max_count = wait_delay * 10;
+       int count = 0;
+       while (max_count > count && false == g_error_cb) {
+               ecore_main_loop_iterate();
+               usleep(100000);
+               count++;
+       }
+
+       return g_error_cb;
+}
+
 static void __get_test_PCM_Data()
 {
        const char* pcm_path = tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_APP"), "/org.tizen.tts-unittests/res/test_pcm.dat");
@@ -374,6 +421,17 @@ TEST_F(TTSTest, utc_tts_destroy_n2)
        EXPECT_EQ(ret, TTS_ERROR_NONE);
 }
 
+TEST_F(TTSTest, utc_tts_destroy_n3)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_destroy(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(tts_set_state_changed_cb(g_tts, __tts_state_changed_cb_destroy_test, nullptr), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_prepare_sync(g_tts), TTS_ERROR_NONE);
+}
+
 TEST_F(TTSTest, utc_tts_set_mode_p)
 {
        int ret = TTS_ERROR_NONE;
@@ -604,6 +662,69 @@ TEST_F(TTSTest, utc_tts_prepare_n2)
 }
 
 /**
+ * @testcase           utc_tts_prepare_n3
+ * @since_tizen                2.3
+ * @description                test whether function returns error when tts sets screen reader mode without feature on.
+ */
+TEST_F(TTSTest, utc_tts_prepare_n3)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_mode(g_tts, TTS_MODE_SCREEN_READER), TTS_ERROR_NONE);
+       ASSERT_NE(tts_prepare(g_tts), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_prepare_n4
+ * @since_tizen                2.3
+ * @description                test whether state does not change to ready. (expired handle)
+ */
+TEST_F(TTSTest, utc_tts_prepare_n4)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_destroy(g_tts), TTS_ERROR_NONE);
+
+       EXPECT_EQ(false, __is_state_changed(TTS_STATE_READY, 5));
+
+       EXPECT_EQ(tts_create(&g_tts), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_prepare_n5
+ * @since_tizen                2.3
+ * @description                test whether state does not change to ready. (screen reader feature off)
+ */
+TEST_F(TTSTest, utc_tts_prepare_n5)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_mode(g_tts, TTS_MODE_SCREEN_READER), TTS_ERROR_NONE);
+       EXPECT_EQ(vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, true), 0);
+
+       EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NONE);
+
+       EXPECT_EQ(vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, false), 0);
+       EXPECT_EQ(false, __is_state_changed(TTS_STATE_READY, 5));
+}
+
+/**
  * @testcase           utc_tts_prepare_sync_p
  * @since_tizen                2.3
  * @description                test whether tts daemon is prepared properly.
@@ -672,6 +793,24 @@ TEST_F(TTSTest, utc_tts_prepare_sync_n2)
 }
 
 /**
+ * @testcase           utc_tts_prepare_sync_n3
+ * @since_tizen                2.3
+ * @description                test whether function returns error when tts sets screen reader mode without feature on.
+ */
+TEST_F(TTSTest, utc_tts_prepare_sync_n3)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_prepare_sync(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_mode(g_tts, TTS_MODE_SCREEN_READER), TTS_ERROR_NONE);
+       ASSERT_NE(tts_prepare_sync(g_tts), TTS_ERROR_NONE);
+}
+
+/**
  * @testcase           utc_tts_foreach_supported_voices_p
  * @since_tizen                2.3
  * @description                test whether each supported voices are gotten properly.
@@ -1197,6 +1336,23 @@ TEST_F(TTSPreparedTest, utc_tts_add_text_n5)
 }
 
 /**
+ * @testcase           utc_tts_add_text_n6
+ * @since_tizen                2.3
+ * @description                test whether function returns error with empty string.
+ */
+TEST_F(TTSPreparedTest, utc_tts_add_text_n6)
+{
+       int utt_id;
+       if (g_supported == false) {
+               EXPECT_EQ(tts_add_text(g_tts, "", g_language, g_voice_type, TTS_SPEED_AUTO, &utt_id), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_NE(tts_add_text(g_tts, "", g_language, g_voice_type, TTS_SPEED_AUTO, &utt_id), TTS_ERROR_NONE);
+}
+
+/**
  * @testcase           utc_tts_play_p
  * @since_tizen                2.3
  * @description                test whether tts is played properly.
@@ -1261,6 +1417,76 @@ TEST_F(TTSPreparedWithUttCbTest, utc_tts_play_p2)
 }
 
 /**
+ * @testcase           utc_tts_play_p3
+ * @since_tizen                2.3
+ * @description                test whether tts is played all text properly.
+ */
+TEST_F(TTSPreparedWithUttCbTest, utc_tts_play_p3)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_play(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       g_utterance_completed_cb = false;
+
+       int utt_id1 = -1;
+       int utt_id2 = -1;
+       EXPECT_EQ(tts_add_text(g_tts, "1 2 3 4 5", g_language, g_voice_type, TTS_SPEED_AUTO, &utt_id1), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_add_text(g_tts, "1 2 3 4 5", g_language, g_voice_type, TTS_SPEED_AUTO, &utt_id2), TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_play(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_PLAYING, 5));
+
+       while (true != g_utterance_completed_cb) {
+               ecore_main_loop_iterate();
+       }
+       g_utterance_completed_cb = false;
+       EXPECT_EQ(utt_id1, g_utt_id);
+
+       while (true != g_utterance_completed_cb) {
+               ecore_main_loop_iterate();
+       }
+       EXPECT_EQ(utt_id2, g_utt_id);
+
+       EXPECT_EQ(tts_stop(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+}
+
+/**
+ * @testcase           utc_tts_play_p4
+ * @since_tizen                2.3
+ * @description                test whether tts is played properly.
+ */
+TEST_F(TTSPreparedTest, utc_tts_play_p4)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_play(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       tts_h tts = NULL;
+       EXPECT_EQ(tts_create(&tts), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_prepare_sync(tts), TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_play(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_PLAYING, 5));
+
+       EXPECT_EQ(tts_play(tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+
+       EXPECT_EQ(tts_stop(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_stop(tts), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_unprepare(tts), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_destroy(tts), TTS_ERROR_NONE);
+       tts = NULL;
+}
+
+/**
  * @testcase           utc_tts_play_n
  * @since_tizen                2.3
  * @description                test whether function returns error with NULL parameter.
@@ -1324,6 +1550,36 @@ TEST_F(TTSTest, utc_tts_play_n3)
 }
 
 /**
+ * @testcase           utc_tts_play_n4
+ * @since_tizen                2.3
+ * @description                test whether function returns error when interrupt mode client plays.
+ */
+TEST_F(TTSPreparedTest, utc_tts_play_n4)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_play(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       tts_h tts = NULL;
+       EXPECT_EQ(tts_create(&tts), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_set_mode(tts, (tts_mode_e)TTS_MODE_INTERRUPT), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_prepare_sync(tts), TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_play(tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+
+       EXPECT_NE(tts_play(g_tts), TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_stop(tts), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_unprepare(tts), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_destroy(tts), TTS_ERROR_NONE);
+       tts = NULL;
+}
+
+/**
  * @testcase           utc_tts_pause_p
  * @since_tizen                2.3
  * @description                test whether tts is paused properly.
@@ -1696,6 +1952,29 @@ TEST_F(TTSTest, utc_tts_unprepare_p2)
        EXPECT_EQ(ret, TTS_ERROR_NONE);
 }
 
+/**
+ * @testcase           utc_tts_unprepare_p3
+ * @since_tizen                2.3
+ * @description                test whether tts is unprepared properly when tts is in screen reader mode.
+ */
+TEST_F(TTSTest, utc_tts_unprepare_p3)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_unprepare(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, true), 0);
+       EXPECT_EQ(tts_set_mode(g_tts, TTS_MODE_SCREEN_READER), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+
+
+       EXPECT_EQ(vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, false), 0);
+       EXPECT_EQ(tts_unprepare(g_tts), TTS_ERROR_NONE);
+}
+
 TEST_F(TTSTest, utc_tts_unprepare_n)
 {
     int ret = tts_unprepare(NULL);
@@ -2256,6 +2535,37 @@ TEST_F(TTSTest, utc_tts_set_error_cb_p)
 }
 
 /**
+ * @testcase           utc_tts_set_error_cb_p2
+ * @since_tizen                2.3
+ * @description                test whether error callback function is invoked when error occurs.
+ */
+TEST_F(TTSTest, utc_tts_set_error_cb_p2)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_error_cb(g_tts, __tts_error_cb, NULL), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       char* engine_id = vconf_get_str(ENGINE_VCONF_KEY);
+
+       g_error_cb = false;
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+       EXPECT_EQ(tts_set_error_cb(g_tts, __tts_error_cb, NULL), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+
+       EXPECT_EQ(vconf_set_str(ENGINE_VCONF_KEY, g_test_engine), 0);
+
+       EXPECT_EQ(__is_error_occur(5), true);
+       sleep(1);
+
+       EXPECT_EQ(vconf_set_str(ENGINE_VCONF_KEY, engine_id), 0);
+       g_current_state = TTS_STATE_CREATED;
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+       EXPECT_EQ(tts_unprepare(g_tts), TTS_ERROR_NONE);
+}
+
+/**
  * @testcase           utc_tts_set_error_cb_n
  * @since_tizen                2.3
  * @description                test whether function returns error with NULL parameter.
@@ -2565,6 +2875,64 @@ TEST_F(TTSPreparedTest, utc_tts_unset_default_voice_changed_cb_n3)
 }
 
 /**
+ * @testcase           utc_tts_get_error_message_p
+ * @since_tizen                3.0
+ * @description                Positive UTC for get error message
+ */
+TEST_F(TTSTest, utc_tts_get_error_message_p)
+{
+       char* error_message = nullptr;
+       if (g_supported == false) {
+               EXPECT_EQ(tts_get_error_message(g_tts, &error_message), TTS_ERROR_NOT_SUPPORTED);
+               free(error_message);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_get_error_message(g_tts, &error_message), TTS_ERROR_NONE);
+       free(error_message);
+}
+
+/**
+ * @testcase           utc_tts_get_error_message_p2
+ * @since_tizen                3.0
+ * @description                Positive UTC for get error message
+ */
+TEST_F(TTSTest, utc_tts_get_error_message_p2)
+{
+       char* error_message = nullptr;
+       if (g_supported == false) {
+               EXPECT_EQ(tts_get_error_message(g_tts, &error_message), TTS_ERROR_NOT_SUPPORTED);
+               free(error_message);
+               return;
+       }
+
+       char* engine_id = vconf_get_str(ENGINE_VCONF_KEY);
+
+       g_error_cb = false;
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+       EXPECT_EQ(tts_set_error_cb(g_tts, __tts_error_cb, NULL), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+
+       EXPECT_EQ(vconf_set_str(ENGINE_VCONF_KEY, g_test_engine), 0);
+
+       EXPECT_EQ(__is_error_occur(5), true);
+
+       EXPECT_EQ(tts_get_error_message(g_tts, &error_message), TTS_ERROR_NONE);
+       EXPECT_NE(error_message, nullptr);
+       free(error_message);
+
+       sleep(1);
+
+       EXPECT_EQ(vconf_set_str(ENGINE_VCONF_KEY, engine_id), 0);
+       g_current_state = TTS_STATE_CREATED;
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+       EXPECT_EQ(tts_unprepare(g_tts), TTS_ERROR_NONE);
+}
+
+/**
  * @testcase           utc_tts_get_error_message_n
  * @since_tizen                3.0
  * @description                Negative UTC for get error message (invalid parameter)
@@ -2812,6 +3180,389 @@ TEST_F(TTSPreparedTest, utc_tts_set_credential_n2)
 
 
 /**
+ * @testcase           utc_tts_set_server_tts_p
+ * @since_tizen                3.0
+ * @description                Positive UTC for set server TTS as enabled
+ */
+TEST_F(TTSPreparedTest, utc_tts_set_server_tts_p)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_server_tts(g_tts, "test"), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_server_tts(g_tts, "test"), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_set_server_tts_p2
+ * @since_tizen                3.0
+ * @description                Positive UTC for set server TTS as disabled
+ */
+TEST_F(TTSPreparedTest, utc_tts_set_server_tts_p2)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_server_tts(g_tts, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_server_tts(g_tts, nullptr), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_set_server_tts_n
+ * @since_tizen                3.0
+ * @description                Negative UTC for set server TTS (Invalid parameter)
+ */
+TEST_F(TTSTest, utc_tts_set_server_tts_n)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_server_tts(nullptr, "test"), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+    EXPECT_EQ(tts_set_server_tts(nullptr, "test"), TTS_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase           utc_tts_set_server_tts_n2
+ * @since_tizen                3.0
+ * @description                Negative UTC for set server TTS (Invalid state)
+ */
+TEST_F(TTSPreparedTest, utc_tts_set_server_tts_n2)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_server_tts(g_tts, "test"), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_play(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_PLAYING, 5));
+
+    EXPECT_EQ(tts_set_server_tts(g_tts, "test"), TTS_ERROR_INVALID_STATE);
+
+       EXPECT_EQ(tts_stop(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+}
+
+/**
+ * @testcase           utc_tts_check_screen_reader_on_p
+ * @since_tizen                6.5
+ * @description                Positive UTC for checking screen reader on
+ */
+TEST_F(TTSTest, utc_tts_check_screen_reader_on_p)
+{
+       bool is_on = false;
+       if (g_supported == false) {
+               EXPECT_EQ(tts_check_screen_reader_on(g_tts, &is_on), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_check_screen_reader_on(g_tts, &is_on), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_check_screen_reader_on_p2
+ * @since_tizen                6.5
+ * @description                Positive UTC for checking screen reader on
+ */
+TEST_F(TTSTest, utc_tts_check_screen_reader_on_p2)
+{
+       bool is_on = false;
+       if (g_supported == false) {
+               EXPECT_EQ(tts_check_screen_reader_on(g_tts, &is_on), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_mode(g_tts, TTS_MODE_SCREEN_READER), TTS_ERROR_NONE);
+
+       EXPECT_EQ(vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, false), 0);
+       EXPECT_EQ(tts_check_screen_reader_on(g_tts, &is_on), TTS_ERROR_NONE);
+
+       EXPECT_EQ(is_on, false);
+}
+
+/**
+ * @testcase           utc_tts_check_screen_reader_on_n
+ * @since_tizen                6.5
+ * @description                Negative UTC for checking screen reader on (invalid parameter)
+ */
+TEST_F(TTSTest, utc_tts_check_screen_reader_on_n)
+{
+       bool is_on = false;
+       if (g_supported == false) {
+               EXPECT_EQ(tts_check_screen_reader_on(g_tts, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_check_screen_reader_on(g_tts, nullptr), TTS_ERROR_INVALID_PARAMETER);
+       EXPECT_EQ(tts_check_screen_reader_on(nullptr, &is_on), TTS_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase           utc_tts_set_screen_reader_changed_cb_p
+ * @since_tizen                6.5
+ * @description                Positive UTC for set screen reader changed callback
+ */
+TEST_F(TTSTest, utc_tts_set_screen_reader_changed_cb_p)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_set_screen_reader_changed_cb_p2
+ * @since_tizen                6.5
+ * @description                Positive UTC for invoking screen reader changed callback
+ */
+TEST_F(TTSTest, utc_tts_set_screen_reader_changed_cb_p2)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       g_screen_reader_changed_cb = false;
+       EXPECT_EQ(vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, true), 0);
+       EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_NONE);
+
+       EXPECT_EQ(vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, false), 0);
+       EXPECT_EQ(__is_screen_reader_changed(5), true);
+}
+
+/**
+ * @testcase           utc_tts_set_screen_reader_changed_cb_n
+ * @since_tizen                6.5
+ * @description                Negative UTC for set screen reader changed callback (Invalid handle)
+ */
+TEST_F(TTSTest, utc_tts_set_screen_reader_changed_cb_n)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_screen_reader_changed_cb(nullptr, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(tts_set_screen_reader_changed_cb(nullptr, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase           utc_tts_set_screen_reader_changed_cb_n2
+ * @since_tizen                6.5
+ * @description                Negative UTC for set screen reader changed callback (Invalid parameter)
+ */
+TEST_F(TTSTest, utc_tts_set_screen_reader_changed_cb_n2)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, nullptr, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, nullptr, nullptr), TTS_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase           utc_tts_set_screen_reader_changed_cb_n2
+ * @since_tizen                6.5
+ * @description                Negative UTC for set screen reader changed callback (Invalid state)
+ */
+TEST_F(TTSPreparedTest, utc_tts_set_screen_reader_changed_cb_n2)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase           utc_tts_unset_screen_reader_changed_cb_p
+ * @since_tizen                6.5
+ * @description                Positive UTC for unset screen reader changed callback
+ */
+TEST_F(TTSTest, utc_tts_unset_screen_reader_changed_cb_p)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_unset_screen_reader_changed_cb(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_unset_screen_reader_changed_cb(g_tts), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_unset_screen_reader_changed_cb_n
+ * @since_tizen                6.5
+ * @description                Negative UTC for unset screen reader changed callback (Invalid handle)
+ */
+TEST_F(TTSTest, utc_tts_unset_screen_reader_changed_cb_n)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_unset_screen_reader_changed_cb(nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(tts_unset_screen_reader_changed_cb(nullptr), TTS_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase           utc_tts_unset_screen_reader_changed_cb_n2
+ * @since_tizen                6.5
+ * @description                Negative UTC for unset screen reader changed callback (Invalid state)
+ */
+TEST_F(TTSTest, utc_tts_unset_screen_reader_changed_cb_n2)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_unset_screen_reader_changed_cb(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_screen_reader_changed_cb(g_tts, __tts_screen_reader_changed_cb, nullptr), TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+
+       EXPECT_EQ(tts_unset_screen_reader_changed_cb(g_tts), TTS_ERROR_INVALID_STATE);
+
+       EXPECT_EQ(tts_unprepare(g_tts), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_set_engine_changed_cb_p
+ * @since_tizen                3.0
+ * @description                Positive UTC for set current engine changed callback
+ */
+TEST_F(TTSTest, utc_tts_set_engine_changed_cb_p)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_engine_changed_cb(g_tts, __tts_engine_changed_cb, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_engine_changed_cb(g_tts, __tts_engine_changed_cb, nullptr), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_set_engine_changed_cb_n
+ * @since_tizen                3.0
+ * @description                Negative UTC for set current engine changed callback (Invalid handle)
+ */
+TEST_F(TTSTest, utc_tts_set_engine_changed_cb_n)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_engine_changed_cb(nullptr, __tts_engine_changed_cb, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(tts_set_engine_changed_cb(nullptr, __tts_engine_changed_cb, nullptr), TTS_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase           utc_tts_set_engine_changed_cb_n2
+ * @since_tizen                3.0
+ * @description                Negative UTC for set current engine changed callback (Invalid state)
+ */
+TEST_F(TTSPreparedTest, utc_tts_set_engine_changed_cb_n2)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_set_engine_changed_cb(g_tts, __tts_engine_changed_cb, nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_engine_changed_cb(g_tts, __tts_engine_changed_cb, nullptr), TTS_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase           utc_tts_unset_engine_changed_cb_p
+ * @since_tizen                3.0
+ * @description                Positive UTC for unset current engine changed callback
+ */
+TEST_F(TTSTest, utc_tts_unset_engine_changed_cb_p)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_unset_engine_changed_cb(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_engine_changed_cb(g_tts, __tts_engine_changed_cb, nullptr), TTS_ERROR_NONE);
+       EXPECT_EQ(tts_unset_engine_changed_cb(g_tts), TTS_ERROR_NONE);
+}
+
+/**
+ * @testcase           utc_tts_unset_engine_changed_cb_n
+ * @since_tizen                3.0
+ * @description                Negative UTC for unset current engine changed callback (Invalid handle)
+ */
+TEST_F(TTSTest, utc_tts_unset_engine_changed_cb_n)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_unset_engine_changed_cb(nullptr), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(tts_unset_engine_changed_cb(nullptr), TTS_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase           utc_tts_unset_engine_changed_cb_n2
+ * @since_tizen                3.0
+ * @description                Negative UTC for unset current engine changed callback (Invalid state)
+ */
+TEST_F(TTSTest, utc_tts_unset_engine_changed_cb_n2)
+{
+       if (g_supported == false) {
+               EXPECT_EQ(tts_unset_engine_changed_cb(g_tts), TTS_ERROR_NOT_SUPPORTED);
+               return;
+       }
+
+       EXPECT_EQ(is_created_hndl, TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_set_engine_changed_cb(g_tts, __tts_engine_changed_cb, nullptr), TTS_ERROR_NONE);
+
+       EXPECT_EQ(tts_prepare(g_tts), TTS_ERROR_NONE);
+       EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
+
+       EXPECT_EQ(tts_unset_engine_changed_cb(g_tts), TTS_ERROR_INVALID_STATE);
+
+       EXPECT_EQ(tts_unprepare(g_tts), TTS_ERROR_NONE);
+}
+
+/**
  * @testcase           utc_tts_add_pcm_p
  * @since_tizen                2.3
  * @description                test whether pcm data is added properly.