From: Suyeon Hwang Date: Wed, 5 Jan 2022 09:32:14 +0000 (+0900) Subject: Add credential field into app data on server side X-Git-Tag: submit/tizen_6.5/20220120.075056~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0916f9f4f3b4b14c90460294479a4f562ebf6f9;p=platform%2Fcore%2Fuifw%2Ftts.git Add credential field into app data on server side Change-Id: I7e0ddb44b6053c4cd6002414f3157e4a32640567 Signed-off-by: Suyeon Hwang --- diff --git a/server/ttsd_data.cpp b/server/ttsd_data.cpp index e0b86949..b15346ae 100644 --- a/server/ttsd_data.cpp +++ b/server/ttsd_data.cpp @@ -40,6 +40,8 @@ typedef struct std::list m_used_voice; tts_ipc_method_e ipc_method; + + char* credential; } app_data_s; static vector g_app_list; @@ -166,6 +168,7 @@ int ttsd_data_new_client(int pid, unsigned int uid) app.state = APP_STATE_READY; app.mode = TTSD_MODE_DEFAULT; app.ipc_method = TTS_IPC_METHOD_UNDEFINED; + app.credential = nullptr; g_app_list.push_back(app); @@ -348,6 +351,41 @@ ttsd_mode_e ttsd_data_get_mode(unsigned int uid) return app_data->mode; } +int ttsd_data_set_credential(unsigned int uid, const char* credential) +{ + lock_guard lock(g_app_data_mutex); + app_data_s* app_data = __get_client_app_data(uid); + if (nullptr == app_data) { + SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); + return TTSD_ERROR_INVALID_PARAMETER; + } + + free(app_data->credential); + app_data->credential = nullptr; + + if (credential) { + app_data->credential = strdup(credential); + } + + return TTSD_ERROR_NONE; +} + +char* ttsd_data_get_credential(unsigned int uid) +{ + lock_guard lock(g_app_data_mutex); + app_data_s* app_data = __get_client_app_data(uid); + if (nullptr == app_data) { + SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%u)", uid); + return nullptr; + } + + if (nullptr == app_data->credential) { + return nullptr; + } + + return strdup(app_data->credential); +} + int ttsd_data_get_speak_data_size(unsigned int uid) { lock_guard lock(g_app_data_mutex); diff --git a/server/ttsd_data.h b/server/ttsd_data.h index b4c7d86f..d7e934dd 100644 --- a/server/ttsd_data.h +++ b/server/ttsd_data.h @@ -81,6 +81,10 @@ int ttsd_data_set_mode(unsigned int uid, ttsd_mode_e mode); ttsd_mode_e ttsd_data_get_mode(unsigned int uid); +int ttsd_data_set_credential(unsigned int uid, const char* credential); + +char* ttsd_data_get_credential(unsigned int uid); + /* speak data */ int ttsd_data_add_speak_data(unsigned int uid, speak_data_s* data); diff --git a/server/ttsd_server.c b/server/ttsd_server.c index d6bd0ca1..382573bc 100644 --- a/server/ttsd_server.c +++ b/server/ttsd_server.c @@ -63,12 +63,11 @@ static bool g_is_terminated = false; /* Function definitions */ -static int __synthesis(unsigned int uid, const char* credential); +static int __synthesis(unsigned int uid); static Eina_Bool __wait_synthesis(void *data) { /* get current play */ - char* credential = (char*)data; unsigned int uid = ttsd_data_get_current_playing(); if (uid > 0) { @@ -80,7 +79,7 @@ static Eina_Bool __wait_synthesis(void *data) g_wait_timer = NULL; if (TTSD_SYNTHESIS_CONTROL_DONE == synth_control) { /* Start next synthesis */ - __synthesis(uid, credential); + __synthesis(uid); } } } else { @@ -90,7 +89,7 @@ static Eina_Bool __wait_synthesis(void *data) return EINA_FALSE; } -static int __synthesis(unsigned int uid, const char* credential) +static int __synthesis(unsigned int uid) { SLOG(LOG_DEBUG, tts_tag(), "@@@ SYNTHESIS START"); @@ -126,6 +125,8 @@ static int __synthesis(unsigned int uid, const char* credential) g_utt.uid = uid; g_utt.uttid = speak_data->utt_id; + char* credential = ttsd_data_get_credential(uid); + SLOG(LOG_INFO, tts_tag(), "-----------------------------------------------------------"); SLOG(LOG_INFO, tts_tag(), "ID : uid (%u), uttid(%d) ", g_utt.uid, g_utt.uttid); SLOG(LOG_INFO, tts_tag(), "Voice : langauge(%s), type(%d), speed(%d)", speak_data->lang, speak_data->vctype, speak_data->speed); @@ -150,9 +151,11 @@ static int __synthesis(unsigned int uid, const char* credential) ttsdc_ipc_send_set_state_message(pid, uid, APP_STATE_READY); } } else { - g_wait_timer = ecore_timer_add(0.05, __wait_synthesis, (void*)credential); + g_wait_timer = ecore_timer_add(0.05, __wait_synthesis, NULL); } + free(credential); + credential = NULL; ttsd_data_clear_speak_data(&speak_data); } else { ttsd_data_clear_speak_data(&speak_data); @@ -967,13 +970,15 @@ int ttsd_server_add_queue(unsigned int uid, const char* text, const char* lang, } } + ttsd_data_set_credential(uid, credential); + /* Check whether tts-engine is running or not */ ttsd_synthesis_control_e synth_control = ttsd_get_synth_control(); SLOG(LOG_INFO, tts_tag(), "[Server INFO] synth_control(%d)", synth_control); if (TTSD_SYNTHESIS_CONTROL_DOING == synth_control) { SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Engine has already been running."); } else { - __synthesis(uid, credential); + __synthesis(uid); } } @@ -1089,6 +1094,8 @@ int ttsd_server_play(unsigned int uid, const char* credential) } } + ttsd_data_set_credential(uid, credential); + /* Check whether tts-engine is running or not */ clock_gettime(CLOCK_MONOTONIC_RAW, &g_request_playing); ttsd_synthesis_control_e synth_control = ttsd_get_synth_control(); @@ -1096,7 +1103,7 @@ int ttsd_server_play(unsigned int uid, const char* credential) if (TTSD_SYNTHESIS_CONTROL_DOING == synth_control) { SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Engine has already been running."); } else { - __synthesis(uid, credential); + __synthesis(uid); } return TTSD_ERROR_NONE;