#include "tts_core.h"
#define MAXSLEEP 128
+#define MAX_CONNECT_CHECK 100
typedef struct {
int uid;
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);
}
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;
}
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;
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");
}
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");