From 5ab27cf3a0022b4e00bb1bf422a7a43656b37e25 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Wed, 12 May 2021 20:01:51 +0900 Subject: [PATCH] Wait TIDL connection when tts_prepare_sync() is called Change-Id: I97892140e896249c1cd90f86ba3c2810ce6e4473 Signed-off-by: Suyeon Hwang --- client/tts_tidl.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/client/tts_tidl.c b/client/tts_tidl.c index 130f2d7..555f373 100644 --- a/client/tts_tidl.c +++ b/client/tts_tidl.c @@ -19,6 +19,7 @@ #include "tts_core.h" #define MAXSLEEP 128 +#define MAX_CONNECT_CHECK 100 typedef struct { int uid; @@ -270,7 +271,7 @@ static void __get_engine_app_id(int mode, int size, char* app_id) SLOG(LOG_INFO, TAG_TTSC, "engine app id : %s", app_id); } -static rpc_port_proxy_tts_h __open_rpc_port(int uid, int mode) +static rpc_port_proxy_tts_h __create_rpc_port(int uid, int mode) { char engine_app_id[256] = {0, }; __get_engine_app_id(mode, 256, engine_app_id); @@ -308,9 +309,9 @@ int tts_tidl_open_connection(int uid) } tts_mode_e mode = tts_client_get_mode(client); - info->rpc_h = __open_rpc_port(uid, mode); + info->rpc_h = __create_rpc_port(uid, mode); if (NULL == info->rpc_h) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open proxy"); + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create proxy"); free(info); return TTS_ERROR_OPERATION_FAILED; } @@ -381,14 +382,14 @@ int tts_tidl_request_hello(int uid) if (info->mode != client->mode) { SLOG(LOG_INFO, TAG_TTSC, "[TIDL] tts mode is changed from (%d) to (%d)", info->mode, client->mode); - if (NULL != info->rpc_h && 0 != rpc_port_proxy_tts_destroy(info->rpc_h)) { + if (0 != rpc_port_proxy_tts_destroy(info->rpc_h)) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to destroy old rpc_port"); return TTS_ERROR_OPERATION_FAILED; } - info->rpc_h = __open_rpc_port(uid, client->mode); + info->rpc_h = __create_rpc_port(uid, client->mode); if (NULL == info->rpc_h) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open proxy"); + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create proxy"); return TTS_ERROR_OPERATION_FAILED; } info->mode = client->mode; @@ -414,6 +415,22 @@ 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++; + } + + if (false == info->connected) { + return TTS_ERROR_OPERATION_FAILED; + } + + return TTS_ERROR_NONE; +} + int tts_tidl_request_hello_sync(int uid) { SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_hello"); @@ -431,8 +448,14 @@ int tts_tidl_request_hello_sync(int uid) } if (!info->connected) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not Connected"); - return TTS_ERROR_OPERATION_FAILED; + 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"); + return TTS_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_INFO, TAG_TTSC, "[TIDL] Stub is Connected"); } SLOG(LOG_DEBUG, TAG_TTSC, ">>>>> TTS Hello"); -- 2.7.4