Use tidl synchronous connect for tts_prepare_sync() 29/265429/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Tue, 19 Oct 2021 07:59:05 +0000 (16:59 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Wed, 20 Oct 2021 04:40:38 +0000 (13:40 +0900)
Change-Id: I58652521adaf9bf4faee8225e5998d28bb707a5d
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts_tidl.c

index 5937899..8bf0f06 100644 (file)
@@ -416,20 +416,25 @@ int tts_tidl_request_hello(int uid)
        return TTS_ERROR_NONE;
 }
 
-static int __wait_tidl_connection(tts_tidl_info_s* info)
-{
-       int cnt = 0;
-       while (false == info->connected && MAX_CONNECT_CHECK > cnt) {
-               ecore_main_loop_iterate();
-               usleep(50000);
-               cnt++;
+static int __request_tidl_connect_sync(tts_tidl_info_s* info) {
+       int ret = rpc_port_proxy_tts_connect_sync(info->rpc_h);
+       SLOG(LOG_INFO, TAG_TTSC, "[INFO] Request connection to stub. ret(%d)", ret);
+       if (RPC_PORT_ERROR_NONE == ret) {
+               return TTS_ERROR_NONE;
        }
 
-       if (false == info->connected) {
+       if (0 != rpc_port_proxy_tts_destroy(info->rpc_h)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to disconnect");
                return TTS_ERROR_OPERATION_FAILED;
        }
 
-       return TTS_ERROR_NONE;
+       info->rpc_h = __create_rpc_port(info->uid, info->engine_app_id);
+       if (NULL == info->rpc_h) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create proxy");
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       return TTS_ERROR_OPERATION_FAILED;
 }
 
 int tts_tidl_request_hello_sync(int uid)
@@ -450,9 +455,9 @@ int tts_tidl_request_hello_sync(int uid)
 
        if (!info->connected) {
                SLOG(LOG_WARN, TAG_TTSC, "[WARNNING] Stub is not Connected. Try to connect..");
-               rpc_port_proxy_tts_connect(info->rpc_h);
-               if (TTS_ERROR_NONE != __wait_tidl_connection(info)) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connect");
+               int ret = __request_tidl_connect_sync(info);
+               if (TTS_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connect. ret(%d)", ret);
                        return TTS_ERROR_OPERATION_FAILED;
                }