From 1289e406b96f95e28a37b3a3f51f470fd57e84eb Mon Sep 17 00:00:00 2001 From: Lee Dongyeol Date: Tue, 18 Dec 2012 12:47:32 +0900 Subject: [PATCH] Fix prevent issue, bug, config path --- client/tts.c | 66 ++++++++++++++++++++++++++----------- client/tts_setting.c | 82 ++++++++++++++++++++++++++++++---------------- client/tts_setting_dbus.c | 2 +- debian/changelog | 8 +++++ server/ttsd_config.c | 8 ++--- server/ttsd_engine_agent.c | 10 +++--- server/ttsd_main.h | 3 +- server/ttsd_player.cpp | 76 +++++++++++++++++++++++++++++------------- server/ttsd_server.cpp | 66 ++++++++++++++++++++----------------- 9 files changed, 210 insertions(+), 111 deletions(-) diff --git a/client/tts.c b/client/tts.c index e2a74df..190a338 100644 --- a/client/tts.c +++ b/client/tts.c @@ -14,6 +14,9 @@ #include #include +#include +#include +#include #include "tts_main.h" #include "tts_client.h" @@ -989,36 +992,61 @@ int tts_unset_error_cb(tts_h tts) return 0; } -static bool _tts_is_alive() +int __get_cmd_line(char *file, char *buf) { FILE *fp = NULL; - char buff[256]; - char cmd[256]; - - memset(buff, '\0', sizeof(char) * 256); - memset(cmd, '\0', sizeof(char) * 256); + int i; - if ((fp = popen("ps -eo \"cmd\"", "r")) == NULL) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] popen error"); - return FALSE; + fp = fopen(file, "r"); + if (fp == NULL) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get command line"); + return -1; } - while(fgets(buff, 255, fp)) { - sscanf(buff, "%s", cmd); + memset(buf, 0, sizeof(buf)); + fgets(buf, 256, fp); + fclose(fp); + + return 0; +} - if (0 == strncmp(cmd, "[tts-daemon]", strlen("[tts-daemon]")) || - 0 == strncmp(cmd, "tts-daemon", strlen("tts-daemon")) || - 0 == strncmp(cmd, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon"))) { - SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !!"); - fclose(fp); - return TRUE; +static bool _tts_is_alive() +{ + DIR *dir; + struct dirent *entry; + struct stat filestat; + + int pid; + char cmdLine[256]; + char tempPath[256]; + + dir = opendir("/proc"); + + while ((entry = readdir(dir)) != NULL) { + lstat(entry->d_name, &filestat); + + if (!S_ISDIR(filestat.st_mode)) + continue; + + pid = atoi(entry->d_name); + if (pid <= 0) continue; + + sprintf(tempPath, "/proc/%d/cmdline", pid); + if (0 != __get_cmd_line(tempPath, cmdLine)) { + break; } - } - fclose(fp); + if ( 0 == strncmp(cmdLine, "[tts-daemon]", strlen("[tts-daemon]")) || + 0 == strncmp(cmdLine, "tts-daemon", strlen("tts-daemon")) || + 0 == strncmp(cmdLine, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon"))) { + SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !!"); + return TRUE; + } + } SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !!"); + closedir(dir); return FALSE; } diff --git a/client/tts_setting.c b/client/tts_setting.c index 5afadba..1eaca7a 100644 --- a/client/tts_setting.c +++ b/client/tts_setting.c @@ -14,6 +14,9 @@ #include #include +#include +#include +#include #include "tts_main.h" #include "tts_setting.h" @@ -21,7 +24,7 @@ static bool g_is_daemon_started = false; -static int __check_tts_daemon(); +static int __check_setting_tts_daemon(); static tts_setting_state_e g_state = TTS_SETTING_STATE_NONE; @@ -44,7 +47,7 @@ static Eina_Bool __tts_setting_connect_daemon(void *data) if (0 != tts_setting_dbus_request_hello()) { if (false == g_is_daemon_started) { g_is_daemon_started = true; - __check_tts_daemon(); + __check_setting_tts_daemon(); } return EINA_TRUE; } @@ -95,7 +98,7 @@ int tts_setting_initialize() /* Send hello */ if (0 != tts_setting_dbus_request_hello()) { - __check_tts_daemon(); + __check_setting_tts_daemon(); } /* do request */ @@ -521,45 +524,66 @@ int tts_setting_set_engine_setting(const char* key, const char* value) return ret; } +int __setting_get_cmd_line(char *file, char *buf) +{ + FILE *fp = NULL; + int i; + + fp = fopen(file, "r"); + if (fp == NULL) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get command line"); + return -1; + } + memset(buf, 0, sizeof(buf)); + fgets(buf, 256, fp); + fclose(fp); + + return 0; +} /* Functions for tts-daemon fork */ -static bool __tts_is_alive() +static bool __tts_setting_is_alive() { - FILE *fp = NULL; - char buff[256]; - char cmd[256]; + DIR *dir; + struct dirent *entry; + struct stat filestat; + + int pid; + char cmdLine[256]; + char tempPath[256]; - memset(buff, '\0', sizeof(char) * 256); - memset(cmd, '\0', sizeof(char) * 256); + dir = opendir("/proc"); - fp = popen("ps", "r"); - if (NULL == fp) { - SLOG(LOG_DEBUG, TAG_TTSC, "[TTS SETTING ERROR] popen error"); - return FALSE; - } + while ((entry = readdir(dir)) != NULL) { + lstat(entry->d_name, &filestat); - while (fgets(buff, 255, fp)) { - strcpy(cmd, buff + 26); + if (!S_ISDIR(filestat.st_mode)) + continue; - if( 0 == strncmp(cmd, "[tts-daemon]", strlen("[tts-daemon]")) || - 0 == strncmp(cmd, "tts-daemon", strlen("tts-daemon")) || - 0 == strncmp(cmd, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon")) - ) { - SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !!"); - fclose(fp); - return TRUE; + pid = atoi(entry->d_name); + if (pid <= 0) continue; + + sprintf(tempPath, "/proc/%d/cmdline", pid); + if (0 != __setting_get_cmd_line(tempPath, cmdLine)) { + break; } + if (0 == strncmp(cmdLine, "[tts-daemon]", strlen("[tts-daemon]")) || + 0 == strncmp(cmdLine, "tts-daemon", strlen("tts-daemon")) || + 0 == strncmp(cmdLine, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon"))) { + SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !! \n"); + return TRUE; + } } - fclose(fp); - SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !! \n"); + closedir(dir); return FALSE; + } -static void __my_sig_child(int signo, siginfo_t *info, void *data) +static void __setting_my_sig_child(int signo, siginfo_t *info, void *data) { int status; pid_t child_pid, child_pgid; @@ -575,9 +599,9 @@ static void __my_sig_child(int signo, siginfo_t *info, void *data) return; } -static int __check_tts_daemon() +static int __check_setting_tts_daemon() { - if( TRUE == __tts_is_alive() ) + if( TRUE == __tts_setting_is_alive() ) return 0; /* fork-exec tts-daemom */ @@ -585,7 +609,7 @@ static int __check_tts_daemon() struct sigaction act, dummy; act.sa_handler = NULL; - act.sa_sigaction = __my_sig_child; + act.sa_sigaction = __setting_my_sig_child; sigemptyset(&act.sa_mask); act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO; diff --git a/client/tts_setting_dbus.c b/client/tts_setting_dbus.c index a0eb8b9..77dcf00 100644 --- a/client/tts_setting_dbus.c +++ b/client/tts_setting_dbus.c @@ -729,7 +729,7 @@ int tts_setting_dbus_request_get_default_speed(int* speed) if (0 == result) { *speed = temp_int; - SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting get default speed : result(%d), speed(%d)", result, speed); + SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting get default speed : result(%d), speed(%d)", result, *speed); } else { SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get default speed : result(%d)", result); } diff --git a/debian/changelog b/debian/changelog index 9444ef1..ea9ec1b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +tts (0.1.1-41slp2+1) unstable; urgency=low + + * Fix prevent issue + * Fix bug when engine result is NULL + * Change config path + + -- Dongyeol Lee Tue, 18 Dec 2012 12:16:38 +0900 + tts (0.1.1-40slp2+1) unstable; urgency=low * Fix prevent diff --git a/server/ttsd_config.c b/server/ttsd_config.c index c30cc27..db772e2 100644 --- a/server/ttsd_config.c +++ b/server/ttsd_config.c @@ -15,7 +15,7 @@ #include "ttsd_main.h" #include "ttsd_config.h" -#define CONFIG_FILE_PATH BASE_DIRECTORY_DOWNLOAD"/ttsd.conf" +#define CONFIG_FILE_PATH CONFIG_DIRECTORY"/ttsd.conf" #define CONFIG_DEFAULT BASE_DIRECTORY_DEFAULT"/ttsd.conf" #define ENGINE_ID "ENGINE_ID" @@ -31,12 +31,12 @@ static int g_speed; int __ttsd_config_save() { if (0 != access(CONFIG_FILE_PATH, R_OK|W_OK)) { - if (0 == ecore_file_mkpath(BASE_DIRECTORY_DOWNLOAD)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR ] Fail to create directory (%s)", BASE_DIRECTORY_DOWNLOAD); + if (0 == ecore_file_mkpath(CONFIG_DIRECTORY)) { + SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR ] Fail to create directory (%s)", CONFIG_DIRECTORY); return -1; } - SLOG(LOG_WARN, TAG_TTSD, "[Config] Create directory (%s)", BASE_DIRECTORY_DOWNLOAD); + SLOG(LOG_WARN, TAG_TTSD, "[Config] Create directory (%s)", CONFIG_DIRECTORY); } FILE* config_fp; diff --git a/server/ttsd_engine_agent.c b/server/ttsd_engine_agent.c index 64867d5..0a71b23 100644 --- a/server/ttsd_engine_agent.c +++ b/server/ttsd_engine_agent.c @@ -576,20 +576,20 @@ int ttsd_engine_agent_load_current_engine() char *error = NULL; g_cur_engine.handle = dlopen(g_cur_engine.engine_path, RTLD_LAZY); /* RTLD_LAZY RTLD_NOW*/ - if ((error = dlerror()) != NULL || !g_cur_engine.handle) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get current engine handle : dlopen error \n"); + if (NULL != (error = dlerror()) || NULL == g_cur_engine.handle) { + SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get current engine handle : dlopen error ($s)", error); return -2; } g_cur_engine.ttsp_unload_engine = (int (*)())dlsym(g_cur_engine.handle, "ttsp_unload_engine"); - if ((error = dlerror()) != NULL) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to link daemon to ttsp_unload_engine() of current engine\n"); + if (NULL != (error = dlerror()) || NULL == g_cur_engine.ttsp_unload_engine) { + SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to link daemon to ttsp_unload_engine() of current engine : (%s)", error); return -3; } g_cur_engine.ttsp_load_engine = (int (*)(const ttspd_funcs_s* , ttspe_funcs_s*) )dlsym(g_cur_engine.handle, "ttsp_load_engine"); if (NULL != (error = dlerror()) || NULL == g_cur_engine.ttsp_load_engine) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to link daemon to ttsp_load_engine() of current engine \n"); + SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to link daemon to ttsp_load_engine() of current engine : %s", error); return -3; } diff --git a/server/ttsd_main.h b/server/ttsd_main.h index 0b2e0cd..1960d42 100644 --- a/server/ttsd_main.h +++ b/server/ttsd_main.h @@ -38,7 +38,8 @@ extern "C" { #define ENGINE_DIRECTORY_DEFAULT "/usr/lib/voice/tts/1.0/engine" #define ENGINE_DIRECTORY_DEFAULT_SETTING "/usr/lib/voice/tts/1.0/setting" -#define BASE_DIRECTORY_DOWNLOAD "/opt/usr/voice/tts/1.0" +#define CONFIG_DIRECTORY "/opt/home/app/.voice" + #define ENGINE_DIRECTORY_DOWNLOAD "/opt/usr/voice/tts/1.0/engine" #define ENGINE_DIRECTORY_DOWNLOAD_SETTING "/opt/usr/voice/tts/1.0/setting" diff --git a/server/ttsd_player.cpp b/server/ttsd_player.cpp index 9410f6f..8e27191 100644 --- a/server/ttsd_player.cpp +++ b/server/ttsd_player.cpp @@ -66,6 +66,7 @@ typedef struct { #define TEMP_FILE_PATH "/tmp" #define FILE_PATH_SIZE 256 +#define DEFAULT_FILE_SIZE 10 /** player init info */ static bool g_player_init = false; @@ -650,10 +651,15 @@ static Eina_Bool __player_next_play(void *data) static int msg_callback(int message, void *data, void *user_param) { - user_data_s* user_data; + user_data_s* user_data = NULL; user_data = (user_data_s*)user_param; + if (NULL == user_data) { + SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER ERROR] user_param is NULL"); + return -1; + } + int uid = user_data->uid; int utt_id = user_data->utt_id; @@ -758,10 +764,9 @@ static int msg_callback(int message, void *data, void *user_param) { SLOG(LOG_DEBUG, TAG_TTSD, "===== END OF STREAM CALLBACK"); - if (NULL == user_data) - break; - - remove(user_data->filename); + if (-1 == remove(user_data->filename)) { + SLOG(LOG_WARN, TAG_TTSD, "[PLAYER WARNING] Fail to remove temp file", user_data->filename); + } /* Check uid */ player_s* current; @@ -877,15 +882,23 @@ int __save_file(const int uid, const int index, const sound_data_s data, char** /* make filename to save */ char* temp; - temp = *filename; + temp = (char*)g_malloc0(sizeof(char) * FILE_PATH_SIZE); - snprintf(temp, FILE_PATH_SIZE, "%s/ttstemp%d_%d.%s", TEMP_FILE_PATH, uid, index, postfix ); + int ret = snprintf(temp, FILE_PATH_SIZE, "%s/ttstemp%d_%d.%s", TEMP_FILE_PATH, uid, index, postfix); + + if (0 >= ret) { + if (NULL != temp) + g_free(temp); + return -1; + } FILE* fp; fp = fopen(temp, "wb"); if (fp == NULL) { SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] temp file open error"); + if (NULL != temp) + g_free(temp); return -1; } @@ -893,27 +906,37 @@ int __save_file(const int uid, const int index, const sound_data_s data, char** WavHeader header; if (0 != __init_wave_header(&header, data.data_size, data.rate, data.channels)) { fclose(fp); + if (NULL != temp) + g_free(temp); return -1; } if (0 >= fwrite(&header, sizeof(WavHeader), 1, fp)) { SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail to write wav header to file"); fclose(fp); + if (NULL != temp) + g_free(temp); return -1; } } int size = fwrite(data.data, data.data_size, 1, fp); if (size <= 0) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Fail to write date"); - fclose(fp); - return -1; + size = fwrite("0000000000", DEFAULT_FILE_SIZE, 1, fp); + if (size <= 0) { + SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Fail to write date"); + fclose(fp); + if (NULL != temp) + g_free(temp); + return -1; + } } fclose(fp); + *filename = temp; SLOG(LOG_DEBUG, TAG_TTSD, " "); - SLOG(LOG_DEBUG, TAG_TTSD, "Filepath : %s ", temp); + SLOG(LOG_DEBUG, TAG_TTSD, "Filepath : %s ", *filename); SLOG(LOG_DEBUG, TAG_TTSD, "Header : Data size(%d), Sample rate(%d), Channel(%d) ", data.data_size, data.rate, data.channels); return 0; @@ -921,25 +944,34 @@ int __save_file(const int uid, const int index, const sound_data_s data, char** int __init_wave_header (WavHeader* hdr, size_t nsamples, size_t sampling_rate, int channel) { - if (hdr == NULL || nsamples <= 0 || sampling_rate <= 0 || channel <= 0) { + if (hdr == NULL || sampling_rate <= 0 || channel <= 0) { SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] __init_wave_header : input parameter invalid"); + SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] hdr : %p", hdr); + SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] nsample : %d", nsamples); + SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] sampling_rate : %", sampling_rate); + SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] channel : %", channel); return TTSD_ERROR_INVALID_PARAMETER; } - size_t bytesize = nsamples; + size_t bytesize = DEFAULT_FILE_SIZE; - strncpy(hdr->riff, "RIFF", 4); + if (0 < nsamples) { + bytesize = nsamples; + } + + /* NOT include \0(NULL) */ + strncpy(hdr->riff, "RIFF", 4); hdr->file_size = (int)(bytesize + 36); strncpy(hdr->wave, "WAVE", 4); - strncpy(hdr->fmt, "fmt ", 4); + strncpy(hdr->fmt, "fmt ", 4); /* fmt + space */ hdr->header_size = 16; - hdr->sample_format = 1; /* WAVE_FORMAT_PCM */ + hdr->sample_format = 1; /* WAVE_FORMAT_PCM */ hdr->n_channels = channel; hdr->sample_rate = (int)(sampling_rate); hdr->bytes_per_second = (int)sampling_rate * sizeof(short); hdr->block_align = sizeof(short); hdr->bits_per_sample = sizeof(short)*8; - strncpy(hdr->data, "data", 4); + strncpy(hdr->data, "data", 4); hdr->data_size = (int)bytesize; return 0; @@ -961,8 +993,6 @@ int __set_and_start(player_s* player) /* make sound file for mmplayer */ char* sound_file = NULL; - sound_file = (char*) g_malloc0( sizeof(char) * FILE_PATH_SIZE ); - if (0 != __save_file(player->uid, g_index, wdata, &sound_file)) { SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail to make sound file"); return -1; @@ -997,7 +1027,7 @@ int __set_and_start(player_s* player) } ret = mm_player_set_attribute(player->player_handle, &err_attr_name, - "profile_uri", sound_file , strlen( sound_file ) + 1, + "profile_uri", sound_file , strlen(sound_file) + 1, "sound_volume_type", MM_SOUND_VOLUME_TYPE_MEDIA, "sound_route", MM_AUDIOROUTE_PLAYBACK_NORMAL, NULL ); @@ -1024,8 +1054,10 @@ int __set_and_start(player_s* player) return -3; } - if( NULL != sound_file ) g_free(sound_file); - if( NULL != wdata.data ) g_free(wdata.data); + if (NULL != sound_file) + g_free(sound_file); + if (NULL != wdata.data) + g_free(wdata.data); return 0; } diff --git a/server/ttsd_server.cpp b/server/ttsd_server.cpp index 706bcf8..99c6bed 100644 --- a/server/ttsd_server.cpp +++ b/server/ttsd_server.cpp @@ -36,8 +36,7 @@ static bool g_is_engine; static bool g_is_synthesizing; /* If the daemon get the result */ -Ecore_Timer* g_timer; -static bool g_is_next_synthesis; +static bool g_is_next_synthesis = false; /* Function definitions */ int __server_next_synthesis(int uid); @@ -46,14 +45,27 @@ int __server_next_synthesis(int uid); int __server_set_is_synthesizing(bool flag) { g_is_synthesizing = flag; + return 0; } -bool __server_get_current_synthesis() +bool __server_get_is_synthesizing() { return g_is_synthesizing; } +int __server_set_is_next_synthesis(bool flag) +{ + g_is_next_synthesis = flag; + + return 0; +} + +bool __server_get_is_next_synthesis() +{ + return g_is_next_synthesis; +} + int __server_send_error(int uid, int utt_id, int error_code) { int pid = ttsd_data_get_pid(uid); @@ -71,7 +83,7 @@ int __server_start_synthesis(int uid, int mode) int result = 0; /* check if tts-engine is running */ - if (true == __server_get_current_synthesis()) { + if (true == __server_get_is_synthesizing()) { SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running "); } else { speak_data_s sdata; @@ -160,7 +172,7 @@ int __server_play_internal(int uid, app_state_e state) int __server_next_synthesis(int uid) { - SLOG(LOG_DEBUG, TAG_TTSD, "===== START NEXT SYNTHESIS & PLAY"); + SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT SYNTHESIS & PLAY START"); /* get current playing client */ int current_uid = ttsd_data_get_current_playing(); @@ -172,7 +184,7 @@ int __server_next_synthesis(int uid) return 0; } - if (true == __server_get_current_synthesis()) { + if (true == __server_get_is_synthesizing()) { SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Engine has already been running. "); SLOG(LOG_DEBUG, TAG_TTSD, "====="); SLOG(LOG_DEBUG, TAG_TTSD, " "); @@ -222,16 +234,20 @@ int __server_next_synthesis(int uid) if(sdata.text != NULL) g_free(sdata.text); + } else { + SLOG(LOG_DEBUG, TAG_TTSD, "[Server] --------------------"); + SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Text queue is empty."); + SLOG(LOG_DEBUG, TAG_TTSD, "[Server] --------------------"); } if (0 != ttsd_player_play(current_uid)) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] __synthesis_result_callback : fail ttsd_player_play() "); + SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] __server_next_synthesis : fail ttsd_player_play() "); } else { /* success playing */ SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Success to start player"); } - SLOG(LOG_DEBUG, TAG_TTSD, "====="); + SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT SYNTHESIS & PLAY END"); SLOG(LOG_DEBUG, TAG_TTSD, " "); return 0; @@ -246,7 +262,7 @@ int __player_result_callback(player_event_e event, int uid, int utt_id) switch(event) { case PLAYER_EMPTY_SOUND_QUEUE: /* check whether synthesis is running */ - if (false == __server_get_current_synthesis()) { + if (false == __server_get_is_synthesizing()) { /* check text queue is empty */ if (0 == ttsd_data_get_speak_data_size(uid) && 0 == ttsd_data_get_sound_data_size(uid)) { SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER Callback] all play completed "); @@ -272,16 +288,13 @@ Eina_Bool __start_next_synthesis(void *data) /* get current play */ int uid = ttsd_data_is_current_playing(); - if (uid < 0) + if (uid < 0) { return EINA_FALSE; + } - if (true == g_is_next_synthesis) { - SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT SYNTHESIS START"); + if (true == __server_get_is_next_synthesis()) { + __server_set_is_next_synthesis(false); __server_next_synthesis(uid); - SLOG(LOG_DEBUG, TAG_TTSD, "===== "); - SLOG(LOG_DEBUG, TAG_TTSD, " "); - - g_is_next_synthesis = false; } return EINA_TRUE; @@ -312,14 +325,13 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns if (TTSP_RESULT_EVENT_FINISH == event) SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_FINISH"); if (false == ttsd_data_is_uttid_valid(uid, uttid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] uttid is NOT valid !!!! " ); + SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] uttid is NOT valid !!!! - uid(%d), uttid(%d)", uid, uttid); SLOG(LOG_DEBUG, TAG_TTSD, "====="); SLOG(LOG_DEBUG, TAG_TTSD, " "); return 0; } - SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) ", uid, uttid, data, data_size); @@ -353,24 +365,20 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns if (event == TTSP_RESULT_EVENT_FINISH) { __server_set_is_synthesizing(false); - - g_is_next_synthesis = true; + __server_set_is_next_synthesis(true); } } else if (event == TTSP_RESULT_EVENT_CANCEL) { SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_CANCEL"); __server_set_is_synthesizing(false); - - g_is_next_synthesis = true; + __server_set_is_next_synthesis(true); } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : etc"); - + SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event ERROR"); __server_set_is_synthesizing(false); - - g_is_next_synthesis = true; + __server_set_is_next_synthesis(true); } if (TTSP_RESULT_EVENT_FINISH == event || TTSP_RESULT_EVENT_CANCEL == event || TTSP_RESULT_EVENT_FAIL == event) { @@ -413,7 +421,6 @@ int ttsd_initialize() } else g_is_engine = true; - g_timer = NULL; return TTSD_ERROR_NONE; } @@ -633,8 +640,7 @@ int ttsd_server_play(int uid) return TTSD_ERROR_OPERATION_FAILED; } - if (NULL == g_timer) - ecore_timer_add(0, __start_next_synthesis, NULL); + ecore_timer_add(0, __start_next_synthesis, NULL); return TTSD_ERROR_NONE; } @@ -657,7 +663,7 @@ int ttsd_server_stop(int uid) if (0 != ttsd_player_stop(uid)) SLOG(LOG_WARN, TAG_TTSD, "[Server] Fail to ttsd_player_stop()"); - if (true == __server_get_current_synthesis()) { + if (true == __server_get_is_synthesizing()) { SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running "); int ret = 0; -- 2.7.4