Change the step of checking utf8 validation and text size 06/227806/1
authorsooyeon.kim <sooyeon.kim@samsung.com>
Mon, 2 Mar 2020 04:30:44 +0000 (13:30 +0900)
committerSooyeon Kim <sooyeon.kim@samsung.com>
Mon, 16 Mar 2020 10:41:58 +0000 (10:41 +0000)
Change-Id: Idc42686df3e46dc6cea88e0bfbf6c0c2bc29f616
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
(cherry picked from commit dfc3cde49f4afb40f26a559573e04b3272057883)

client/tts.c

index 1637606..8676a5c 100644 (file)
@@ -1260,7 +1260,7 @@ int tts_get_max_text_size(tts_h tts, unsigned int* size)
 
        g_max_text_size = (int)*size;
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "Get max text count : %d", *size);
+       SLOG(LOG_INFO, TAG_TTSC, "Get max text size : %d byte", *size);
        return TTS_ERROR_NONE;
 }
 
@@ -1390,30 +1390,6 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
                return TTS_ERROR_INVALID_STATE;
        }
 
-       if (-1 == g_max_text_size) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] g_max_text_size is %d", 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");
-                       return TTS_ERROR_INVALID_PARAMETER;
-               }
-       }
-
-       if (0 == g_max_text_size) {
-               if (strlen(text) <= 0) {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] Max Text Size is %d", g_max_text_size);
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is invalid. (max text size is unlimited.)");
-                       SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-                       return TTS_ERROR_INVALID_PARAMETER;
-               }
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] g_max_text_size is %d", g_max_text_size);
-               if (g_max_text_size < strlen(text) || strlen(text) <= 0) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is invalid. current text_size(%d)", strlen(text));
-                       SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-                       return TTS_ERROR_INVALID_PARAMETER;
-               }
-       }
-
        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, "@@@");
@@ -1447,7 +1423,33 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Text is invalid - '%s'", text);
                return TTS_ERROR_INVALID_PARAMETER;
        }
-       SLOG(LOG_DEBUG, TAG_TTSC, "Text is valid - text is '%s'", text);
+
+       /* check text size */
+       if (-1 == g_max_text_size) {
+               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");
+                       return TTS_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       if (0 == g_max_text_size) {
+               if (strlen(text) <= 0) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] Max Text Size is %d byte", g_max_text_size);
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is invalid. (max text size is unlimited.)");
+                       SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+                       return TTS_ERROR_INVALID_PARAMETER;
+               }
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] g_max_text_size is %d byte", g_max_text_size);
+               if (g_max_text_size < strlen(text) || strlen(text) <= 0) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is invalid. current text_size(%d byte)", strlen(text));
+                       SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+                       return TTS_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "Text is valid - text(%d byte) is '%s'", strlen(text), text);
 
        /* save texts for repetition */
        if (NULL != client->text_repeat) {