Move code for checking screen reader status into tts_core 06/257106/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Wed, 18 Nov 2020 06:38:58 +0000 (15:38 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 27 May 2021 04:45:11 +0000 (13:45 +0900)
Change-Id: Iba167a7fe003d95c9de8ba147b8be2806d6b9a61
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts.c
client/tts_core.c
client/tts_core.h

index d3e32fd..5aa2858 100644 (file)
@@ -32,8 +32,6 @@
 
 #include "tts_internal.h"
 
-static bool g_screen_reader;
-
 static int g_feature_enabled = -1;
 
 static int g_max_text_size = -1;
@@ -111,25 +109,6 @@ static int __tts_convert_config_error_code(tts_config_error_e code)
        return code;
 }
 
-static int __tts_recheck_screen_reader()
-{
-       SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] Check screen reader again");
-
-       int ret = -1;
-       int screen_reader = 0;
-
-       ret = vconf_get_bool(TTS_ACCESSIBILITY_KEY, &screen_reader);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-               return TTS_ERROR_INVALID_STATE;
-       } else {
-               SLOG(LOG_INFO, TAG_TTSC, "[INFO] Current screen reader status(%d)", screen_reader);
-               g_screen_reader = (bool)screen_reader;
-       }
-
-       return TTS_ERROR_NONE;
-}
-
 //LCOV_EXCL_START
 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)
 {
@@ -153,6 +132,7 @@ void __tts_config_voice_changed_cb(const char* before_lang, int before_voice_typ
 
                while (NULL != iter) {
                        data = iter->data;
+                       // TODO: add client validation check code
                        tts_core_notify_default_voice_changed(data, before_lang, before_voice_type, language, voice_type);
 
                        /* Check whether language is changed or not. If it is changed, make 'text_repeat' NULL */
@@ -355,9 +335,6 @@ int tts_destroy(tts_h tts)
                client->hello_timer = NULL;
        }
 
-       int ret = -1;
-       int count = 0;
-
        tts_state_e current_state = tts_client_get_current_state(client);
        if (TTS_STATE_INVALID == current_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client is not valid");
@@ -368,46 +345,9 @@ int tts_destroy(tts_h tts)
        case TTS_STATE_PAUSED:
        case TTS_STATE_PLAYING:
        case TTS_STATE_READY:
-               // TODO: fix to core_unprepare
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader(%d)", ret);
-               }
-
-               tts_mode_e mode = tts_client_get_mode(client);
-               SLOG(LOG_INFO, TAG_TTSC, "[INFO] g_screen_reader(%s), mode(%d)", (true == g_screen_reader) ? "True" : "False", mode);
-
-               if (!(false == g_screen_reader && TTS_MODE_SCREEN_READER == mode)) {
-                       do {
-                               ret = tts_ipc_request_finalize(client->uid);
-                               if (0 != ret) {
-                                       //LCOV_EXCL_START
-                                       if (TTS_ERROR_TIMED_OUT != ret) {
-                                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
-                                               break;
-                                       } else {
-                                               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry finalize");
-                                               usleep(10000);
-                                               count++;
-                                               if (TTS_RETRY_COUNT == count) {
-                                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
-                                                       break;
-                                               }
-                                       }
-                                       //LCOV_EXCL_STOP
-                               }
-                       } while (0 != ret);
-               } else {
-                       SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize : g_sr(%d) mode(%d)", g_screen_reader, mode);
-
-                       ret = tts_ipc_stop_listening(client->uid);
-                       if (0 != ret) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to remove match : %s", __tts_get_error_code(ret));
-                       }
+               if (0 != tts_core_unprepare(client)) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to unprepare");
                }
-
-               tts_client_set_current_state(client, TTS_STATE_CREATED);
-
        case TTS_STATE_CREATED:
                /* Unset registered callbacks */
                tts_client_unset_all_cb(client);
@@ -458,13 +398,6 @@ int tts_destroy(tts_h tts)
        return TTS_ERROR_NONE;
 }
 
-//LCOV_EXCL_START
-void __tts_screen_reader_changed_cb(bool value)
-{
-       g_screen_reader = value;
-}
-//LCOV_EXCL_STOP
-
 int tts_set_mode(tts_h tts, tts_mode_e mode)
 {
        if (0 != __tts_get_feature_enabled()) {
@@ -490,18 +423,10 @@ int tts_set_mode(tts_h tts, tts_mode_e mode)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       tts_client_set_mode(client, mode);
-
-       if (TTS_MODE_SCREEN_READER == mode) {
-               int ret;
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[Config ERROR] Fail to get screen reader(%d)", ret);
-                       return TTS_ERROR_OPERATION_FAILED;
-               }
-               tts_config_set_screen_reader_callback(client->uid, __tts_screen_reader_changed_cb);
-       } else {
-               tts_config_unset_screen_reader_callback(client->uid);
+       int ret = tts_core_set_mode(client, mode);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set mode to client. ret(%d)", ret);
+               return ret;
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
@@ -570,7 +495,6 @@ int tts_set_credential(tts_h tts, const char* credential)
        client->credential = strdup(credential);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-
        return TTS_ERROR_NONE;
 }
 
@@ -737,14 +661,7 @@ int tts_unprepare(tts_h tts)
        }
 
        SLOG(LOG_INFO, TAG_TTSC, "@@@ Unprepare TTS");
