Merge "Remove unnecessary timer" into tizen
authorWonnam Jang <wn.jang@samsung.com>
Wed, 5 Dec 2018 11:55:04 +0000 (11:55 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Wed, 5 Dec 2018 11:55:04 +0000 (11:55 +0000)
1  2 
client/tts.c

diff --combined client/tts.c
@@@ -37,9 -37,6 +37,9 @@@ static bool g_err_callback_status = fal
  
  static int g_max_text_size = -1;
  
 +static Ecore_Timer* g_check_state_timer = NULL;
 +
 +
  /* for repetition */
  static char* g_language = NULL;
  
@@@ -383,12 -380,6 +383,12 @@@ int tts_destroy(tts_h tts
                g_language = NULL;
        }
  
 +      /* Delete state timer before destroying handle */
 +      if (NULL != g_check_state_timer) {
 +              ecore_timer_del(g_check_state_timer);
 +              g_check_state_timer = NULL;
 +      }
 +
        tts = NULL;
  
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
@@@ -647,7 -638,10 +647,10 @@@ static Eina_Bool __tts_connect_daemon(v
                client->utt_id = -1;
  
                ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
-               client->conn_timer = NULL;
+               if (client->conn_timer) {
+                       ecore_timer_del(client->conn_timer);
+                       client->conn_timer = NULL;
+               }
                return EINA_FALSE;
  
        } else if (TTS_ERROR_PERMISSION_DENIED == ret) {
                client->utt_id = -1;
  
                ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
-               client->conn_timer = NULL;
+               if (client->conn_timer) {
+                       ecore_timer_del(client->conn_timer);
+                       client->conn_timer = NULL;
+               }
                return EINA_FALSE;
  
        } else if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "Supported options : credential(%s)", credential_needed ? "need" : "no need");
        }
  
-       client->conn_timer = NULL;
+       if (client->conn_timer) {
+               ecore_timer_del(client->conn_timer);
+               client->conn_timer = NULL;
+       }
  
        client = tts_client_get(tts);
        /* check handle */
@@@ -720,6 -720,10 +729,10 @@@ int tts_prepare(tts_h tts
        }
  
        ecore_thread_main_loop_begin();
+       if (client->conn_timer) {
+               ecore_timer_del(client->conn_timer);
+               client->conn_timer = NULL;
+       }
        client->conn_timer = ecore_timer_add(0.02, __tts_connect_daemon, (void*)tts);
        ecore_thread_main_loop_end();
  
@@@ -2093,11 -2097,7 +2106,11 @@@ int __tts_cb_set_state(int uid, int sta
        }
  
        if (NULL != client->state_changed_cb) {
 -              ecore_timer_add(0, __tts_notify_state_changed, client->tts);
 +              if (NULL != g_check_state_timer) {
 +                      ecore_timer_del(g_check_state_timer);
 +                      g_check_state_timer = NULL;
 +              }
 +              g_check_state_timer = ecore_timer_add(0, __tts_notify_state_changed, client->tts);
        } else {
                SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
        }
@@@ -2218,11 -2218,6 +2231,11 @@@ int tts_unset_state_changed_cb(tts_h tt
        client->state_changed_cb = NULL;
        client->state_changed_user_data = NULL;
  
 +      if (NULL != g_check_state_timer) {
 +              ecore_timer_del(g_check_state_timer);
 +              g_check_state_timer = NULL;
 +      }
 +
        SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset state changed cb");
  
        return 0;