Remove tts_core_notify_state_changed_async() to assure callback invocation 01/275001/3
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 13 May 2022 07:46:22 +0000 (16:46 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Thu, 16 Jun 2022 09:07:06 +0000 (09:07 +0000)
- Issue:
Sometimes, if client calls tts_play() very quickly, then the first state changed callback which
shows the change from 'created' to 'ready' state is skipped.

- Solution:
This patch removes the tts_core_notify_state_changed_async() function in order to make sure that
the first state changed callback is called. tts_core_notify_state_changed_async() can not assure
the callback invocation of all state changed because state of client can be changed between timer
register and its actual invocation. And also, without this function, calback invocation does not
block the main loop because all the callers of this function is called by ipc message.
Thus, by this patch, client can assure that the state changed callback is always invoked when
the state is changed.

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

index 2664af8..d7864f6 100644 (file)
@@ -139,20 +139,6 @@ static Eina_Bool __notify_error_timer_cb(void *data)
        return EINA_FALSE;
 }
 
-static Eina_Bool __notify_state_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_state_changed_cb(client, client->before_state, client->current_state);
-               client->notify_state_timer = NULL;
-       }
-
-       return EINA_FALSE;
-}
-
 static bool __is_engine_installed(const char* appid)
 {
        app_info_h app_info = NULL;
@@ -752,31 +738,6 @@ int tts_core_notify_state_changed(tts_client_s* client, tts_state_e current_stat
        return TTS_ERROR_NONE;
 }
 
-int tts_core_notify_state_changed_async(tts_client_s* client, tts_state_e current_state)
-{
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
-       tts_state_e before_state = tts_client_get_current_state(client);
-       if (before_state == current_state) {
-               SLOG(LOG_INFO, TAG_TTSC, "[INFO] State is not changed. before(%s), current(%s)", __convert_state(before_state), __convert_state(current_state));
-               return TTS_ERROR_NONE;
-       }
-
-       SLOG(LOG_DEBUG, TAG_TTSC, "Notify state changed asynchronously");
-       tts_client_set_current_state(client, current_state);
-       if (NULL != client->notify_state_timer) {
-               ecore_timer_del(client->notify_state_timer);
-       }
-
-       uintptr_t uid = tts_client_get_uid(client);
-       client->notify_state_timer = ecore_timer_add(0, __notify_state_timer_cb, (void*)uid);
-
-       return TTS_ERROR_NONE;
-}
-
 int tts_core_notify_utt_started(tts_client_s* client, int utt_id)
 {
        if (false == tts_client_is_valid_client(client)) {
@@ -1042,7 +1003,7 @@ int tts_core_receive_hello(unsigned int uid, int ret, int credential_needed)
 
        tts_ipc_request_set_mode(uid, tts_client_get_mode(client));
 
-       tts_core_notify_state_changed_async(client, TTS_STATE_READY);
+       tts_core_notify_state_changed(client, TTS_STATE_READY);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
        return TTS_ERROR_NONE;
index 7ef8756..c2e6beb 100644 (file)
@@ -23,7 +23,6 @@ extern "C" {
 
 // common function
 int tts_core_notify_state_changed(tts_client_s* client, tts_state_e current_state);
-int tts_core_notify_state_changed_async(tts_client_s* client, tts_state_e current_state);
 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);
 int tts_core_notify_error_async(tts_client_s* client, tts_error_e reason, int utt_id, const char* err_msg);
index 41e3344..ebdccc5 100644 (file)
@@ -179,7 +179,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                                dbus_error_free(&err);
                        }
 
-                       if (0 == tts_core_notify_state_changed_async(tts_client_get_by_uid(uid), (tts_state_e)state)) {
+                       if (0 == tts_core_notify_state_changed(tts_client_get_by_uid(uid), (tts_state_e)state)) {
                                SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts state changed : uid(%u) state(%d)", uid, state);
                        }
                } /* TTSD_SIGNAL_SET_STATE */
index 5f42bff..1ed6a3b 100644 (file)
@@ -125,7 +125,7 @@ static void __notify_cb(void *user_data, int pid, int uid, bundle *msg)
        } else if (0 == strncmp(TTSD_METHOD_SET_STATE, method, strlen(TTSD_METHOD_SET_STATE))) {
                bundle_get_str(msg, TTS_BUNDLE_MESSAGE, &val);
                if (val) {
-                       tts_core_notify_state_changed_async(client, (tts_state_e)atoi(val));
+                       tts_core_notify_state_changed(client, (tts_state_e)atoi(val));
                }
        } else if (0 == strncmp(TTSD_METHOD_ERROR, method, strlen(TTSD_METHOD_ERROR))) {
                char *uttid = NULL;