From 7ee0bc81ecb9e77c742205ab0a046386d96c1ff5 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 29 Jul 2021 14:22:25 +0900 Subject: [PATCH] Create new proxy handle when engine is changed When engine is changed or mode is changed, client has to make new proxy handle to change stub app ID. Previous code creates new proxy handle only when mode is changed. So, if engine is changed, previous code does not connect new engine but the engine before changed. This patch makes the client creates new proxy handle not only when mode is changed, but also engine is changed. For checking engine change, information structure stores engine app id of current proxy handle. Change-Id: Ie59a18a4cbdc0862e636d326715b95d25a694003 Signed-off-by: Suyeon Hwang --- client/tts_tidl.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/client/tts_tidl.c b/client/tts_tidl.c index 8f5dcb3..8e3653f 100644 --- a/client/tts_tidl.c +++ b/client/tts_tidl.c @@ -26,7 +26,7 @@ typedef struct { bool connected; rpc_port_proxy_tts_h rpc_h; rpc_port_tts_notify_cb_h notify_cb_h; - int mode; + char* engine_app_id; } tts_tidl_info_s; static GList* g_tidl_infos = NULL; @@ -222,11 +222,8 @@ 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 __create_rpc_port(int uid, int mode) +static rpc_port_proxy_tts_h __create_rpc_port(int uid, const char* engine_app_id) { - char engine_app_id[256] = {0, }; - __get_engine_app_id(mode, 256, engine_app_id); - rpc_port_proxy_tts_callback_s rpc_callback = { .connected = __on_connected, .disconnected = __on_disconnected, @@ -260,14 +257,17 @@ int tts_tidl_open_connection(int uid) } tts_mode_e mode = tts_client_get_mode(client); - info->rpc_h = __create_rpc_port(uid, mode); + char engine_app_id[256] = {0, }; + __get_engine_app_id(mode, 256, engine_app_id); + + info->rpc_h = __create_rpc_port(uid, engine_app_id); if (NULL == info->rpc_h) { SLOG(LOG_ERROR, TAG_TTSC, "[TIDL ERROR] Fail to create proxy"); free(info); return TTS_ERROR_OPERATION_FAILED; } - info->mode = mode; + info->engine_app_id = strdup(engine_app_id); info->uid = uid; g_tidl_infos = g_list_append(g_tidl_infos, info); @@ -298,6 +298,10 @@ int tts_tidl_close_connection(int uid) info->rpc_h = NULL; info->notify_cb_h = NULL; + + free(info->engine_app_id); + info->engine_app_id = NULL; + g_tidl_infos = g_list_remove(g_tidl_infos, info); free(info); @@ -332,19 +336,24 @@ int tts_tidl_request_hello(int uid) return TTS_ERROR_INVALID_PARAMETER; } - if (info->mode != client->mode) { - SLOG(LOG_INFO, TAG_TTSC, "[TIDL] tts mode is changed from (%d) to (%d)", info->mode, client->mode); + tts_mode_e mode = tts_client_get_mode(client); + char engine_app_id[256] = {0, }; + __get_engine_app_id(mode, 256, engine_app_id); + + if (NULL == info->engine_app_id || 0 != strncmp(info->engine_app_id, engine_app_id, strlen(info->engine_app_id))) { + SLOG(LOG_INFO, TAG_TTSC, "[TIDL] tts engine is changed from (%s) to (%s)", info->engine_app_id, engine_app_id); 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 = __create_rpc_port(uid, client->mode); + info->rpc_h = __create_rpc_port(uid, engine_app_id); if (NULL == info->rpc_h) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create proxy"); return TTS_ERROR_OPERATION_FAILED; } - info->mode = client->mode; + free(info->engine_app_id); + info->engine_app_id = strdup(engine_app_id); } if (!info->connected) { -- 2.7.4