Refactor tts handle check code 98/248498/9
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 13 Nov 2020 09:47:44 +0000 (18:47 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 18 Mar 2021 07:58:30 +0000 (16:58 +0900)
To apply unity code to check tts handle, this patch fixes handle check code of each API.

Change-Id: I8168bf04321f81f365a3f38060281b0a922776c9
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts.c
client/tts_core.c
client/tts_dbus.c

index a30f92b..d2c3e68 100644 (file)
@@ -180,7 +180,7 @@ static Eina_Bool __reconnect_by_engine_changed(void* data)
 
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[WARNING] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return EINA_FALSE;
        }
 
@@ -208,7 +208,7 @@ void _tts_config_engine_changed_cb(const char* engine_id, const char* setting, c
 
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[WARNING] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return;
        }
 
@@ -253,10 +253,8 @@ int tts_create(tts_h* tts)
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Create TTS");
 
-       /* check param */
        if (NULL == tts) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -340,16 +338,9 @@ int tts_destroy(tts_h tts)
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Destroy TTS");
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
-       /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -501,11 +492,8 @@ int tts_set_mode(tts_h tts, tts_mode_e mode)
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Set TTS mode(%d)", mode);
 
        tts_client_s* client = tts_client_get(tts);
-
-       /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -550,12 +538,8 @@ int tts_get_mode(tts_h tts, tts_mode_e* mode)
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Get TTS mode");
 
        tts_client_s* client = tts_client_get(tts);
-
-       /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -584,15 +568,14 @@ int tts_set_credential(tts_h tts, const char* credential)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       if (NULL == tts || NULL == credential) {
+       if (NULL == credential) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -620,15 +603,9 @@ int tts_set_server_tts(tts_h tts, const char* credential)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -708,10 +685,8 @@ int tts_prepare(tts_h tts)
        }
 
        tts_client_s* client = tts_client_get(tts);
-
-       /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -741,10 +716,8 @@ int tts_prepare_sync(tts_h tts)
        }
 
        tts_client_s* client = tts_client_get(tts);
-
-       /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -774,10 +747,8 @@ int tts_unprepare(tts_h tts)
        }
 
        tts_client_s* client = tts_client_get(tts);
-
-       /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -795,7 +766,7 @@ int tts_unprepare(tts_h tts)
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader(%d)", ret);
        }
 
-       ret = tts_core_unprepare(tts_client_get(tts), g_screen_reader);
+       ret = tts_core_unprepare(client, g_screen_reader);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] tts_core_unprepare is failed(%s)", __tts_get_error_code(ret));
                return ret;
@@ -814,16 +785,14 @@ int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, voi
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Foreach supported voices");
 
-       if (NULL == tts || NULL == callback) {
+       if (NULL == callback) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
-
-       /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -858,17 +827,14 @@ int tts_get_default_voice(tts_h tts, char** lang, int* vctype)
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Get default voice");
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+       if (NULL == lang || NULL == vctype) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
                return TTS_ERROR_INVALID_PARAMETER;
-
        }
-       tts_client_s* client = tts_client_get(tts);
 
