unsigned int uid = ttsd_data_get_current_playing();
if (uid > 0) {
- ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
+ ttsd_synthesis_control_e synth_control = ttsd_data_get_synth_control();
if (TTSD_SYNTHESIS_CONTROL_DOING == synth_control) {
return EINA_TRUE;
} else {
SLOG(LOG_INFO, tts_tag(), "Credential : %s", credential);
SLOG(LOG_INFO, tts_tag(), "-----------------------------------------------------------");
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DOING);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DOING);
ret = ttsd_engine_start_synthesis(speak_data->lang, speak_data->vctype, speak_data->text, speak_data->speed, appid, credential, NULL);
if (TTSD_ERROR_NONE != ret) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to start SYNTHESIS !!!! * ");
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
__stop_and_send_ready_state(uid);
} else {
g_wait_timer = ecore_timer_add(0.05, __wait_synthesis, (void*)credential);
SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Error msg from engine, pid(%d), uid(%u), uttid(%d), error(%d), msg(%s)", tmp_pid, uid, uttid, error, (NULL == msg ? "NULL" : msg));
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
if (0 != ttsd_data_clear_data(uid))
SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_data_clear_data()");
int uttid = g_utt.uttid;
if (false == ttsd_data_is_uttid_valid(uid, uttid)) {
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] uttid is NOT valid !!!! - uid(%u), uttid(%d)", uid, uttid);
SLOG(LOG_DEBUG, tts_tag(), "@@@");
return TTSD_ERROR_INVALID_PARAMETER;
if (TTSE_RESULT_EVENT_START > event || TTSE_RESULT_EVENT_FINISH < event) {
SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_ERROR");
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
return TTSD_ERROR_INVALID_PARAMETER;
}
if (rate <= 0 || audio_type < 0 || audio_type > TTSE_AUDIO_TYPE_MAX) {
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] audio data is invalid");
SLOG(LOG_DEBUG, tts_tag(), "@@@");
return TTSD_ERROR_INVALID_PARAMETER;
/* check the current state */
app_tts_state_e state = ttsd_data_get_client_state(uid);
if (APP_STATE_NONE == state) {
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid is not valid");
return TTSD_ERROR_INVALID_PARAMETER;
}
SLOG(LOG_INFO, tts_tag(), "[Server] uid(%u), current state(%d)", uid, state);
if (APP_STATE_CREATED == state || APP_STATE_READY == state) {
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
SLOG(LOG_WARN, tts_tag(), "[SERVER WARNING] Current state is %d. The synthesized result is ignored.", state);
return TTSD_ERROR_NONE;
}
}
if (event == TTSE_RESULT_EVENT_FINISH) {
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
}
return TTSD_ERROR_NONE;
SLOG(LOG_INFO, tts_tag(), "[Server] Send to stop all requests");
ttsd_engine_cancel_synthesis();
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
/* stop all player */
ttsd_player_all_stop();
return;
}
+static void __read_proc()
+{
+ DIR *dp = NULL;
+ struct dirent *dirp = NULL;
+ int tmp;
+
+ GList *iter = NULL;
+ if (0 < g_list_length(g_proc_list)) {
+ iter = g_list_first(g_proc_list);
+ while (NULL != iter) {
+ g_proc_list = g_list_remove_link(g_proc_list, iter);
+ g_list_free(iter);
+ iter = g_list_first(g_proc_list);
+ }
+ }
+
+ dp = opendir("/proc");
+ if (NULL == dp) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to open proc");
+ } else {
+ do {
+ dirp = readdir(dp);
+
+ if (NULL != dirp) {
+ tmp = atoi(dirp->d_name);
+ if (0 >= tmp) continue;
+ g_proc_list = g_list_append(g_proc_list, GINT_TO_POINTER(tmp));
+ }
+ } while (NULL != dirp);
+ closedir(dp);
+ }
+ return;
+}
+
+bool __get_client_for_clean_up(int pid, unsigned int uid, app_tts_state_e state, void* user_data)
+{
+ bool exist = false;
+ int i = 0;
+
+ GList *iter = NULL;
+ for (i = 0; i < g_list_length(g_proc_list); i++) {
+ iter = g_list_nth(g_proc_list, i);
+ if (NULL != iter) {
+ if (pid == GPOINTER_TO_INT(iter->data)) {
+ SLOG(LOG_DEBUG, tts_tag(), "uid (%u) is running", uid);
+ exist = true;
+ break;
+ }
+ }
+ }
+
+ if (false == exist) {
+ SLOG(LOG_ERROR, tts_tag(), "uid (%u) should be removed", uid);
+ ttsd_server_finalize(uid);
+ }
+
+ return true;
+}
+
+static Eina_Bool __cleanup_client(void *data)
+{
+ SLOG(LOG_DEBUG, tts_tag(), "@@@ CLEAN UP CLIENT START");
+ __read_proc();
+
+ if (0 < ttsd_data_get_client_count()) {
+ ttsd_data_foreach_clients(__get_client_for_clean_up, NULL);
+ } else {
+ if (NULL == g_quit_loop_timer) {
+ SLOG(LOG_INFO, tts_tag(), "[Server] Add a timer __quit_ecore_loop");
+ g_quit_loop_timer = ecore_timer_add(0, __quit_ecore_loop, NULL);
+ }
+ SLOG(LOG_ERROR, tts_tag(), "[Server] Deleted timer");
+ g_check_client_timer = NULL;
+ return EINA_FALSE;
+ }
+
+ SLOG(LOG_DEBUG, tts_tag(), "@@@");
+
+ return EINA_TRUE;
+}
+
/*
* Server APIs
*/
return TTSD_ERROR_OPERATION_FAILED;
}
- /* set current engine */
- //if (0 != ttsd_engine_agent_initialize_current_engine(callback)) {
- // SLOG(LOG_WARN, tts_tag(), "[Server WARNING] No Engine !!!" );
- // g_is_engine = false;
- //} else
- // g_is_engine = true;
-
if (0 != ttsd_engine_agent_load_current_engine(callback)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to load current engine");
return TTSD_ERROR_OPERATION_FAILED;
}
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
ttsd_config_set_screen_reader_callback(__screen_reader_changed_cb);
- g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
+ g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, __cleanup_client, NULL);
if (NULL == g_check_client_timer) {
SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to create timer");
}
return TTSD_ERROR_NONE;
}
-static void __read_proc()
-{
- DIR *dp = NULL;
- struct dirent *dirp = NULL;
- int tmp;
-
- GList *iter = NULL;
- if (0 < g_list_length(g_proc_list)) {
- iter = g_list_first(g_proc_list);
- while (NULL != iter) {
- g_proc_list = g_list_remove_link(g_proc_list, iter);
- g_list_free(iter);
- iter = g_list_first(g_proc_list);
- }
- }
-
- dp = opendir("/proc");
- if (NULL == dp) {
- SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to open proc");
- } else {
- do {
- dirp = readdir(dp);
-
- if (NULL != dirp) {
- tmp = atoi(dirp->d_name);
- if (0 >= tmp) continue;
- g_proc_list = g_list_append(g_proc_list, GINT_TO_POINTER(tmp));
- }
- } while (NULL != dirp);
- closedir(dp);
- }
- return;
-}
-
-bool __get_client_for_clean_up(int pid, unsigned int uid, app_tts_state_e state, void* user_data)
-{
- bool exist = false;
- int i = 0;
-
- GList *iter = NULL;
- for (i = 0; i < g_list_length(g_proc_list); i++) {
- iter = g_list_nth(g_proc_list, i);
- if (NULL != iter) {
- if (pid == GPOINTER_TO_INT(iter->data)) {
- SLOG(LOG_DEBUG, tts_tag(), "uid (%u) is running", uid);
- exist = true;
- break;
- }
- }
- }
-
- if (false == exist) {
- SLOG(LOG_ERROR, tts_tag(), "uid (%u) should be removed", uid);
- ttsd_server_finalize(uid);
- }
-
- return true;
-#if 0
- char appid[1024] = {0, };
- if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid) - 1)) {
- SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id");
- }
-
- if (0 < strlen(appid)) {
- SLOG(LOG_DEBUG, tts_tag(), "[%d] is running app - %s", pid, appid);
- } else {
- SLOG(LOG_DEBUG, tts_tag(), "[%d] is daemon or no_running app", pid);
-
- int result = 1;
- result = ttsdc_send_hello(pid, uid);
-
- if (0 == result) {
- SLOG(LOG_DEBUG, tts_tag(), "[Server] uid(%u) should be removed.", uid);
- ttsd_server_finalize(uid);
- } else if (-1 == result) {
- SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Hello result has error");
- }
- }
- return true;
-#endif
-}
-
-
-Eina_Bool ttsd_cleanup_client(void *data)
-{
- SLOG(LOG_DEBUG, tts_tag(), "@@@ CLEAN UP CLIENT START");
- __read_proc();
-
- if (0 < ttsd_data_get_client_count()) {
- ttsd_data_foreach_clients(__get_client_for_clean_up, NULL);
- } else {
- if (NULL == g_quit_loop_timer) {
- SLOG(LOG_INFO, tts_tag(), "[Server] Add a timer __quit_ecore_loop");
- g_quit_loop_timer = ecore_timer_add(0, __quit_ecore_loop, NULL);
- }
- SLOG(LOG_ERROR, tts_tag(), "[Server] Deleted timer");
- g_check_client_timer = NULL;
- return EINA_FALSE;
- }
-
- SLOG(LOG_DEBUG, tts_tag(), "@@@");
-
- return EINA_TRUE;
-}
-
void __used_voice_cb(const char* lang, int type)
{
SLOG(LOG_DEBUG, tts_tag(), "[Server] Request to unload voice (%s,%d)", lang, type);
ttsd_data_set_credential(uid, credential);
/* Check whether tts-engine is running or not */
- ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
+ ttsd_synthesis_control_e synth_control = ttsd_data_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.");
/* 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();
+ ttsd_synthesis_control_e synth_control = ttsd_data_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.");
static void __stop_engine_synthesis(unsigned int uid)
{
- ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
+ ttsd_synthesis_control_e synth_control = ttsd_data_get_synth_control();
SLOG(LOG_INFO, tts_tag(), "[Server INFO] synth_control(%d)", synth_control);
if (TTSD_SYNTHESIS_CONTROL_DOING == synth_control && uid == ttsd_data_get_current_playing()) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to cancel synthesis : ret(%d)", ret);
}
- ttsd_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+ ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
}
int ttsd_server_stop(unsigned int uid)