-
-       int ret = -1;
-       ret = __tts_recheck_screen_reader();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader(%d)", ret);
-       }
-
-       ret = tts_core_unprepare(client, g_screen_reader);
+       int ret = tts_core_unprepare(client);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] tts_core_unprepare is failed(%s)", __tts_get_error_code(ret));
                return ret;
@@ -994,19 +911,9 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
                return TTS_ERROR_INVALID_STATE;
        }
 
-       int ret = -1;
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == tts_client_get_mode(client)) {
-               /* check screen reader option one more time */
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
        if (true == client->credential_needed && NULL == client->credential) {
@@ -1052,7 +959,7 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
        }
 
        /* do request */
-       ret = -1;
+       int ret = -1;
        int count = 0;
        bool is_prepared = false;
        while (0 != ret) {
@@ -1164,19 +1071,9 @@ int tts_play_async(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == tts_client_get_mode(client)) {
-               /* check screen reader vconf one more time */
-               int ret = -1;
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
        if (true == client->credential_needed && NULL == client->credential) {
@@ -1213,18 +1110,9 @@ int tts_play(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == tts_client_get_mode(client)) {
-               /* check screen reader option one more time */
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
        if (true == client->credential_needed && NULL == client->credential) {
@@ -1338,18 +1226,9 @@ int tts_stop_aync(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == tts_client_get_mode(client)) {
-               /* check screen reader option one more time */
-               int ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
        ecore_main_loop_thread_safe_call_async(__tts_stop_async, (void*)tts);
@@ -1379,22 +1258,12 @@ int tts_stop(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       int ret = -1;
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == tts_client_get_mode(client)) {
-               /* check screen reader option one more time */
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
-       ret = -1;
+       int ret = -1;
        int count = 0;
        bool is_prepared = false;
        while (0 != ret) {
@@ -1499,18 +1368,9 @@ int tts_pause_async(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == tts_client_get_mode(client)) {
-               /* check screen reader option one more time */
-               int ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
        ecore_main_loop_thread_safe_call_async(__tts_pause_async, (void*)tts);
@@ -1539,21 +1399,12 @@ int tts_pause(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       int ret = -1;
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == tts_client_get_mode(client)) {
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
-       ret = -1;
+       int ret = -1;
        int count = 0;
        bool is_prepared = false;
        while (0 != ret) {
@@ -2067,21 +1918,12 @@ 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 == tts_client_get_mode(client)) {
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
-       ret = -1;
+       int ret = -1;
        int count = 0;
        bool is_prepared = false;
        while (0 != ret) {
@@ -2133,21 +1975,12 @@ int tts_play_pcm(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       int ret = -1;
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == tts_client_get_mode(client)) {
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
-       ret = -1;
+       int ret = -1;
        int count = 0;
        bool is_prepared = false;
        while (0 != ret) {
@@ -2200,21 +2033,12 @@ int tts_stop_pcm(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       int ret = -1;
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == tts_client_get_mode(client)) {
-               ret = __tts_recheck_screen_reader();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
-                       return TTS_ERROR_INVALID_STATE;
-               } else {
-                       if (false == g_screen_reader) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
-                               return TTS_ERROR_INVALID_STATE;
-                       }
-               }
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is not available");
+               return TTS_ERROR_INVALID_STATE;
        }
 
-       ret = -1;
+       int ret = -1;
        int count = 0;
        bool is_prepared = false;
        while (0 != ret) {
index 6ba299a..055c517 100644 (file)
@@ -25,6 +25,8 @@
 /* Static variables */
 static volatile bool g_is_thread_canceled = false;
 
+static bool g_is_screen_reader_on = false;
+
 static char* g_engine_name = NULL;
 static int g_engine_update_status = 0;
 
@@ -359,6 +361,7 @@ static void __start_reprepare_thread(void* data, Ecore_Thread* thread)
                usleep(50000);
                cnt++;
 
+               // TODO: fix way to exit thread safely
                /* Checking thread is canceled or not */
                if (ecore_thread_check(g_reprepare_thread)) {
                        SLOG(LOG_WARN, TAG_TTSC, "[WARNING] client thread is canceled. Exit");
@@ -371,6 +374,7 @@ static void __start_reprepare_thread(void* data, Ecore_Thread* thread)
        while (g_engine_update_status && (NULL != g_pkgmgr)) {
                usleep(200000);
 
+               // TODO: fix way to exit thread safely
                /* Checking thread is canceled or not */
                if (ecore_thread_check(g_reprepare_thread)) {
                        SLOG(LOG_WARN, TAG_TTSC, "[WARNING] client thread is canceled. Exit");
@@ -602,6 +606,31 @@ static bool __supported_voice_cb(const char* engine_id, const char* language, in
        return false;
 }
 
+static int __update_screen_reader_state()
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] Update screen reader state");
+
+       int ret = -1;
+       int screen_reader = 0;
+       ret = vconf_get_bool(TTS_ACCESSIBILITY_KEY, &screen_reader);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       SLOG(LOG_INFO, TAG_TTSC, "[INFO] Current screen reader status(%d)", screen_reader);
+       g_is_screen_reader_on = (bool)screen_reader;
+
+       return TTS_ERROR_NONE;
+}
+
+//LCOV_EXCL_START
+static void __screen_reader_state_changed_cb(bool value)
+{
+       g_is_screen_reader_on = value;
+}
+//LCOV_EXCL_STOP
+
 /* Public functions */
 int tts_core_initialize()
 {
@@ -811,6 +840,28 @@ int tts_core_set_current_state(tts_client_s* client, tts_state_e state)
        return TTS_ERROR_NONE;
 }
 
+int tts_core_set_mode(tts_client_s* client, tts_mode_e mode)
+{
+       if (false == tts_client_is_valid_client(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] client is not valid");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       int uid = client->uid;
+       tts_client_set_mode(client, mode);
+       if (TTS_MODE_SCREEN_READER == mode) {
+               if (0 != __update_screen_reader_state()) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader state");
+                       return TTS_ERROR_OPERATION_FAILED;
+               }
+               tts_config_set_screen_reader_callback(uid, __screen_reader_state_changed_cb);
+       } else {
+               tts_config_unset_screen_reader_callback(uid);
+       }
+
+       return TTS_ERROR_NONE;
+}
+
 bool tts_core_is_valid_text(const char* text)
 {
        if (NULL == text) {
@@ -853,6 +904,31 @@ bool tts_core_is_valid_text(const char* text)
        return true;
 }
 
+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;
+       }
+
+       tts_mode_e mode = tts_client_get_mode(client);
+       if (false == g_is_screen_reader_on && TTS_MODE_SCREEN_READER == mode) {
+               /* check screen reader option one more time */
+               int ret = __update_screen_reader_state();
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get screen reader vconf(%d)", ret);
+                       return false;
+               }
+
+               if (false == g_is_screen_reader_on) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Screen reader option is NOT available.");
+                       return false;
+               }
+       }
+
+       return true;
+}
+
 int tts_core_receive_hello(int uid, int ret, int credential_needed)
 {
        tts_client_s* client = tts_client_get_by_uid(uid);
@@ -943,7 +1019,7 @@ int tts_core_prepare_sync(tts_client_s* client)
        return TTS_ERROR_NONE;
 }
 
-int tts_core_unprepare(tts_client_s* client, bool is_screen_reader_on)
+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.");
@@ -956,13 +1032,14 @@ int tts_core_unprepare(tts_client_s* client, bool is_screen_reader_on)
                client->hello_timer = NULL;
        }
 
+       __update_screen_reader_state();
        tts_mode_e mode = tts_client_get_mode(client);
-       SLOG(LOG_INFO, TAG_TTSC, "[INFO] screen_reader(%s), mode(%d)", (true == is_screen_reader_on) ? "True" : "False", mode);
+       SLOG(LOG_INFO, TAG_TTSC, "[INFO] screen_reader(%s), mode(%d)", (true == g_is_screen_reader_on) ? "True" : "False", mode);
 
        int ret = -1;
        int count = 0;
-       if (false == is_screen_reader_on && TTS_MODE_SCREEN_READER == mode) {
-               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize : is_screen_reader(%d) mode(%d)", is_screen_reader_on, mode);
+       if (false == g_is_screen_reader_on && TTS_MODE_SCREEN_READER == mode) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize : is_screen_reader(%d) mode(%d)", g_is_screen_reader_on, mode);
 
                ret = tts_ipc_stop_listening(client->uid);
                if (0 != ret) {
index ebf3d66..3374a5b 100644 (file)
@@ -31,7 +31,10 @@ 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);
 
 int tts_core_set_current_state(tts_client_s* client, tts_state_e state);
+int tts_core_set_mode(tts_client_s* client, tts_mode_e mode);
+
 bool tts_core_is_valid_text(const char* text);
+bool tts_core_check_screen_reader(tts_client_s* client);
 
 // called by tts.c
 int tts_core_initialize();
@@ -40,7 +43,7 @@ const char* tts_core_get_engine_name();
 
 int tts_core_prepare(tts_client_s* client);
 int tts_core_prepare_sync(tts_client_s* client);
-int tts_core_unprepare(tts_client_s* client, bool is_screen_reader_on);
+int tts_core_unprepare(tts_client_s* client);
 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);