+       tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -893,15 +859,14 @@ int tts_get_max_text_size(tts_h tts, unsigned int* size)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       if (NULL == tts || NULL == size) {
+       if (NULL == size) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get max text count : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get max text count : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -913,6 +878,7 @@ int tts_get_max_text_size(tts_h tts, unsigned int* size)
 
        if (0 != tts_config_mgr_get_max_text_size(size)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get max text size");
+               // TODO: fix return value to operation failed
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -928,15 +894,14 @@ int tts_get_state(tts_h tts, tts_state_e* state)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       if (NULL == tts || NULL == state) {
+       if (NULL == state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -964,15 +929,14 @@ int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       if (NULL == tts || NULL == min || NULL == normal || NULL == max) {
+       if (NULL == min || NULL == normal || NULL == max) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -989,15 +953,14 @@ int tts_get_error_message(tts_h tts, char** err_msg)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       if (NULL == tts || NULL == err_msg) {
+       if (NULL == err_msg) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1016,14 +979,14 @@ int tts_get_error_message(tts_h tts, char** err_msg)
 
 int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id)
 {
-       SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Add text: text(%s), language(%s), type(%d)", (NULL == text) ? "NULL" : text, (NULL == language) ? "NULL" : language, voice_type);
-
        if (0 != __tts_get_feature_enabled()) {
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       if (speed < 0) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Speed should not be negative(%d)", speed);
+       SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Add text: text(%s), language(%s), type(%d)", (NULL == text) ? "NULL" : text, (NULL == language) ? "NULL" : language, voice_type);
+
+       if (TTS_SPEED_AUTO > speed || TTS_SPEED_MAX < speed) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] speed value(%d) is invalid.", speed);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1032,21 +995,14 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Add text");
-
-       int ret = -1;
-
-       if (NULL == tts || NULL == utt_id) {
+       if (NULL == utt_id) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1056,12 +1012,7 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
                return TTS_ERROR_INVALID_STATE;
        }
 
-       if (TTS_SPEED_AUTO > speed || TTS_SPEED_MAX < speed) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] speed value(%d) is invalid.", speed);
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
+       int ret = -1;
        if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
                /* check screen reader option one more time */
                ret = __tts_recheck_screen_reader();
@@ -1081,6 +1032,7 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
                return TTS_ERROR_PERMISSION_DENIED;
        }
 
+       // TODO: move up to parameter check
        /* check valid utf8 */
        bool valid = false;
 
@@ -1104,9 +1056,11 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
                SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] g_max_text_size is %d byte", g_max_text_size);
                if (0 != tts_config_mgr_get_max_text_size((unsigned int*)&g_max_text_size)) {
                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get max text size");
+                       // TODO: fix to operation failed
                        return TTS_ERROR_INVALID_PARAMETER;
                }
        }
+       // TODO: move up to parameter check
 
        if (0 == g_max_text_size) {
                if (strlen(text) <= 0) {
@@ -1207,11 +1161,10 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
 static void __tts_play_async(void *data)
 {
        tts_h tts = (tts_h)data;
-       tts_client_s* client = tts_client_get(tts);
 
-       /* check handle */
+       tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return;
        }
 
@@ -1263,17 +1216,9 @@ int tts_play_async(tts_h tts)
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Play tts");
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1320,18 +1265,9 @@ int tts_play(tts_h tts)
 
        int ret = -1;
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1399,11 +1335,10 @@ int tts_play(tts_h tts)
 static void __tts_stop_async(void *data)
 {
        tts_h tts = (tts_h)data;
-       tts_client_s* client = tts_client_get(tts);
 
-       /* check handle */
+       tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return;
        }
 
@@ -1455,17 +1390,9 @@ int tts_stop_aync(tts_h tts)
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Stop tts");
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1504,19 +1431,9 @@ int tts_stop(tts_h tts)
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Stop tts");
 
-       int ret = -1;
-
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1526,6 +1443,7 @@ int tts_stop(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
+       int ret = -1;
        if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
                /* check screen reader option one more time */
                ret = __tts_recheck_screen_reader();
@@ -1578,11 +1496,10 @@ int tts_stop(tts_h tts)
 static void __tts_pause_async(void *data)
 {
        tts_h tts = (tts_h)data;
-       tts_client_s* client = tts_client_get(tts);
 
-       /* check handle */
+       tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return;
        }
 
@@ -1634,17 +1551,9 @@ int tts_pause_async(tts_h tts)
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Pause tts");
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1682,19 +1591,9 @@ int tts_pause(tts_h tts)
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Pause tts");
 
-       int ret = -1;
-
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1704,6 +1603,7 @@ int tts_pause(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
+       int ret = -1;
        if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
                ret = __tts_recheck_screen_reader();
                if (0 != ret) {
@@ -1760,20 +1660,14 @@ int tts_set_private_data(tts_h tts, const char* key, const char* data)
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Set private data, key(%s), data(%s)", key, data);
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        if (NULL == key || NULL == data) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid parameter");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1830,20 +1724,14 @@ int tts_get_private_data(tts_h tts, const char* key, char** data)
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Get private data, key(%s)", key);
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        if (NULL == key || NULL == data) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid parameter");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1901,10 +1789,9 @@ int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* use
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1931,10 +1818,9 @@ int tts_unset_state_changed_cb(tts_h tts)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1956,10 +1842,9 @@ int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, v
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1987,10 +1872,9 @@ int tts_unset_utterance_started_cb(tts_h tts)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt started cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2013,10 +1897,9 @@ int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callbac
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt completed cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2044,10 +1927,9 @@ int tts_unset_utterance_completed_cb(tts_h tts)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt completed cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2069,10 +1951,9 @@ int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set error cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2100,10 +1981,9 @@ int tts_unset_error_cb(tts_h tts)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset error cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2126,10 +2006,9 @@ int tts_set_default_voice_changed_cb(tts_h tts, tts_default_voice_changed_cb cal
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set default voice changed cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2157,10 +2036,9 @@ int tts_unset_default_voice_changed_cb(tts_h tts)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset default voice changed cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2183,10 +2061,9 @@ int tts_set_engine_changed_cb(tts_h tts, tts_engine_changed_cb callback, void* u
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set engine changed cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2214,10 +2091,9 @@ int tts_unset_engine_changed_cb(tts_h tts)
                return TTS_ERROR_NOT_SUPPORTED;
        }
 
-       /* check handle */
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset engine changed cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2243,19 +2119,9 @@ int tts_add_pcm(tts_h tts, int event, const void* data, unsigned int data_size,
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Add pcm tts");
 
-       int ret = -1;
-
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2265,6 +2131,7 @@ int tts_add_pcm(tts_h tts, int event, const void* data, unsigned int data_size,
                return TTS_ERROR_INVALID_STATE;
        }
 
+       int ret = -1;
        if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
                ret = __tts_recheck_screen_reader();
                if (0 != ret) {
@@ -2318,19 +2185,9 @@ int tts_play_pcm(tts_h tts)
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Play pcm tts");
 
-       int ret = -1;
-
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2340,6 +2197,7 @@ int tts_play_pcm(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
+       int ret = -1;
        if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
                ret = __tts_recheck_screen_reader();
                if (0 != ret) {
@@ -2394,19 +2252,9 @@ int tts_stop_pcm(tts_h tts)
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Stop pcm tts");
 
-       int ret = -1;
-
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        tts_client_s* client = tts_client_get(tts);
-
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2416,6 +2264,7 @@ int tts_stop_pcm(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
+       int ret = -1;
        if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
                ret = __tts_recheck_screen_reader();
                if (0 != ret) {
@@ -2471,25 +2320,14 @@ int tts_repeat(tts_h tts, char** text_repeat, int* utt_id)
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Repeat TTS");
 
-       if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
        if (NULL == text_repeat || NULL == utt_id) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       *text_repeat = NULL;
-       *utt_id = -1;
-
        tts_client_s* client = tts_client_get(tts);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid.");
-               SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -2499,6 +2337,9 @@ int tts_repeat(tts_h tts, char** text_repeat, int* utt_id)
                return TTS_ERROR_INVALID_STATE;
        }
 
+       *text_repeat = NULL;
+       *utt_id = -1;
+
        /* Clear the legacy and Add texts to be played repeatedly */
        int ret = -1;
        ret = tts_stop(tts);
index 4c66a35..d7ac852 100644 (file)
@@ -147,7 +147,6 @@ static Eina_Bool __notify_error_timer_cb(void *data)
 {
        int uid = (int)data;
        tts_client_s* client = tts_client_get_by_uid(uid);
-       /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] UID is not valid. (%d)", uid);
        } else {
@@ -162,7 +161,6 @@ static Eina_Bool __notify_state_timer_cb(void *data)
 {
        int uid = (int)data;
        tts_client_s* client = tts_client_get_by_uid(uid);
-       /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] UID is not valid. (%d)", uid);
        } else {
@@ -468,13 +466,11 @@ static Eina_Bool __prepare_cb(void *data)
        int uid = (int)data;
        tts_client_s* client = tts_client_get_by_uid(uid);
 
-       /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return EINA_FALSE;
        }
 
-       /* check state */
        int ret = __send_hello_msg(client);
        if (ret != TTS_ERROR_NONE) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to send hello message"); //LCOV_EXCL_LINE
@@ -502,7 +498,6 @@ static Eina_Bool __prepare_first_cb(void *data)
        int uid = (int)data;
        tts_client_s* client = tts_client_get_by_uid(uid);
 
-       /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return EINA_FALSE;
@@ -650,7 +645,6 @@ int tts_core_deinitialize()
 
 int tts_core_notify_state_changed(tts_client_s* client, tts_state_e before_state, tts_state_e current_state)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -663,7 +657,6 @@ int tts_core_notify_state_changed(tts_client_s* client, tts_state_e before_state
 
 int tts_core_notify_state_changed_async(tts_client_s* client, tts_state_e before_state, tts_state_e current_state)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -681,7 +674,6 @@ int tts_core_notify_state_changed_async(tts_client_s* client, tts_state_e before
 
 int tts_core_notify_utt_started(tts_client_s* client, int utt_id)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -706,7 +698,6 @@ 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)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -731,7 +722,6 @@ int tts_core_notify_utt_completeted(tts_client_s* client, int utt_id)
 
 int tts_core_notify_error(tts_client_s* client, int utt_id, tts_error_e reason)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -745,7 +735,6 @@ int tts_core_notify_error(tts_client_s* client, int utt_id, tts_error_e reason)
 
 int tts_core_notify_error_async(tts_client_s* client, int utt_id, tts_error_e reason)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -766,7 +755,6 @@ int tts_core_notify_error_async(tts_client_s* client, int utt_id, tts_error_e re
 
 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)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -797,7 +785,6 @@ 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)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -889,7 +876,6 @@ const char* tts_core_get_engine_name()
 
 int tts_core_prepare(tts_client_s* client)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -911,7 +897,6 @@ int tts_core_prepare(tts_client_s* client)
 
 int tts_core_prepare_sync(tts_client_s* client)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -935,7 +920,6 @@ int tts_core_prepare_sync(tts_client_s* client)
 
 int tts_core_unprepare(tts_client_s* client, bool is_screen_reader_on)
 {
-       /* check handle */
        if (NULL == client || false == tts_client_is_valid(client->uid)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -999,7 +983,6 @@ int tts_core_unprepare(tts_client_s* client, bool is_screen_reader_on)
 
 int tts_core_reprepare()
 {
-       /* check handle */
        GList* clients = tts_client_get_client_list();
        if (NULL == clients) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get client list");
index dd8aae6..4100a6e 100644 (file)
@@ -516,8 +516,6 @@ DBusMessage* __tts_dbus_make_message(int uid, const char* method)
        }
 
        tts_client_s* client = tts_client_get_by_uid(uid);
-
-       /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] uid is not available");
                return NULL;