From: Kwangyoun Kim Date: Thu, 7 Feb 2013 09:42:37 +0000 (+0900) Subject: Add TTS mode X-Git-Tag: 2.1b_release~9^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c044bf393b2c99b2e53f2919594370613fa584b;p=platform%2Fcore%2Fuifw%2Ftts.git Add TTS mode Change-Id: I83e74e14ed0d27f1bb13319f35b9fda5011a0f91 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b163e21..9009ece 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common") ## Dependent packages ## INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED - mm-player vconf dlog ecore ecore-file dbus-1 + mm-player vconf dlog ecore ecore-file dbus-1 mm-session capi-system-runtime-info ) ## Client library ## diff --git a/changelog b/changelog index 92e9721..b93ed96 100755 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +tts (0.1.1-49) + + * Add TTS mode(notification and screen reader) + * Update smack rule + + --Kwangyoun Kim Thu, 07 Feb 2013 + tts (0.1.1-48) * Update smack rule diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/client/tts-setting.pc.in b/client/tts-setting.pc.in old mode 100644 new mode 100755 diff --git a/client/tts.c b/client/tts.c index bed0b84..6d1bbdd 100755 --- a/client/tts.c +++ b/client/tts.c @@ -26,10 +26,14 @@ static bool g_is_daemon_started = false; +static bool g_is_noti_daemon_started = false; + +static bool g_is_sr_daemon_started = false; + static Ecore_Timer* g_connect_timer = NULL; /* Function definition */ -static int __tts_check_tts_daemon(); +static int __tts_check_tts_daemon(tts_mode_e mode); static Eina_Bool __tts_notify_state_changed(void *data); static Eina_Bool __tts_notify_error(void *data); @@ -61,6 +65,10 @@ int tts_create(tts_h* tts) return TTS_ERROR_OUT_OF_MEMORY; } + g_is_daemon_started = false; + g_is_noti_daemon_started = false; + g_is_sr_daemon_started = false; + SLOG(LOG_DEBUG, TAG_TTSC, "====="); SLOG(LOG_DEBUG, TAG_TTSC, " "); @@ -103,10 +111,16 @@ int tts_destroy(tts_h tts) case TTS_STATE_READY: /* Request Finalize */ ret = tts_dbus_request_finalize(client->uid); - if (0 != ret) { + if (0 != ret) SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request finalize"); - } - g_is_daemon_started = false; + + if (TTS_MODE_SCREEN_READER == client->mode) + g_is_sr_daemon_started = false; + else if (TTS_MODE_NOTIFICATION == client->mode) + g_is_noti_daemon_started = false; + else + g_is_daemon_started = false; + case TTS_STATE_CREATED: if (NULL != g_connect_timer) { SLOG(LOG_DEBUG, TAG_TTSC, "Connect Timer is deleted"); @@ -121,7 +135,7 @@ int tts_destroy(tts_h tts) if (0 != tts_dbus_close_connection()) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection"); } - } + } SLOG(LOG_DEBUG, TAG_TTSC, "====="); SLOG(LOG_DEBUG, TAG_TTSC, " "); @@ -216,16 +230,29 @@ static Eina_Bool __tts_connect_daemon(void *data) } /* Send hello */ - if (0 != tts_dbus_request_hello()) { - if (false == g_is_daemon_started) { - g_is_daemon_started = true; - __tts_check_tts_daemon(); + if (0 != tts_dbus_request_hello(client->uid)) { + if (TTS_MODE_SCREEN_READER == client->mode) { + if (false == g_is_sr_daemon_started) { + g_is_sr_daemon_started = true; + __tts_check_tts_daemon(client->mode); + } + } else if (TTS_MODE_NOTIFICATION == client->mode) { + if (false == g_is_noti_daemon_started) { + g_is_noti_daemon_started = true; + __tts_check_tts_daemon(client->mode); + } + } else { + if (false == g_is_daemon_started) { + g_is_daemon_started = true; + __tts_check_tts_daemon(client->mode); + } } + return EINA_TRUE; } SLOG(LOG_DEBUG, TAG_TTSC, "===== Connect daemon"); - + /* do request initialize */ int ret = -1; @@ -321,7 +348,14 @@ int tts_unprepare(tts_h tts) if (0 != ret) { SLOG(LOG_WARN, TAG_TTSC, "[ERROR] Fail to request finalize"); } - g_is_daemon_started = false; + + if (TTS_MODE_SCREEN_READER == client->mode) + g_is_sr_daemon_started = false; + else if (TTS_MODE_NOTIFICATION == client->mode) + g_is_noti_daemon_started = false; + else + g_is_daemon_started = false; + client->before_state = client->current_state; client->current_state = TTS_STATE_CREATED; @@ -491,6 +525,13 @@ int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_ty return TTS_ERROR_INVALID_STATE; } + if (MAX_TEXT_COUNT < strlen(text)) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is too big."); + SLOG(LOG_DEBUG, TAG_TTSC, "====="); + SLOG(LOG_DEBUG, TAG_TTSC, " "); + return TTS_ERROR_INVALID_PARAMETER; + } + /* change default language value */ char* temp = NULL; @@ -509,10 +550,10 @@ int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_ty ret = tts_dbus_request_add_text(client->uid, text, temp, voice_type, speed, client->current_utt_id); if (0 != ret) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret); + } else { + *utt_id = client->current_utt_id; } - *utt_id = client->current_utt_id; - if (NULL != temp) free(temp); @@ -1079,7 +1120,7 @@ int tts_unset_error_cb(tts_h tts) return 0; } -int __get_cmd_line(char *file, char *buf) +static int __get_cmd_line(char *file, char *buf) { FILE *fp = NULL; @@ -1096,18 +1137,19 @@ int __get_cmd_line(char *file, char *buf) return -1; } fclose(fp); + return 0; } -static bool _tts_is_alive() +static bool __tts_is_alive(char* daemon_path) { DIR *dir; struct dirent *entry; struct stat filestat; int pid; - char cmdLine[256]; - char tempPath[256]; + char cmdLine[256] = {'\0',}; + char tempPath[256] = {'\0',}; dir = opendir("/proc"); if (NULL == dir) { @@ -1116,11 +1158,13 @@ static bool _tts_is_alive() } while ((entry = readdir(dir)) != NULL) { - if (0 != lstat(entry->d_name, &filestat)) + if (0 != lstat(entry->d_name, &filestat)) { continue; + } - if (!S_ISDIR(filestat.st_mode)) + if (!S_ISDIR(filestat.st_mode)) { continue; + } pid = atoi(entry->d_name); if (pid <= 0) continue; @@ -1130,35 +1174,45 @@ static bool _tts_is_alive() continue; } - 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 !!"); - closedir(dir); - return TRUE; + if (0 == strncmp(cmdLine, daemon_path, strlen(daemon_path))) { + SLOG(LOG_DEBUG, TAG_TTSC, "%s is ALIVE !!", daemon_path); + closedir(dir); + return TRUE; } } - SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !!"); + SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO %s !!", daemon_path); closedir(dir); return FALSE; } -static int __tts_check_tts_daemon() +static int __tts_check_tts_daemon(tts_mode_e mode) { - if (TRUE == _tts_is_alive()) { + char daemon_path[64] = {'\0',}; + int pid, i; + + if (TTS_MODE_DEFAULT == mode) { + strcpy(daemon_path, "/usr/bin/tts-daemon"); + } else if (TTS_MODE_NOTIFICATION == mode) { + strcpy(daemon_path, "/usr/bin/tts-daemon-noti"); + } else if (TTS_MODE_SCREEN_READER == mode) { + strcpy(daemon_path, "/usr/bin/tts-daemon-sr"); + } else { + SLOG(LOG_ERROR, TAG_TTSC, "mode is not valid"); + return -1; + } + + if (TRUE == __tts_is_alive(daemon_path)) { return 0; } - /* fork-exec tts-daemom */ - int pid, i; - + /* fork-exec daemom */ pid = fork(); switch(pid) { case -1: - SLOG(LOG_ERROR, TAG_TTSC, "Fail to create tts-daemon"); + SLOG(LOG_ERROR, TAG_TTSC, "Fail to create daemon"); break; case 0: @@ -1166,7 +1220,7 @@ static int __tts_check_tts_daemon() for (i = 0;i < _NSIG;i++) signal(i, SIG_DFL); - execl("/usr/bin/tts-daemon", "/usr/bin/tts-daemon", NULL); + execl(daemon_path, daemon_path, NULL); break; default: diff --git a/client/tts.pc.in b/client/tts.pc.in old mode 100644 new mode 100755 diff --git a/client/tts_dbus.c b/client/tts_dbus.c index 73a7fc4..7f5eca1 100755 --- a/client/tts_dbus.c +++ b/client/tts_dbus.c @@ -311,16 +311,54 @@ int tts_dbus_reconnect() return 0; } +DBusMessage* __tts_dbus_make_message(int uid, const char* method) +{ + if (NULL == method) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input method is NULL"); + return NULL; + } + + tts_client_s* client = tts_client_get_by_uid(uid); + + /* check handle */ + if (NULL == client) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] uid is not available"); + return NULL; + } + + DBusMessage* msg; + + if (TTS_MODE_DEFAULT == client->mode) { + msg = dbus_message_new_method_call( + TTS_SERVER_SERVICE_NAME, + TTS_SERVER_SERVICE_OBJECT_PATH, + TTS_SERVER_SERVICE_INTERFACE, + method); + } else if (TTS_MODE_NOTIFICATION == client->mode) { + msg = dbus_message_new_method_call( + TTS_NOTI_SERVER_SERVICE_NAME, + TTS_NOTI_SERVER_SERVICE_OBJECT_PATH, + TTS_NOTI_SERVER_SERVICE_INTERFACE, + method); + } else if (TTS_MODE_SCREEN_READER == client->mode) { + msg = dbus_message_new_method_call( + TTS_SR_SERVER_SERVICE_NAME, + TTS_SR_SERVER_SERVICE_OBJECT_PATH, + TTS_SR_SERVER_SERVICE_INTERFACE, + method); + } else { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input mode is not available"); + return NULL; + } + + return msg; +} -int tts_dbus_request_hello() +int tts_dbus_request_hello(int uid) { DBusMessage* msg; - msg = dbus_message_new_method_call( - TTS_SERVER_SERVICE_NAME, - TTS_SERVER_SERVICE_OBJECT_PATH, - TTS_SERVER_SERVICE_INTERFACE, - TTS_METHOD_HELLO); + msg = __tts_dbus_make_message(uid, TTS_METHOD_HELLO); if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts hello : Fail to make message \n"); @@ -355,11 +393,7 @@ int tts_dbus_request_initialize(int uid) DBusError err; dbus_error_init(&err); - msg = dbus_message_new_method_call( - TTS_SERVER_SERVICE_NAME, - TTS_SERVER_SERVICE_OBJECT_PATH, - TTS_SERVER_SERVICE_INTERFACE, - TTS_METHOD_INITIALIZE); + msg = __tts_dbus_make_message(uid, TTS_METHOD_INITIALIZE); if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to make message \n"); @@ -423,11 +457,7 @@ int tts_dbus_request_finalize(int uid) DBusError err; dbus_error_init(&err); - msg = dbus_message_new_method_call( - TTS_SERVER_SERVICE_NAME, - TTS_SERVER_SERVICE_OBJECT_PATH, - TTS_SERVER_SERVICE_INTERFACE, - TTS_METHOD_FINALIZE); + msg = __tts_dbus_make_message(uid, TTS_METHOD_FINALIZE); if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts finalize : Fail to make message"); @@ -487,11 +517,7 @@ int tts_dbus_request_get_support_voice(int uid, tts_h tts, tts_supported_voice_c DBusError err; dbus_error_init(&err); - msg = dbus_message_new_method_call( - TTS_SERVER_SERVICE_NAME, - TTS_SERVER_SERVICE_OBJECT_PATH, - TTS_SERVER_SERVICE_INTERFACE, - TTS_METHOD_GET_SUPPORT_VOICES); + msg = __tts_dbus_make_message(uid, TTS_METHOD_GET_SUPPORT_VOICES); if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get supported voices : Fail to make message"); @@ -587,11 +613,7 @@ int tts_dbus_request_get_default_voice(int uid , char** lang, tts_voice_type_e* DBusError err; dbus_error_init(&err); - msg = dbus_message_new_method_call( - TTS_SERVER_SERVICE_NAME, - TTS_SERVER_SERVICE_OBJECT_PATH, - TTS_SERVER_SERVICE_INTERFACE, - TTS_METHOD_GET_CURRENT_VOICE); + msg = __tts_dbus_make_message(uid, TTS_METHOD_GET_CURRENT_VOICE); if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get default voice : Fail to make message"); @@ -672,11 +694,7 @@ int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int v DBusError err; dbus_error_init(&err); - msg = dbus_message_new_method_call( - TTS_SERVER_SERVICE_NAME, - TTS_SERVER_SERVICE_OBJECT_PATH, - TTS_SERVER_SERVICE_INTERFACE, - TTS_METHOD_ADD_QUEUE); + msg = __tts_dbus_make_message(uid, TTS_METHOD_ADD_QUEUE); if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts add text : Fail to make message"); @@ -745,11 +763,7 @@ int tts_dbus_request_play(int uid) DBusError err; dbus_error_init(&err); - msg = dbus_message_new_method_call( - TTS_SERVER_SERVICE_NAME, - TTS_SERVER_SERVICE_OBJECT_PATH, - TTS_SERVER_SERVICE_INTERFACE, - TTS_METHOD_PLAY ); + msg = __tts_dbus_make_message(uid, TTS_METHOD_PLAY); if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts play : Fail to make message"); @@ -811,11 +825,7 @@ int tts_dbus_request_stop(int uid) DBusError err; dbus_error_init(&err); - msg = dbus_message_new_method_call( - TTS_SERVER_SERVICE_NAME, - TTS_SERVER_SERVICE_OBJECT_PATH, - TTS_SERVER_SERVICE_INTERFACE, - TTS_METHOD_STOP); + msg = __tts_dbus_make_message(uid, TTS_METHOD_STOP); if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts stop : Fail to make message"); @@ -876,11 +886,7 @@ int tts_dbus_request_pause(int uid) DBusError err; dbus_error_init(&err); - msg = dbus_message_new_method_call( - TTS_SERVER_SERVICE_NAME, - TTS_SERVER_SERVICE_OBJECT_PATH, - TTS_SERVER_SERVICE_INTERFACE, - TTS_METHOD_PAUSE); + msg = __tts_dbus_make_message(uid, TTS_METHOD_PAUSE); if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts pause : Fail to make message"); diff --git a/client/tts_dbus.h b/client/tts_dbus.h index c94973e..9993bc2 100755 --- a/client/tts_dbus.h +++ b/client/tts_dbus.h @@ -25,8 +25,7 @@ int tts_dbus_open_connection(); int tts_dbus_close_connection(); - -int tts_dbus_request_hello(); +int tts_dbus_request_hello(int uid); int tts_dbus_request_initialize(int uid); diff --git a/client/tts_setting.c b/client/tts_setting.c index cc41c7c..1164e84 100755 --- a/client/tts_setting.c +++ b/client/tts_setting.c @@ -87,14 +87,14 @@ int tts_setting_initialize() SLOG(LOG_DEBUG, TAG_TTSC, "===== Initialize TTS Setting"); if (TTS_SETTING_STATE_READY == g_state) { - SLOG(LOG_WARN, TAG_TTSC, "[WARNING] TTS Setting has already been initialized. \n"); + SLOG(LOG_WARN, TAG_TTSC, "[WARNING] TTS Setting has already been initialized."); SLOG(LOG_DEBUG, TAG_TTSC, "====="); SLOG(LOG_DEBUG, TAG_TTSC, " "); return TTS_SETTING_ERROR_NONE; } if( 0 != tts_setting_dbus_open_connection() ) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open connection\n "); + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open connection"); SLOG(LOG_DEBUG, TAG_TTSC, "====="); SLOG(LOG_DEBUG, TAG_TTSC, " "); return TTS_SETTING_ERROR_OPERATION_FAILED; @@ -144,14 +144,14 @@ int tts_setting_initialize_async(tts_setting_initialized_cb callback, void* user SLOG(LOG_DEBUG, TAG_TTSC, "===== Initialize TTS Setting"); if (TTS_SETTING_STATE_READY == g_state) { - SLOG(LOG_WARN, TAG_TTSC, "[WARNING] TTS Setting has already been initialized. \n"); + SLOG(LOG_WARN, TAG_TTSC, "[WARNING] TTS Setting has already been initialized."); SLOG(LOG_DEBUG, TAG_TTSC, "====="); SLOG(LOG_DEBUG, TAG_TTSC, " "); return TTS_SETTING_ERROR_NONE; } if( 0 != tts_setting_dbus_open_connection() ) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open connection\n "); + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open connection"); SLOG(LOG_DEBUG, TAG_TTSC, "====="); SLOG(LOG_DEBUG, TAG_TTSC, " "); return TTS_SETTING_ERROR_OPERATION_FAILED; @@ -190,7 +190,7 @@ int tts_setting_finalize() g_is_daemon_started = false; if (0 != tts_setting_dbus_close_connection()) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection\n "); + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection"); } else { SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Finalize"); } @@ -584,12 +584,12 @@ static bool __tts_setting_is_alive() 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"); + SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !!"); closedir(dir); return TRUE; } } - SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !! \n"); + SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !!"); closedir(dir); return FALSE; diff --git a/common/tts_defs.h b/common/tts_defs.h old mode 100644 new mode 100755 index 6787947..32eb0a2 --- a/common/tts_defs.h +++ b/common/tts_defs.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,6 +35,13 @@ extern "C" { #define TTS_SERVER_SERVICE_OBJECT_PATH "/com/samsung/voice/ttsserver" #define TTS_SERVER_SERVICE_INTERFACE "com.samsung.voice.ttsserver" +#define TTS_NOTI_SERVER_SERVICE_NAME "service.connect.ttsnotiserver" +#define TTS_NOTI_SERVER_SERVICE_OBJECT_PATH "/com/samsung/voice/ttsnotiserver" +#define TTS_NOTI_SERVER_SERVICE_INTERFACE "com.samsung.voice.ttsnotiserver" + +#define TTS_SR_SERVER_SERVICE_NAME "service.connect.ttssrserver" +#define TTS_SR_SERVER_SERVICE_OBJECT_PATH "/com/samsung/voice/ttssrserver" +#define TTS_SR_SERVER_SERVICE_INTERFACE "com.samsung.voice.ttssrserver" /****************************************************************************************** * Message Definition for APIs diff --git a/packaging/tts.spec b/packaging/tts.spec index 126a0a0..e917be9 100755 --- a/packaging/tts.spec +++ b/packaging/tts.spec @@ -11,10 +11,12 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(mm-player) BuildRequires: pkgconfig(mm-common) +BuildRequires: pkgconfig(mm-session) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(ecore-file) +BuildRequires: pkgconfig(capi-system-runtime-info) BuildRequires: cmake @@ -54,7 +56,7 @@ mkdir -p %{buildroot}/usr/share/license %defattr(-,root,root,-) %{_libdir}/lib*.so %{_libdir}/voice/tts/1.0/ttsd.conf -%{_bindir}/tts-daemon +%{_bindir}/tts-daemon* /usr/share/license/* %files devel diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 83f9c28..e84018a 100755 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -15,27 +15,44 @@ SET(VERSION 0.0.1) SET(SRCS ttsd_data.cpp - ttsd_player.cpp + ttsd_player.c ttsd_engine_agent.c ttsd_config.c - ttsd_server.cpp + ttsd_server.c ttsd_network.c ttsd_dbus.c ttsd_dbus_server.c ttsd_main.c ) +SET(NOTI_SRCS + ttsd_data.cpp + ttsd_player.c + ttsd_engine_agent.c + ttsd_config.c + ttsd_server.c + ttsd_network.c + ttsd_dbus.c + ttsd_dbus_server.c + ttsd_main_noti.c +) + +SET(SR_SRCS + ttsd_data.cpp + ttsd_player.c + ttsd_engine_agent.c + ttsd_config.c + ttsd_server.c + ttsd_network.c + ttsd_dbus.c + ttsd_dbus_server.c + ttsd_main_sr.c +) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) INCLUDE_DIRECTORIES(${INCLUDEDIR}) INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/../common") - -## Dependent packages ## -#INCLUDE(FindPkgConfig) -#pkg_check_modules(pkgs REQUIRED -# mm-player vconf mm-common dbus-1 dlog -#) - FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) @@ -61,8 +78,18 @@ ADD_DEFINITIONS("-DIMAGEDIR=\"${IMAGEDIR}\"") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} -ldl ${pkgs_LDFLAGS}) +ADD_EXECUTABLE("${PROJECT_NAME}-noti" ${NOTI_SRCS}) +TARGET_LINK_LIBRARIES("${PROJECT_NAME}-noti" -ldl ${pkgs_LDFLAGS}) + +ADD_EXECUTABLE("${PROJECT_NAME}-sr" ${SR_SRCS}) +TARGET_LINK_LIBRARIES("${PROJECT_NAME}-sr" -ldl ${pkgs_LDFLAGS}) + + ## Install ## INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) +INSTALL(TARGETS "${PROJECT_NAME}-noti" DESTINATION bin) +INSTALL(TARGETS "${PROJECT_NAME}-sr" DESTINATION bin) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ttsp.h DESTINATION include) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ttsd.conf DESTINATION lib/voice/tts/1.0) diff --git a/server/ttsd.conf b/server/ttsd.conf old mode 100644 new mode 100755 diff --git a/server/ttsd_config.c b/server/ttsd_config.c index 61066c3..c51f4d9 100755 --- a/server/ttsd_config.c +++ b/server/ttsd_config.c @@ -12,43 +12,81 @@ */ #include +#include #include "ttsd_main.h" #include "ttsd_config.h" +#include "ttsd_engine_agent.h" +#include "ttsd_data.h" -#define CONFIG_FILE_PATH CONFIG_DIRECTORY"/ttsd.conf" -#define CONFIG_DEFAULT BASE_DIRECTORY_DEFAULT"/ttsd.conf" +#define CONFIG_DEFAULT BASE_DIRECTORY_DEFAULT"/ttsd.conf" + +#define DEFAULT_CONFIG_FILE_NAME "/ttsd_default.conf" +#define NOTI_CONFIG_FILE_NAME "/ttsd_noti.conf" +#define SR_CONFIG_FILE_NAME "/ttsd_sr.conf" + +#define DEFAULT_ERROR_FILE_NAME "/ttsd_default.err" +#define NOTI_ERROR_FILE_NAME "/ttsd_noti.err" +#define SR_ERROR_FILE_NAME "/ttsd_sr.err" #define ENGINE_ID "ENGINE_ID" #define VOICE "VOICE" #define SPEED "SPEED" - static char* g_engine_id; static char* g_language; static int g_vc_type; static int g_speed; +static char* g_config_file; + +static ttsd_config_lang_changed_cb g_callback; + +void __system_language_changed_cb(runtime_info_key_e key, void *user_data) +{ + if (RUNTIME_INFO_KEY_LANGUAGE == key) { + if (TTSD_MODE_NOTIFICATION == ttsd_get_mode() || TTSD_MODE_SCREEN_READER == ttsd_get_mode()) { + int ret = -1; + char *value; + + ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &value); + if (0 != ret) { + SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get system language : %d", ret); + return; + } else { + SLOG(LOG_DEBUG, get_tag(), "[Config] System language changed : %s", value); + if (NULL != g_callback) + g_callback(value, g_vc_type); + + if (NULL != value) + free(value); + } + } + } + + return; +} + int __ttsd_config_save() { - if (0 != access(CONFIG_FILE_PATH, R_OK|W_OK)) { + if (0 != access(g_config_file, R_OK|W_OK)) { if (0 == ecore_file_mkpath(CONFIG_DIRECTORY)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR ] Fail to create directory (%s)", CONFIG_DIRECTORY); + SLOG(LOG_ERROR, get_tag(), "[Config ERROR ] Fail to create directory (%s)", CONFIG_DIRECTORY); return -1; } - SLOG(LOG_WARN, TAG_TTSD, "[Config] Create directory (%s)", CONFIG_DIRECTORY); + SLOG(LOG_WARN, get_tag(), "[Config] Create directory (%s)", CONFIG_DIRECTORY); } FILE* config_fp; - config_fp = fopen(CONFIG_FILE_PATH, "w+"); + config_fp = fopen(g_config_file, "w+"); if (NULL == config_fp) { /* make file and file default */ - SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to open config (%s)", CONFIG_FILE_PATH); + SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to open config (%s)", g_config_file); return -1; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Config] Rewrite config file"); + SLOG(LOG_DEBUG, get_tag(), "[Config] Rewrite config file"); /* Write engine id */ fprintf(config_fp, "%s %s\n", ENGINE_ID, g_engine_id); @@ -64,7 +102,6 @@ int __ttsd_config_save() return 0; } - int __ttsd_config_load() { FILE* config_fp; @@ -73,14 +110,14 @@ int __ttsd_config_load() int int_param = 0; bool is_default_open = false; - config_fp = fopen(CONFIG_FILE_PATH, "r"); + config_fp = fopen(g_config_file, "r"); if (NULL == config_fp) { - SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Not open file(%s)", CONFIG_FILE_PATH); + SLOG(LOG_WARN, get_tag(), "[Config WARNING] Not open file(%s)", g_config_file); config_fp = fopen(CONFIG_DEFAULT, "r"); if (NULL == config_fp) { - SLOG(LOG_ERROR, TAG_TTSD, "[Config WARNING] Not open original config file(%s)", CONFIG_FILE_PATH); + SLOG(LOG_ERROR, get_tag(), "[Config WARNING] Not open original config file(%s)", CONFIG_DEFAULT); return -1; } is_default_open = true; @@ -89,7 +126,7 @@ int __ttsd_config_load() /* Read engine id */ if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) { fclose(config_fp); - SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to read config (engine id)"); + SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (engine id)"); __ttsd_config_save(); return -1; } else { @@ -97,18 +134,16 @@ int __ttsd_config_load() g_engine_id = strdup(buf_param); } else { fclose(config_fp); - SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to load config (engine id)"); + SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (engine id)"); __ttsd_config_save(); return -1; } } - - /* Read voice */ if (EOF == fscanf(config_fp, "%s %s %d", buf_id, buf_param, &int_param)) { fclose(config_fp); - SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to read config (voice)"); + SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (voice)"); __ttsd_config_save(); return -1; } else { @@ -117,7 +152,7 @@ int __ttsd_config_load() g_vc_type = int_param; } else { fclose(config_fp); - SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to load config (voice)"); + SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (voice)"); __ttsd_config_save(); return -1; } @@ -126,7 +161,7 @@ int __ttsd_config_load() /* Read speed */ if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) { fclose(config_fp); - SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to read config (speed)"); + SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (speed)"); __ttsd_config_save(); return -1; } else { @@ -134,7 +169,7 @@ int __ttsd_config_load() g_speed = int_param; } else { fclose(config_fp); - SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to load config (speed)"); + SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (speed)"); __ttsd_config_save(); return -1; } @@ -142,33 +177,87 @@ int __ttsd_config_load() fclose(config_fp); - SLOG(LOG_DEBUG, TAG_TTSD, "[Config] Load config : engine(%s), voice(%s,%d), speed(%d)", + SLOG(LOG_DEBUG, get_tag(), "[Config] Load config : engine(%s), voice(%s,%d), speed(%d)", g_engine_id, g_language, g_vc_type, g_speed); if (true == is_default_open) { if(0 == __ttsd_config_save()) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Config] Create config(%s)", CONFIG_FILE_PATH); + SLOG(LOG_DEBUG, get_tag(), "[Config] Create config(%s)", g_config_file); } } return 0; } -int ttsd_config_initialize() +int ttsd_config_initialize(ttsd_config_lang_changed_cb callback) { g_engine_id = NULL; g_language = NULL; g_vc_type = 1; g_speed = 3; + g_callback = callback; + + if (TTSD_MODE_NOTIFICATION == ttsd_get_mode()) { + g_config_file = (char*)malloc(strlen(CONFIG_DIRECTORY) + strlen(NOTI_CONFIG_FILE_NAME) + 1); + strcpy(g_config_file, CONFIG_DIRECTORY); + strcat(g_config_file, NOTI_CONFIG_FILE_NAME); + } else if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) { + g_config_file = (char*)malloc(strlen(CONFIG_DIRECTORY) + strlen(SR_CONFIG_FILE_NAME) + 1); + strcpy(g_config_file, CONFIG_DIRECTORY); + strcat(g_config_file, SR_CONFIG_FILE_NAME); + } else { + g_config_file = (char*)malloc(strlen(CONFIG_DIRECTORY) + strlen(DEFAULT_CONFIG_FILE_NAME) + 1); + strcpy(g_config_file, CONFIG_DIRECTORY); + strcat(g_config_file, DEFAULT_CONFIG_FILE_NAME); + } + __ttsd_config_load(); + /* Register system language changed callback */ + int ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_LANGUAGE, __system_language_changed_cb, NULL); + if (0 != ret) { + SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to register callback : %d", ret); + return TTSD_ERROR_OPERATION_FAILED; + } + return 0; } int ttsd_config_finalize() { __ttsd_config_save(); + + if (NULL != g_config_file) { + free(g_config_file); + } + + return 0; +} + +int ttsd_config_update_language() +{ + if (TTSD_MODE_NOTIFICATION == ttsd_get_mode() || TTSD_MODE_SCREEN_READER == ttsd_get_mode()) { + int ret = -1; + char *value; + + ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &value); + if (0 != ret) { + SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get system language : %d", ret); + return -1; + } else { + SLOG(LOG_DEBUG, get_tag(), "[Config] System language : %s", value); + + if (0 != strcmp(value, g_language)) { + if (NULL != g_callback) + g_callback(value, g_vc_type); + } + + if (NULL != value) + free(value); + } + } + return 0; } @@ -237,3 +326,81 @@ int ttsd_config_set_default_speed(int speed) __ttsd_config_save(); return 0; } + +int ttsd_config_save_error(int uid, int uttid, const char* lang, int vctype, const char* text, + const char* func, int line, const char* message) +{ + char* err_file; + + if (TTSD_MODE_NOTIFICATION == ttsd_get_mode()) { + err_file = (char*)malloc(strlen(CONFIG_DIRECTORY) + strlen(NOTI_ERROR_FILE_NAME) + 1); + strcpy(err_file, CONFIG_DIRECTORY); + strcat(err_file, NOTI_ERROR_FILE_NAME); + } else if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) { + err_file = (char*)malloc(strlen(CONFIG_DIRECTORY) + strlen(SR_ERROR_FILE_NAME) + 1); + strcpy(err_file, CONFIG_DIRECTORY); + strcat(err_file, SR_ERROR_FILE_NAME); + } else { + err_file = (char*)malloc(strlen(CONFIG_DIRECTORY) + strlen(DEFAULT_ERROR_FILE_NAME) + 1); + strcpy(err_file, CONFIG_DIRECTORY); + strcat(err_file, DEFAULT_ERROR_FILE_NAME); + } + + FILE* err_fp; + err_fp = fopen(err_file, "w+"); + if (NULL == err_fp) { + SLOG(LOG_WARN, get_tag(), "[WARNING] Fail to open error file (%s)", err_file); + return -1; + } + SLOG(LOG_DEBUG, get_tag(), "Save Error File (%s)", err_file); + + /* func */ + if (NULL != func) { + fprintf(err_fp, "function - %s\n", func); + } + + /* line */ + fprintf(err_fp, "line - %d\n", line); + + /* message */ + if (NULL != message) { + fprintf(err_fp, "message - %s\n", message); + } + + int ret; + /* uid */ + fprintf(err_fp, "uid - %d\n", uid); + + /* uttid */ + fprintf(err_fp, "uttid - %d\n", uttid); + + /* lang */ + if (NULL != lang) { + fprintf(err_fp, "language - %s\n", lang); + } + + /* vctype */ + fprintf(err_fp, "vctype - %d\n", vctype); + + /* text */ + if (NULL != text) { + fprintf(err_fp, "text - %s\n", text); + } + + /* get current engine */ + char *engine_id = NULL; + + ret = ttsd_engine_setting_get_engine(&engine_id); + if (0 != ret) { + SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to get current engine"); + } else { + fprintf(err_fp, "current engine - %s", engine_id); + } + + /* get data */ + ttsd_data_save_error_log(uid, err_fp); + + fclose(err_fp); + + return 0; +} \ No newline at end of file diff --git a/server/ttsd_config.h b/server/ttsd_config.h index e8b32d8..e4b256a 100755 --- a/server/ttsd_config.h +++ b/server/ttsd_config.h @@ -19,10 +19,14 @@ extern "C" { #endif -int ttsd_config_initialize(); +typedef void (*ttsd_config_lang_changed_cb)(const char* langauge, int type); + +int ttsd_config_initialize(ttsd_config_lang_changed_cb callback); int ttsd_config_finalize(); +int ttsd_config_update_language(); + int ttsd_config_get_default_engine(char** engine_id); int ttsd_config_set_default_engine(const char* engine_id); @@ -35,6 +39,9 @@ int ttsd_config_get_default_speed(int* speed); int ttsd_config_set_default_speed(int speed); +int ttsd_config_save_error(int uid, int uttid, const char* lang, int vctype, const char* text, + const char* func, int line, const char* message); + #ifdef __cplusplus } #endif diff --git a/server/ttsd_data.cpp b/server/ttsd_data.cpp index 73ab2c1..88191dd 100755 --- a/server/ttsd_data.cpp +++ b/server/ttsd_data.cpp @@ -11,12 +11,27 @@ * limitations under the License. */ - +#include #include "ttsd_main.h" #include "ttsd_data.h" using namespace std; +typedef struct +{ + int pid; + int uid; + int utt_id_stopped; + app_state_e state; + + std::vector m_speak_data; + std::vector m_wav_data; +}app_data_s; + +typedef struct { + int pid; +} setting_app_data_s; + static vector g_app_list; static vector g_setting_list; @@ -31,69 +46,69 @@ int __data_show_list() { int vsize = g_app_list.size(); - SLOG(LOG_DEBUG, TAG_TTSD, "----- client list -----"); + SLOG(LOG_DEBUG, get_tag(), "----- client list -----"); for (int i=0; i pid) { + SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to get pid"); + } else { + fprintf(fp, "pid - %d\n", pid); + } + /* app state */ + app_state_e state; + ret = ttsd_data_get_client_state(uid, &state); + if (0 != ret) { + SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to get app state"); + } else { + fprintf(fp, "app state - %d\n", state); + } + + int index = 0; + unsigned int i; + + index = ttsd_data_is_client(uid); + + /* get sound data */ + fprintf(fp, "----- Sound list -----\n"); + + for (i=0 ; i < g_app_list[index].m_wav_data.size() ; i++) { + fprintf(fp, "[%dth] data size(%ld), uttid(%d), type(%d) \n", + i+1, g_app_list[index].m_wav_data[i].data_size, g_app_list[index].m_wav_data[i].utt_id, g_app_list[index].m_wav_data[i].audio_type ); + } + fprintf(fp, "----------------------\n"); + + /* get speck data */ + fprintf(fp, "----- Text list -----\n"); + + for (i=0 ; i< g_app_list[index].m_speak_data.size() ; i++) { + fprintf(fp, "[%dth] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s) \n", + i+1, g_app_list[index].m_speak_data[i].lang, g_app_list[index].m_speak_data[i].vctype, g_app_list[index].m_speak_data[i].speed, + g_app_list[index].m_speak_data[i].utt_id, g_app_list[index].m_speak_data[i].text ); + } + fprintf(fp, "---------------------"); + + return 0; } \ No newline at end of file diff --git a/server/ttsd_data.h b/server/ttsd_data.h index 40f8647..83539ff 100755 --- a/server/ttsd_data.h +++ b/server/ttsd_data.h @@ -15,10 +15,10 @@ #ifndef __TTSD_DATA_H_ #define __TTSD_DATA_H_ -#include +//#include #include "ttsp.h" -using namespace std; +//using namespace std; #ifdef __cplusplus extern "C" { @@ -52,21 +52,6 @@ typedef struct int channels; }sound_data_s; -typedef struct -{ - int pid; - int uid; - int utt_id_stopped; - app_state_e state; - - std::vector m_speak_data; - std::vector m_wav_data; -}app_data_s; - -typedef struct { - int pid; -} setting_app_data_s; - int ttsd_data_new_client(int pid, int uid); int ttsd_data_delete_client(int uid); @@ -112,6 +97,9 @@ int ttsd_setting_data_delete(int pid); int ttsd_setting_data_is_setting(int pid); +/* for error log */ +int ttsd_data_save_error_log(int uid, FILE* fp); + #ifdef __cplusplus } #endif diff --git a/server/ttsd_dbus.c b/server/ttsd_dbus.c index 2b71b93..3e98f97 100755 --- a/server/ttsd_dbus.c +++ b/server/ttsd_dbus.c @@ -25,6 +25,9 @@ static DBusConnection* g_conn; static int g_waiting_time = 3000; +static char *g_service_name; +static char *g_service_interface; + int ttsdc_send_hello(int pid, int uid) { char service_name[64]; @@ -44,10 +47,10 @@ int ttsdc_send_hello(int pid, int uid) TTSD_METHOD_HELLO); if (NULL == msg) { - SLOG(LOG_ERROR, TAG_TTSD, "<<<< [Dbus ERROR] Fail to create hello message : uid(%d)", uid); + SLOG(LOG_ERROR, get_tag(), "<<<< [Dbus ERROR] Fail to create hello message : uid(%d)", uid); return -1; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "<<<< [Dbus] Send hello message : uid(%d)", uid); + SLOG(LOG_DEBUG, get_tag(), "<<<< [Dbus] Send hello message : uid(%d)", uid); } dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); @@ -65,14 +68,14 @@ int ttsdc_send_hello(int pid, int uid) dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, ">>>> [Dbus] Get arguments error (%s)", err.message); + SLOG(LOG_ERROR, get_tag(), ">>>> [Dbus] Get arguments error (%s)", err.message); dbus_error_free(&err); result = -1; } dbus_message_unref(result_msg); } else { - SLOG(LOG_DEBUG, TAG_TTSD, ">>>> [Dbus] Result message is NULL. Client is not available"); + SLOG(LOG_DEBUG, get_tag(), ">>>> [Dbus] Result message is NULL. Client is not available"); result = 0; } @@ -98,7 +101,7 @@ int ttsdc_send_message(int pid, int uid, int data, char *method) method); if (NULL == msg) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] Fail to create message : type(%s), uid(%d)\n", method, uid); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to create message : type(%s), uid(%d)\n", method, uid); return -1; } @@ -106,9 +109,9 @@ int ttsdc_send_message(int pid, int uid, int data, char *method) /* send the message and flush the connection */ if (!dbus_connection_send(g_conn, msg, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] <<<< send message : Out Of Memory, type(%s), ifname(%s), uid(%d), data(%d)", method, target_if_name, uid, data); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] <<<< send message : Out Of Memory, type(%s), ifname(%s), uid(%d), data(%d)", method, target_if_name, uid, data); } else { - SLOG(LOG_DEBUG, TAG_TTSD, "<<<< send message : type(%s), uid(%d), data(%d)", method, uid, data); + SLOG(LOG_DEBUG, get_tag(), "<<<< send message : type(%s), uid(%d), data(%d)", method, uid, data); dbus_connection_flush(g_conn); } @@ -151,7 +154,7 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason) TTSD_METHOD_ERROR); if (NULL == msg) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] Fail to create error message : uid(%d)\n", uid); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to create error message : uid(%d)\n", uid); return -1; } @@ -162,9 +165,9 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason) DBUS_TYPE_INVALID); if (!dbus_connection_send(g_conn, msg, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] <<<< error message : Out Of Memory !\n"); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] <<<< error message : Out Of Memory !\n"); } else { - SLOG(LOG_DEBUG, TAG_TTSD, "<<<< Send error signal : uid(%d), reason(%d), uttid(%d)", uid, reason, uttid); + SLOG(LOG_DEBUG, get_tag(), "<<<< Send error signal : uid(%d), reason(%d), uttid(%d)", uid, reason, uttid); dbus_connection_flush(g_conn); } @@ -189,73 +192,73 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle if (NULL == msg || NULL == conn) { return ECORE_CALLBACK_RENEW; } - + /* client event */ - if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_HELLO)) + if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_HELLO)) ttsd_dbus_server_hello(conn, msg); - else if( dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_INITIALIZE) ) + else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_INITIALIZE) ) ttsd_dbus_server_initialize(conn, msg); - else if( dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_FINALIZE) ) + else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_FINALIZE) ) ttsd_dbus_server_finalize(conn, msg); - else if( dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_GET_SUPPORT_VOICES) ) + else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_SUPPORT_VOICES) ) ttsd_dbus_server_get_support_voices(conn, msg); - else if( dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_GET_CURRENT_VOICE) ) + else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_CURRENT_VOICE) ) ttsd_dbus_server_get_current_voice(conn, msg); - else if( dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_ADD_QUEUE) ) + else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_ADD_QUEUE) ) ttsd_dbus_server_add_text(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_PLAY)) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PLAY)) ttsd_dbus_server_play(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_STOP)) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_STOP)) ttsd_dbus_server_stop(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_PAUSE)) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PAUSE)) ttsd_dbus_server_pause(conn, msg); /* setting event */ - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_HELLO)) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_HELLO)) ttsd_dbus_server_hello(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_INITIALIZE) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_INITIALIZE) ) ttsd_dbus_server_setting_initialize(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_FINALIZE) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_FINALIZE) ) ttsd_dbus_server_setting_finalize(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_GET_ENGINE_LIST) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_ENGINE_LIST) ) ttsd_dbus_server_setting_get_engine_list(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_GET_ENGINE) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_ENGINE) ) ttsd_dbus_server_setting_get_engine(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_SET_ENGINE) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_SET_ENGINE) ) ttsd_dbus_server_setting_set_engine(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_GET_VOICE_LIST) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_VOICE_LIST) ) ttsd_dbus_server_setting_get_voice_list(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_GET_DEFAULT_VOICE) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_DEFAULT_VOICE) ) ttsd_dbus_server_setting_get_default_voice(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_SET_DEFAULT_VOICE) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_SET_DEFAULT_VOICE) ) ttsd_dbus_server_setting_set_default_voice(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_GET_DEFAULT_SPEED) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_DEFAULT_SPEED) ) ttsd_dbus_server_setting_get_speed(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_SET_DEFAULT_SPEED) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_SET_DEFAULT_SPEED) ) ttsd_dbus_server_setting_set_speed(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_GET_ENGINE_SETTING) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_ENGINE_SETTING) ) ttsd_dbus_server_setting_get_engine_setting(conn, msg); - else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_SET_ENGINE_SETTING) ) + else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_SET_ENGINE_SETTING) ) ttsd_dbus_server_setting_set_engine_setting(conn, msg); @@ -265,7 +268,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle return ECORE_CALLBACK_RENEW; } -int ttsd_dbus_open_connection() +int ttsd_dbus_open_connection(ttsd_mode_e mode) { DBusError err; dbus_error_init(&err); @@ -276,26 +279,46 @@ int ttsd_dbus_open_connection() g_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] fail dbus_bus_get : %s\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] fail dbus_bus_get : %s\n", err.message); dbus_error_free(&err); } if (NULL == g_conn) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] fail to get dbus connection \n" ); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] fail to get dbus connection \n" ); return -1; } + if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) { + g_service_name = (char*)malloc(sizeof(char) * strlen(TTS_SR_SERVER_SERVICE_NAME) + 1); + g_service_interface = (char*)malloc(sizeof(char) * strlen(TTS_SR_SERVER_SERVICE_INTERFACE) + 1); + + strcpy(g_service_name, TTS_SR_SERVER_SERVICE_NAME); + strcpy(g_service_interface, TTS_SR_SERVER_SERVICE_INTERFACE); + } else if (TTSD_MODE_NOTIFICATION == ttsd_get_mode()) { + g_service_name = (char*)malloc(sizeof(char) * strlen(TTS_NOTI_SERVER_SERVICE_NAME) + 1); + g_service_interface = (char*)malloc(sizeof(char) * strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1); + + strcpy(g_service_name, TTS_NOTI_SERVER_SERVICE_NAME); + strcpy(g_service_interface, TTS_NOTI_SERVER_SERVICE_INTERFACE); + } else { + g_service_name = (char*)malloc(sizeof(char) * strlen(TTS_SERVER_SERVICE_NAME) + 1); + g_service_interface = (char*)malloc(sizeof(char) * strlen(TTS_SERVER_SERVICE_INTERFACE) + 1); + + strcpy(g_service_name, TTS_SERVER_SERVICE_NAME); + strcpy(g_service_interface, TTS_SERVER_SERVICE_INTERFACE); + } + /* request our name on the bus and check for errors */ - ret = dbus_bus_request_name(g_conn, TTS_SERVER_SERVICE_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING , &err); + ret = dbus_bus_request_name(g_conn, g_service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err); if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { printf("Fail to be primary owner in dbus request. \n"); - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] fail to be primary owner \n"); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] fail to be primary owner \n"); return -1; } if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] dbus_bus_request_name() : %s \n", err.message); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_request_name() : %s \n", err.message); dbus_error_free(&err); return -1; @@ -303,14 +326,14 @@ int ttsd_dbus_open_connection() /* add a rule for getting signal */ char rule[128]; - snprintf(rule, 128, "type='signal',interface='%s'", TTS_SERVER_SERVICE_INTERFACE); + snprintf(rule, 128, "type='signal',interface='%s'", g_service_interface); /* add a rule for which messages we want to see */ dbus_bus_add_match(g_conn, rule, &err); /* see signals from the given interface */ dbus_connection_flush(g_conn); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] dbus_bus_add_match() : %s \n", err.message); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_add_match() : %s \n", err.message); return -1; } @@ -321,11 +344,11 @@ int ttsd_dbus_open_connection() fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ , (Ecore_Fd_Cb)listener_event_callback, g_conn, NULL, NULL); if (NULL == fd_handler) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] ecore_main_fd_handler_add() : fail to get fd handler \n"); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] ecore_main_fd_handler_add() : fail to get fd handler \n"); return -1; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Dbus SUCCESS] Open connection. "); + SLOG(LOG_DEBUG, get_tag(), "[Dbus SUCCESS] Open connection. "); return 0; } @@ -334,15 +357,21 @@ int ttsd_dbus_close_connection() DBusError err; dbus_error_init(&err); - dbus_bus_release_name (g_conn, TTS_SERVER_SERVICE_NAME, &err); + dbus_bus_release_name (g_conn, g_service_name, &err); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] dbus_bus_release_name() : %s\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_release_name() : %s\n", err.message); dbus_error_free(&err); return -1; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Dbus SUCCESS] Close connection. "); + if (NULL != g_service_name) + free(g_service_name); + + if (NULL != g_service_interface) + free(g_service_interface); + + SLOG(LOG_DEBUG, get_tag(), "[Dbus SUCCESS] Close connection. "); return 0; } diff --git a/server/ttsd_dbus_server.c b/server/ttsd_dbus_server.c index a9d0d36..611ab29 100755 --- a/server/ttsd_dbus_server.c +++ b/server/ttsd_dbus_server.c @@ -25,24 +25,24 @@ extern int ttsd_data_get_pid(const int uid); int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg) { - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS Hello"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS Hello"); DBusMessage* reply; reply = dbus_message_new_method_return(msg); if (NULL != reply) { if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] Out Of Memory!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Out Of Memory!"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -60,15 +60,15 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS INITIALIZE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS INITIALIZE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts initialize : get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts initialize : get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts initialize : pid(%d), uid(%d) \n", pid , uid); + SLOG(LOG_DEBUG, get_tag(), "[IN] tts initialize : pid(%d), uid(%d) \n", pid , uid); ret = ttsd_server_initialize(pid, uid); } @@ -79,23 +79,23 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts initialize : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] tts initialize : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts initialize : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts initialize : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts initialize : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -110,15 +110,15 @@ int ttsd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg) dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS FINALIZE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS FINALIZE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts finalize : get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts finalize : get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts finalize : uid(%d) \n", uid); + SLOG(LOG_DEBUG, get_tag(), "[IN] tts finalize : uid(%d) \n", uid); ret = ttsd_server_finalize(uid); } @@ -129,23 +129,23 @@ int ttsd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts finalize : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] tts finalize : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts finalize : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts finalize : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts finalize : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -161,14 +161,14 @@ int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg) dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS GET VOICES"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS GET VOICES"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts get supported voices : get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts get supported voices : get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] get supported voices : uid(%d) \n", uid ); + SLOG(LOG_DEBUG, get_tag(), "[IN] get supported voices : uid(%d) \n", uid ); ret = ttsd_server_get_support_voices(uid, &voice_list); } @@ -187,7 +187,7 @@ int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg) int size = g_list_length(voice_list); if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts supported voices : Fail to append type \n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : Fail to append type \n"); ret = TTSD_ERROR_OPERATION_FAILED; } else { @@ -214,23 +214,23 @@ int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg) iter = g_list_first(voice_list); } } - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts supported voices : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] tts supported voices : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts supported voices : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] error : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] error : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts supported voices : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -247,14 +247,14 @@ int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg) dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS GET DEFAULT VOICE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS GET DEFAULT VOICE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts get default voice : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts get default voice : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts get default voice : uid(%d) \n", uid); + SLOG(LOG_DEBUG, get_tag(), "[IN] tts get default voice : uid(%d) \n", uid); ret = ttsd_server_get_current_voice(uid, &lang, &voice_type); } @@ -269,26 +269,26 @@ int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_STRING, &lang, DBUS_TYPE_INT32, &voice_type, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts default voice : lang(%s), vctype(%d)\n", lang, voice_type ); + SLOG(LOG_DEBUG, get_tag(), "[OUT] tts default voice : lang(%s), vctype(%d)\n", lang, voice_type ); } else { dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts default voice : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts default voice : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts default voice : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -311,15 +311,15 @@ int ttsd_dbus_server_add_text(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INT32, &uttid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS ADD TEXT"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS ADD TEXT"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts add text : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts add text : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), uttid(%d) \n", + SLOG(LOG_DEBUG, get_tag(), "[IN] tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), uttid(%d) \n", uid, text, lang, voicetype, speed, uttid); ret = ttsd_server_add_queue(uid, text, lang, voicetype, speed, uttid); } @@ -331,23 +331,23 @@ int ttsd_dbus_server_add_text(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts add text : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] tts add text : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts add text : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts add text : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts add text : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -362,14 +362,14 @@ int ttsd_dbus_server_play(DBusConnection* conn, DBusMessage* msg) dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS PLAY"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS PLAY"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts play : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts play : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts play : uid(%d) \n", uid ); + SLOG(LOG_DEBUG, get_tag(), "[IN] tts play : uid(%d) \n", uid ); ret = ttsd_server_play(uid); } @@ -380,23 +380,23 @@ int ttsd_dbus_server_play(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts play : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] tts play : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts play : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts play : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts play : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -412,14 +412,14 @@ int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS STOP"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS STOP"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts stop : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts stop : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts stop : uid(%d)\n", uid); + SLOG(LOG_DEBUG, get_tag(), "[IN] tts stop : uid(%d)\n", uid); ret = ttsd_server_stop(uid); } @@ -432,23 +432,23 @@ int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts stop : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] tts stop : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts stop : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts stop : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts stop : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -465,14 +465,14 @@ int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS PAUSE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS PAUSE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] tts pause : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts pause : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] tts pause : uid(%d)\n", uid); + SLOG(LOG_DEBUG, get_tag(), "[IN] tts pause : uid(%d)\n", uid); ret = ttsd_server_pause(uid, &uttid); } @@ -485,23 +485,23 @@ int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] tts pause : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] tts pause : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts pause : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts pause : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] tts pause : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -523,14 +523,14 @@ int ttsd_dbus_server_setting_initialize(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING INITIALIZE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING INITIALIZE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] Receivce setting initialize : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] Receivce setting initialize : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] Receivce setting initialize : pid(%d) \n", pid); + SLOG(LOG_DEBUG, get_tag(), "[IN] Receivce setting initialize : pid(%d) \n", pid); ret = ttsd_server_setting_initialize(pid); } @@ -541,23 +541,23 @@ int ttsd_dbus_server_setting_initialize(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting initialize : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting initialize : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting initialize : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting initialize : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting initialize : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting initialize : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting initialize : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting initialize : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -572,14 +572,14 @@ int ttsd_dbus_server_setting_finalize(DBusConnection* conn, DBusMessage* msg) dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING FINALIZE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING FINALIZE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting finalize : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting finalize : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting finalize : pid(%d)\n", pid); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting finalize : pid(%d)\n", pid); ret = ttsd_server_setting_finalize(pid); } @@ -590,23 +590,23 @@ int ttsd_dbus_server_setting_finalize(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting finalize : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting finalize : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting finalize : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting finalize : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting finalize : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting finalize : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting finalize : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting finalize : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -622,14 +622,14 @@ int ttsd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage* dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET ENGINE LIST"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET ENGINE LIST"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting engine list : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting engine list : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting engine list : pid(%d) \n", pid); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting engine list : pid(%d) \n", pid); ret = ttsd_server_setting_get_engine_list(pid, &engine_list); } @@ -647,7 +647,7 @@ int ttsd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage* /* Append size */ int size = g_list_length(engine_list); if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting engine list : fail to append engine size \n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting engine list : fail to append engine size \n"); } else { GList *iter = NULL; @@ -659,7 +659,7 @@ int ttsd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage* engine = iter->data; if (NULL != engine) { - SLOG(LOG_DEBUG, TAG_TTSD, "engine id : %s, engine name : %s, ug_name, : %s", + SLOG(LOG_DEBUG, get_tag(), "engine id : %s, engine name : %s, ug_name, : %s", engine->engine_id, engine->engine_name, engine->ug_name); dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_id) ); @@ -680,24 +680,24 @@ int ttsd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage* iter = g_list_first(engine_list); } - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting engine list : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting engine list : result(%d) \n", ret); } } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting engine list : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting engine list : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting engine list : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting engine list : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting engine list : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting engine list : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -715,14 +715,14 @@ int ttsd_dbus_server_setting_get_engine(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET ENGINE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET ENGINE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting get engine : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting get engine : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting get engine : pid(%d)\n", pid); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting get engine : pid(%d)\n", pid); ret = ttsd_server_setting_get_current_engine(pid, &engine_id); } @@ -732,27 +732,27 @@ int ttsd_dbus_server_setting_get_engine(DBusConnection* conn, DBusMessage* msg) if (NULL != reply) { if (0 == ret) { dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_STRING, &engine_id, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting get engine : result(%d), engine id(%s)\n", ret, engine_id); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting get engine : result(%d), engine id(%s)\n", ret, engine_id); } else { dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine : result(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine : result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine : fail to create reply message!!"); } if (NULL != engine_id) free(engine_id); - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -771,14 +771,14 @@ int ttsd_dbus_server_setting_set_engine(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_STRING, &engine_id, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING SET ENGINE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING SET ENGINE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting set engine : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting set engine : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting set engine : pid(%d), engine id(%s)\n", pid, engine_id); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting set engine : pid(%d), engine id(%s)\n", pid, engine_id); ret = ttsd_server_setting_set_current_engine(pid, engine_id); } @@ -789,23 +789,23 @@ int ttsd_dbus_server_setting_set_engine(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting set engine : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting set engine : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -824,14 +824,14 @@ int ttsd_dbus_server_setting_get_voice_list(DBusConnection* conn, DBusMessage* m DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET VOICE LIST"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET VOICE LIST"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting voice list : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting voice list : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting voice list : pid(%d)\n", pid); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting voice list : pid(%d)\n", pid); ret = ttsd_server_setting_get_voice_list(pid, &engine_id, &voice_list); } @@ -851,7 +851,7 @@ int ttsd_dbus_server_setting_get_voice_list(DBusConnection* conn, DBusMessage* m /* Append voice size */ int size = g_list_length(voice_list); if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Fail to append type \n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Fail to append type \n"); ret = TTSD_ERROR_OPERATION_FAILED; } else { @@ -878,29 +878,29 @@ int ttsd_dbus_server_setting_get_voice_list(DBusConnection* conn, DBusMessage* m iter = g_list_first(voice_list); } } - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting voice list : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting voice list : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Fail to append engine_id \n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Fail to append engine_id \n"); } if (NULL != engine_id) free(engine_id); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -919,14 +919,14 @@ int ttsd_dbus_server_setting_get_default_voice(DBusConnection* conn, DBusMessage DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET DEFAULT VOICE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET DEFAULT VOICE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting get default voice : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting get default voice : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting get default voice : pid(%d)\n", pid); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting get default voice : pid(%d)\n", pid); ret = ttsd_server_setting_get_default_voice(pid, &lang, &type); } @@ -940,24 +940,24 @@ int ttsd_dbus_server_setting_get_default_voice(DBusConnection* conn, DBusMessage DBUS_TYPE_STRING, &lang, DBUS_TYPE_INT32, &type, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting get default voice : result(%d), language(%s), type(%d) \n", ret, lang, type); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting get default voice : result(%d), language(%s), type(%d) \n", ret, lang, type); } else { dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default voice : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default voice : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default voice : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default voice : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default voice : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default voice : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -978,14 +978,14 @@ int ttsd_dbus_server_setting_set_default_voice(DBusConnection* conn, DBusMessage DBUS_TYPE_INT32, &voicetype, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SET DEFAULT VOICE"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SET DEFAULT VOICE"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting set default voice : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting set default voice : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting set default voice : pid(%d), lang(%s), type(%d)\n" + SLOG(LOG_DEBUG, get_tag(), "[IN] setting set default voice : pid(%d), lang(%s), type(%d)\n" , pid, language, voicetype); ret = ttsd_server_setting_set_default_voice(pid, language, voicetype); } @@ -997,23 +997,23 @@ int ttsd_dbus_server_setting_set_default_voice(DBusConnection* conn, DBusMessage dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting set default voice : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting set default voice : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default voice : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default voice : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default voice : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default voice : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default voice : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default voice : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -1031,14 +1031,14 @@ int ttsd_dbus_server_setting_get_speed(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET SPEED"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET SPEED"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting get speed : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting get speed : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting get default speed : pid(%d)\n", pid); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting get default speed : pid(%d)\n", pid); ret = ttsd_server_setting_get_default_speed(pid, &speed); } @@ -1048,24 +1048,24 @@ int ttsd_dbus_server_setting_get_speed(DBusConnection* conn, DBusMessage* msg) if (NULL != reply) { if (0 == ret) { dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INT32, &speed, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting get default speed : result(%d), speed(%d) \n", ret, speed); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting get default speed : result(%d), speed(%d) \n", ret, speed); } else { dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default speed : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default speed : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default speed : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default speed : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get default speed : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default speed : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -1084,14 +1084,14 @@ int ttsd_dbus_server_setting_set_speed(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INT32, &speed, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET SPEED"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET SPEED"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting set default speed : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting set default speed : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting set default speed : pid(%d), speed(%d)\n", pid, speed); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting set default speed : pid(%d), speed(%d)\n", pid, speed); ret = ttsd_server_setting_set_default_speed(pid, speed); } @@ -1102,23 +1102,23 @@ int ttsd_dbus_server_setting_set_speed(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting set default speed : result(%d)", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting set default speed : result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default speed : result(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default speed : result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default speed : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default speed : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set default speed : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default speed : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -1137,14 +1137,14 @@ int ttsd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessag DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING GET ENGINE SETTING"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET ENGINE SETTING"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting get engine option : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting get engine option : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting get engine option : pid(%d)", pid); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting get engine option : pid(%d)", pid); ret = ttsd_server_setting_get_engine_setting(pid, &engine_id, &engine_setting_list); } @@ -1163,7 +1163,7 @@ int ttsd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessag /* Append voice size */ int size = g_list_length(engine_setting_list); if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Fail to append type \n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Fail to append type \n"); ret = TTSD_ERROR_OPERATION_FAILED; } else { @@ -1192,29 +1192,29 @@ int ttsd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessag iter = g_list_first(engine_setting_list); } } - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting engine setting list : result(%d) \n", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting engine setting list : result(%d) \n", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting voice list : Fail to append engine_id \n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Fail to append engine_id \n"); } if (NULL != engine_id) free(engine_id); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine option : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine option : result(%d) \n", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine option : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine option : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting get engine option : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine option : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -1235,14 +1235,14 @@ int ttsd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessag DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> SETTING SET ENGINE SETTING"); + SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING SET ENGINE SETTING"); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] setting set engine option : Get arguments error (%s)\n", err.message); + SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting set engine option : Get arguments error (%s)\n", err.message); dbus_error_free(&err); ret = TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[IN] setting set engine option : pid(%d), key(%s), value(%s)\n", pid, key, value); + SLOG(LOG_DEBUG, get_tag(), "[IN] setting set engine option : pid(%d), key(%s), value(%s)\n", pid, key, value); ret = ttsd_server_setting_set_engine_setting(pid, key, value); } @@ -1253,22 +1253,22 @@ int ttsd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessag dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] setting set engine option : result(%d)", ret); + SLOG(LOG_DEBUG, get_tag(), "[OUT] setting set engine option : result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine option : result(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine option : result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine option : Out Of Memory!\n"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine option : Out Of Memory!\n"); } dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] setting set engine option : fail to create reply message!!"); + SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine option : fail to create reply message!!"); } - SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "<<<<<"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } diff --git a/server/ttsd_engine_agent.c b/server/ttsd_engine_agent.c index 44a1972..e873ba1 100755 --- a/server/ttsd_engine_agent.c +++ b/server/ttsd_engine_agent.c @@ -103,7 +103,7 @@ int ttsd_engine_agent_init(synth_result_callback result_cb) { /* initialize static data */ if (result_cb == NULL) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] invalid parameter \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] invalid parameter"); return TTSD_ERROR_INVALID_PARAMETER; } @@ -121,19 +121,19 @@ int ttsd_engine_agent_init(synth_result_callback result_cb) g_agent_init = true; if (0 != ttsd_config_get_default_voice(&(g_cur_engine.default_lang), &(g_cur_engine.default_vctype))) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] There is No default voice in config\n"); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] There is No default voice in config"); /* Set default voice */ g_cur_engine.default_lang = strdup("en_US"); g_cur_engine.default_vctype = TTSP_VOICE_TYPE_FEMALE; } if (0 != ttsd_config_get_default_speed(&(g_cur_engine.default_speed))) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] There is No default speed in config\n"); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] There is No default speed in config"); ttsd_config_set_default_speed((int)TTSP_SPEED_NORMAL); g_cur_engine.default_speed = TTSP_SPEED_NORMAL; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Initialize Engine Agent "); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Initialize Engine Agent"); return 0; } @@ -141,7 +141,7 @@ int ttsd_engine_agent_init(synth_result_callback result_cb) int ttsd_engine_agent_release() { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized"); return TTSD_ERROR_OPERATION_FAILED; } @@ -176,7 +176,7 @@ int ttsd_engine_agent_release() g_free(g_cur_engine.default_lang); - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Release Engine Agent\n"); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Release Engine Agent"); return 0; } @@ -184,13 +184,13 @@ int ttsd_engine_agent_release() int ttsd_engine_agent_initialize_current_engine() { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } /* update engine list */ if (0 != __internal_update_engine_list()) { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent WARNING] No engine error \n"); + SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] No engine error"); return TTSD_ERROR_OPERATION_FAILED; } @@ -219,14 +219,14 @@ int ttsd_engine_agent_initialize_current_engine() iter = g_list_next(iter); } } else { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent WARNING] Fail to set a engine of engine list\n"); + SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Fail to set a engine of engine list\n"); return TTSD_ERROR_OPERATION_FAILED; } if (NULL != data->engine_uuid) { cur_engine_uuid = strdup(data->engine_uuid); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Data of current engine is corrupt\n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Data of current engine is corrupt\n"); return TTSD_ERROR_OPERATION_FAILED; } @@ -237,14 +237,14 @@ int ttsd_engine_agent_initialize_current_engine() /* check whether cur engine uuid is valid or not. */ if (0 != __internal_check_engine_id(cur_engine_uuid)) { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent WARNING] It is not valid engine id from config \n"); + SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] It is not valid engine id from config"); GList *iter = NULL; if (g_list_length(g_engine_list) > 0) iter = g_list_first(g_engine_list); else { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent ERROR] NO TTS Engine !! \n"); + SLOG(LOG_WARN, get_tag(), "[Engine Agent ERROR] NO TTS Engine !!"); return TTSD_ERROR_OPERATION_FAILED; } @@ -260,25 +260,25 @@ int ttsd_engine_agent_initialize_current_engine() } if (NULL != cur_engine_uuid) - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] Current Engine Id : %s \n", cur_engine_uuid); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Current Engine Id : %s", cur_engine_uuid); else return TTSD_ERROR_OPERATION_FAILED; /* set current engine */ if (0 != __internal_set_current_engine(cur_engine_uuid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to set current engine "); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to set current engine "); return TTSD_ERROR_OPERATION_FAILED; } if (false == is_get_engineid_from_config) { if (0 != ttsd_config_set_default_engine(cur_engine_uuid)) - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to set id to config \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to set id to config"); } if (NULL != cur_engine_uuid) g_free(cur_engine_uuid); - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Set current engine"); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set current engine"); return 0; } @@ -323,21 +323,21 @@ int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info) handle = dlopen (filepath, RTLD_LAZY ); if (!handle) { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent] Invalid engine : %s", filepath); + SLOG(LOG_WARN, get_tag(), "[Engine Agent] Invalid engine : %s", filepath); return TTSD_ERROR_OPERATION_FAILED; } /* link engine to daemon */ dlsym(handle, "ttsp_load_engine"); if ((error = dlerror()) != NULL) { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent] Invalid engine. Fail to open ttsp_load_engine : %s", filepath); + SLOG(LOG_WARN, get_tag(), "[Engine Agent] Invalid engine. Fail to open ttsp_load_engine : %s", filepath); dlclose(handle); return TTSD_ERROR_OPERATION_FAILED; } dlsym(handle, "ttsp_unload_engine"); if ((error = dlerror()) != NULL) { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent] Invalid engine. Fail to open ttsp_unload_engine : %s", filepath); + SLOG(LOG_WARN, get_tag(), "[Engine Agent] Invalid engine. Fail to open ttsp_unload_engine : %s", filepath); dlclose(handle); return TTSD_ERROR_OPERATION_FAILED; } @@ -346,7 +346,7 @@ int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info) get_engine_info = (int (*)(ttsp_engine_info_cb, void*))dlsym(handle, "ttsp_get_engine_info"); if (NULL != (error = dlerror()) || NULL == get_engine_info) { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent] ttsp_get_engine_info() link error"); + SLOG(LOG_WARN, get_tag(), "[Engine Agent] ttsp_get_engine_info() link error"); dlclose(handle); return TTSD_ERROR_OPERATION_FAILED; } @@ -356,7 +356,7 @@ int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info) /* get engine info */ if (0 != get_engine_info(&__engine_info_cb, (void*)temp)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get engine info"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get engine info"); dlclose(handle); g_free(temp); return TTSD_ERROR_OPERATION_FAILED; @@ -365,16 +365,24 @@ int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info) /* close engine */ dlclose(handle); + if (TTSD_MODE_NOTIFICATION == ttsd_get_mode() || TTSD_MODE_SCREEN_READER == ttsd_get_mode()) { + if (true == temp->use_network) { + free(temp); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent WARNING] %s is invalid because of network based engine.", temp->engine_name); + return TTSD_ERROR_OPERATION_FAILED; + } + } + temp->engine_path = g_strdup(filepath); - SLOG(LOG_DEBUG, TAG_TTSD, "----- Valid engine"); - SLOG(LOG_DEBUG, TAG_TTSD, "Engine uuid : %s", temp->engine_uuid); - SLOG(LOG_DEBUG, TAG_TTSD, "Engine name : %s", temp->engine_name); - SLOG(LOG_DEBUG, TAG_TTSD, "Setting ug path : %s", temp->setting_ug_path); - SLOG(LOG_DEBUG, TAG_TTSD, "Engine path : %s", temp->engine_path); - SLOG(LOG_DEBUG, TAG_TTSD, "Use network : %s", temp->use_network ? "true":"false"); - SLOG(LOG_DEBUG, TAG_TTSD, "-----"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "----- Valid engine"); + SLOG(LOG_DEBUG, get_tag(), "Engine uuid : %s", temp->engine_uuid); + SLOG(LOG_DEBUG, get_tag(), "Engine name : %s", temp->engine_name); + SLOG(LOG_DEBUG, get_tag(), "Setting ug path : %s", temp->setting_ug_path); + SLOG(LOG_DEBUG, get_tag(), "Engine path : %s", temp->engine_path); + SLOG(LOG_DEBUG, get_tag(), "Use network : %s", temp->use_network ? "true":"false"); + SLOG(LOG_DEBUG, get_tag(), "-----"); + SLOG(LOG_DEBUG, get_tag(), " "); *info = temp; @@ -420,7 +428,7 @@ int __internal_update_engine_list() strncat(filepath, "/", strlen("/") ); strncat(filepath, dirp->d_name, strlen(dirp->d_name) ); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not enough memory!! \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not enough memory!!" ); continue; } @@ -453,7 +461,7 @@ int __internal_update_engine_list() strcat(filepath, "/"); strcat(filepath, dirp->d_name); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not enough memory!! \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not enough memory!!" ); continue; } @@ -471,7 +479,7 @@ int __internal_update_engine_list() } if (g_list_length(g_engine_list) <= 0) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] No Engine\n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No Engine\n"); return TTSD_ERROR_OPERATION_FAILED; } @@ -507,13 +515,13 @@ int __internal_set_current_engine(const char* engine_uuid) /* If current engine does not exist, return error */ if (false == flag) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] __internal_set_current_engine : Cannot find engine id \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] __internal_set_current_engine : Cannot find engine id"); return TTSD_ERROR_OPERATION_FAILED; } else { if (g_cur_engine.engine_uuid != NULL) { /*compare current engine uuid */ if (0 == strncmp(g_cur_engine.engine_uuid, data->engine_uuid, strlen(engine_uuid))) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] tts engine has already been set \n"); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] tts engine has already been set"); return 0; } } @@ -525,7 +533,7 @@ int __internal_set_current_engine(const char* engine_uuid) if (g_cur_engine.engine_path != NULL) g_free(g_cur_engine.engine_path); if (NULL == data->engine_uuid || NULL == data->engine_name || NULL == data->engine_path) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] __internal_set_current_engine : Engine data is NULL"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] __internal_set_current_engine : Engine data is NULL"); return TTSD_ERROR_OPERATION_FAILED; } @@ -538,11 +546,11 @@ int __internal_set_current_engine(const char* engine_uuid) g_cur_engine.is_set = true; g_cur_engine.need_network = data->use_network; - SLOG(LOG_DEBUG, TAG_TTSD, "-----"); - SLOG(LOG_DEBUG, TAG_TTSD, "Current engine uuid : %s \n", g_cur_engine.engine_uuid); - SLOG(LOG_DEBUG, TAG_TTSD, "Current engine name : %s \n", g_cur_engine.engine_name); - SLOG(LOG_DEBUG, TAG_TTSD, "Current engine path : %s \n", g_cur_engine.engine_path); - SLOG(LOG_DEBUG, TAG_TTSD, "-----"); + SLOG(LOG_DEBUG, get_tag(), "-----"); + SLOG(LOG_DEBUG, get_tag(), "Current engine uuid : %s", g_cur_engine.engine_uuid); + SLOG(LOG_DEBUG, get_tag(), "Current engine name : %s", g_cur_engine.engine_name); + SLOG(LOG_DEBUG, get_tag(), "Current engine path : %s", g_cur_engine.engine_path); + SLOG(LOG_DEBUG, get_tag(), "-----"); return 0; } @@ -550,41 +558,41 @@ int __internal_set_current_engine(const char* engine_uuid) int ttsd_engine_agent_load_current_engine() { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_set) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] ttsd_engine_agent_load_current_engine : No Current Engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ttsd_engine_agent_load_current_engine : No Current Engine "); return TTSD_ERROR_OPERATION_FAILED; } /* check whether current engine is loaded or not */ if (true == g_cur_engine.is_loaded ) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent] ttsd_engine_agent_load_current_engine : Engine has already been loaded \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent] ttsd_engine_agent_load_current_engine : Engine has already been loaded " ); return 0; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] current engine path : %s\n", g_cur_engine.engine_path); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] current engine path : %s\n", g_cur_engine.engine_path); /* open engine */ char *error = NULL; g_cur_engine.handle = dlopen(g_cur_engine.engine_path, RTLD_LAZY); /* RTLD_LAZY RTLD_NOW*/ 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); + SLOG(LOG_ERROR, get_tag(), "[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 (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); + SLOG(LOG_ERROR, get_tag(), "[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 : %s", error); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to link daemon to ttsp_load_engine() of current engine : %s", error); return -3; } @@ -596,27 +604,27 @@ int ttsd_engine_agent_load_current_engine() ret = g_cur_engine.ttsp_load_engine(g_cur_engine.pdfuncs, g_cur_engine.pefuncs); if (0 != ret) { printf("Fail load '%s' engine\n", g_cur_engine.engine_path); - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to load engine : result(%d) \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to load engine : result(%d)"); return TTSD_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] engine info : version(%d), size(%d)\n",g_cur_engine.pefuncs->version, g_cur_engine.pefuncs->size ); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] engine info : version(%d), size(%d)\n",g_cur_engine.pefuncs->version, g_cur_engine.pefuncs->size ); /* engine error check */ if (g_cur_engine.pefuncs->size != sizeof(ttspe_funcs_s)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] ttsd_engine_agent_load_current_engine : current engine is not valid \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ttsd_engine_agent_load_current_engine : current engine is not valid"); return TTSD_ERROR_OPERATION_FAILED; } /* initalize engine */ if (NULL == g_cur_engine.pefuncs->initialize) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] init function of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] init function of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } ret = g_cur_engine.pefuncs->initialize(__result_cb); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to initialize current engine : result(%d)\n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to initialize current engine : result(%d)\n", ret); return TTSD_ERROR_OPERATION_FAILED; } @@ -624,23 +632,23 @@ int ttsd_engine_agent_load_current_engine() bool set_voice = false; if (NULL != g_cur_engine.default_lang) { if (NULL == g_cur_engine.pefuncs->is_valid_voice) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] is_valid_voice() of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] is_valid_voice() of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } if (true == g_cur_engine.pefuncs->is_valid_voice(g_cur_engine.default_lang, g_cur_engine.default_vctype)) { set_voice = true; - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Set origin default voice to current engine : lang(%s), type(%d) \n", + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set origin default voice to current engine : lang(%s), type(%d)", g_cur_engine.default_lang, g_cur_engine.default_vctype); } else { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent WARNING] Fail set origin default voice : lang(%s), type(%d)\n", + SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Fail set origin default voice : lang(%s), type(%d)\n", g_cur_engine.default_lang, g_cur_engine.default_vctype); } } if (false == set_voice) { if (NULL == g_cur_engine.pefuncs->foreach_voices) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] get_voice_list of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] get_voice_list of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } @@ -660,7 +668,7 @@ int ttsd_engine_agent_load_current_engine() voice = iter->data; if (true != g_cur_engine.pefuncs->is_valid_voice(voice->language, voice->type)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine ERROR] Fail voice is NOT valid"); + SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail voice is NOT valid"); return TTSD_ERROR_OPERATION_FAILED; } @@ -669,18 +677,18 @@ int ttsd_engine_agent_load_current_engine() g_cur_engine.default_lang = g_strdup(voice->language); g_cur_engine.default_vctype = voice->type; - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Select default voice : lang(%s), type(%d) \n", + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Select default voice : lang(%s), type(%d)", voice->language, voice->type); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine ERROR] Fail to get language list : result(%d)\n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail to get language list : result(%d)\n", ret); return TTSD_ERROR_OPERATION_FAILED; } __free_voice_list(voice_list); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine ERROR] Fail to get language list : result(%d)\n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail to get language list : result(%d)\n", ret); return TTSD_ERROR_OPERATION_FAILED; } } @@ -693,28 +701,28 @@ int ttsd_engine_agent_load_current_engine() int ttsd_engine_agent_unload_current_engine() { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_set) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] No Current Engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No Current Engine "); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] Engine has already been unloaded \n" ); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Engine has already been unloaded " ); return 0; } /* shutdown engine */ if (NULL == g_cur_engine.pefuncs->deinitialize) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] The deinitialize() of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] The deinitialize() of engine is NULL!!"); } else { int ret = 0; ret = g_cur_engine.pefuncs->deinitialize(); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent] Fail deinitialize() : result(%d)\n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent] Fail deinitialize() : result(%d)\n", ret); } } @@ -733,12 +741,12 @@ int ttsd_engine_agent_unload_current_engine() bool ttsd_engine_agent_need_network() { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } @@ -751,7 +759,7 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, return false; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] Select voice : input lang(%s) , input type(%d), default lang(%s), default type(%d)", + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Select voice : input lang(%s) , input type(%d), default lang(%s), default type(%d)", lang, type, g_cur_engine.default_lang, g_cur_engine.default_vctype); @@ -759,13 +767,12 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, if (0 == strncmp(lang, "default", strlen("default")) && 0 == type) { *out_lang = strdup(g_cur_engine.default_lang); *out_type = g_cur_engine.default_vctype; - return true; - + return true; } /* Get voice list */ if (NULL == g_cur_engine.pefuncs->foreach_voices) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] foreach_voices of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] foreach_voices of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } @@ -774,7 +781,7 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, ret = g_cur_engine.pefuncs->foreach_voices(__supported_voice_cb, &voice_list); if (0 != ret || 0 >= g_list_length(voice_list)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get voice list : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get voice list : result(%d)", ret); return false; } @@ -863,7 +870,7 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, } if (true == result) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] Selected voice : lang(%s), type(%d) \n", *out_lang, *out_type); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Selected voice : lang(%s), type(%d)", *out_lang, *out_type); } __free_voice_list(voice_list); @@ -874,12 +881,12 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, bool ttsd_engine_agent_is_same_engine(const char* engine_id) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return false; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return false; } @@ -891,21 +898,59 @@ bool ttsd_engine_agent_is_same_engine(const char* engine_id) return false; } +int ttsd_engine_agent_set_default_voice(const char* language, ttsp_voice_type_e vctype) +{ + if (false == g_agent_init) { + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); + return TTSD_ERROR_OPERATION_FAILED; + } + + if (false == g_cur_engine.is_loaded) { + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); + return TTSD_ERROR_OPERATION_FAILED; + } + + if (NULL == g_cur_engine.pefuncs->is_valid_voice) { + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] The function of engine is NULL!!"); + return TTSD_ERROR_OPERATION_FAILED; + } + + int ret = -1; + if(false == g_cur_engine.pefuncs->is_valid_voice(language, vctype)) { + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Voice is NOT valid !!"); + return TTSD_ERROR_INVALID_VOICE; + } + + if (NULL != g_cur_engine.default_lang) + free(g_cur_engine.default_lang); + + g_cur_engine.default_lang = strdup(language); + g_cur_engine.default_vctype = vctype; + + ret = ttsd_config_set_default_voice(language, (int)vctype); + if (0 == ret) { + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d)", + g_cur_engine.default_lang, g_cur_engine.default_vctype); + } else { + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to write default voice to config (%d)", ret); + } +} + /****************************************************************************************** * TTS Engine Interfaces for client *******************************************************************************************/ int ttsd_engine_start_synthesis(const char* lang, const ttsp_voice_type_e vctype, const char* text, const int speed, void* user_param) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] start ttsd_engine_start_synthesis() \n"); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] start ttsd_engine_start_synthesis()"); if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } @@ -913,15 +958,15 @@ int ttsd_engine_start_synthesis(const char* lang, const ttsp_voice_type_e vctype char* temp_lang = NULL; ttsp_voice_type_e temp_type; if (true != ttsd_engine_select_valid_voice(lang, vctype, &temp_lang, &temp_type)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Fail to select default voice \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to select default voice"); return TTSD_ERROR_INVALID_VOICE; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] Start synthesis : language(%s), type(%d), speed(%d), text(%s) \n", + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Start synthesis : language(%s), type(%d), speed(%d), text(%s)", temp_lang, temp_type, speed, text); } if (NULL == g_cur_engine.pefuncs->start_synth) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] start_synth() of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] start_synth() of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } @@ -937,9 +982,9 @@ int ttsd_engine_start_synthesis(const char* lang, const ttsp_voice_type_e vctype int ret = 0; ret = g_cur_engine.pefuncs->start_synth(temp_lang, temp_type, text, temp_speed, user_param); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] ***************************************", ret); - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] * synthesize error : result(%6d) *", ret); - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] ***************************************", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ***************************************", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] * synthesize error : result(%6d) *", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ***************************************", ret); return TTSD_ERROR_OPERATION_FAILED; } @@ -952,20 +997,20 @@ int ttsd_engine_start_synthesis(const char* lang, const ttsp_voice_type_e vctype int ttsd_engine_cancel_synthesis() { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] start ttsd_engine_cancel_synthesis() \n"); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] start ttsd_engine_cancel_synthesis()"); if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } if (NULL == g_cur_engine.pefuncs->cancel_synth) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] cancel_synth() of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] cancel_synth() of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } @@ -973,7 +1018,7 @@ int ttsd_engine_cancel_synthesis() int ret = 0; ret = g_cur_engine.pefuncs->cancel_synth(); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail cancel synthesis : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail cancel synthesis : result(%d)", ret); return TTSD_ERROR_OPERATION_FAILED; } @@ -983,27 +1028,27 @@ int ttsd_engine_cancel_synthesis() int ttsd_engine_get_audio_format( ttsp_audio_type_e* type, int* rate, int* channels) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } if (NULL == g_cur_engine.pefuncs->get_audio_format) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] get_audio_format() of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] get_audio_format() of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } int ret = 0; ret = g_cur_engine.pefuncs->get_audio_format(type, rate, channels); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get audio format : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get audio format : result(%d)", ret); return TTSD_ERROR_OPERATION_FAILED; } else - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] get audio format : type(%d), rate(%d), channel(%d) \n", *type, *rate, *channels); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] get audio format : type(%d), rate(%d), channel(%d)", *type, *rate, *channels); return 0; } @@ -1013,11 +1058,11 @@ bool __supported_voice_cb(const char* language, ttsp_voice_type_e type, void* us GList** voice_list = (GList**)user_data; if (NULL == language || NULL == voice_list) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!"); return false; } - SLOG(LOG_DEBUG, TAG_TTSD, "-- Language(%s), Type(%d)", language, type); + SLOG(LOG_DEBUG, get_tag(), "-- Language(%s), Type(%d)", language, type); voice_s* voice = g_malloc0(sizeof(voice_s)); voice->language = strdup(language); @@ -1031,24 +1076,24 @@ bool __supported_voice_cb(const char* language, ttsp_voice_type_e type, void* us int ttsd_engine_get_voice_list(GList** voice_list) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } if (NULL == g_cur_engine.pefuncs->foreach_voices) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] The function of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] The function of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } int ret = 0; ret = g_cur_engine.pefuncs->foreach_voices(__supported_voice_cb, (void*)voice_list); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Fail to get voice list : result(%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to get voice list : result(%d)", ret); return TTSD_ERROR_OPERATION_FAILED; } @@ -1058,17 +1103,17 @@ int ttsd_engine_get_voice_list(GList** voice_list) int ttsd_engine_get_default_voice( char** lang, ttsp_voice_type_e* vctype ) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } if (NULL == lang || NULL == vctype) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] BAD Parameter \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] BAD Parameter"); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1076,10 +1121,10 @@ int ttsd_engine_get_default_voice( char** lang, ttsp_voice_type_e* vctype ) *lang = g_strdup(g_cur_engine.default_lang); *vctype = g_cur_engine.default_vctype; - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine] Get default voice : language(%s), type(%d)\n", *lang, *vctype); + SLOG(LOG_DEBUG, get_tag(), "[Engine] Get default voice : language(%s), type(%d)\n", *lang, *vctype); } else { if (NULL == g_cur_engine.pefuncs->foreach_voices) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] get_voice_list of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] get_voice_list of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } @@ -1099,7 +1144,7 @@ int ttsd_engine_get_default_voice( char** lang, ttsp_voice_type_e* vctype ) voice = iter->data; if (true != g_cur_engine.pefuncs->is_valid_voice(voice->language, voice->type)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine ERROR] Fail voice is NOT valid "); + SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail voice is NOT valid "); return TTSD_ERROR_OPERATION_FAILED; } @@ -1114,15 +1159,15 @@ int ttsd_engine_get_default_voice( char** lang, ttsp_voice_type_e* vctype ) *lang = g_strdup(g_cur_engine.default_lang); *vctype = g_cur_engine.default_vctype = voice->type; - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine] Get default voice (New selected) : language(%s), type(%d)\n", *lang, *vctype); + SLOG(LOG_DEBUG, get_tag(), "[Engine] Get default voice (New selected) : language(%s), type(%d)\n", *lang, *vctype); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine ERROR] Fail to get language list : result(%d)\n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail to get language list : result(%d)\n", ret); return TTSD_ERROR_OPERATION_FAILED; } __free_voice_list(voice_list); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine ERROR] Fail to get language list : result(%d)\n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail to get language list : result(%d)\n", ret); return TTSD_ERROR_OPERATION_FAILED; } } @@ -1136,18 +1181,18 @@ int ttsd_engine_get_default_voice( char** lang, ttsp_voice_type_e* vctype ) int ttsd_engine_setting_get_engine_list(GList** engine_list) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (NULL == engine_list) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Input parameter is NULL" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL" ); return TTSD_ERROR_INVALID_PARAMETER; } /* update engine list */ if (0 != __internal_update_engine_list()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail __internal_update_engine_list() \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail __internal_update_engine_list()"); return TTSD_ERROR_OPERATION_FAILED; } @@ -1156,7 +1201,7 @@ int ttsd_engine_setting_get_engine_list(GList** engine_list) iter = g_list_first(g_engine_list); - SLOG(LOG_DEBUG, TAG_TTSD, "----- [Engine Agent] engine list -----"); + SLOG(LOG_DEBUG, get_tag(), "----- [Engine Agent] engine list -----"); while (NULL != iter) { engine_s* temp_engine; @@ -1173,12 +1218,12 @@ int ttsd_engine_setting_get_engine_list(GList** engine_list) iter = g_list_next(iter); - SLOG(LOG_DEBUG, TAG_TTSD, " -- engine id(%s) engine name(%s) ug name(%s) \n", + SLOG(LOG_DEBUG, get_tag(), " -- engine id(%s) engine name(%s) ug name(%s)", temp_engine->engine_id, temp_engine->engine_name, temp_engine->ug_name); } - SLOG(LOG_DEBUG, TAG_TTSD, "--------------------------------------"); + SLOG(LOG_DEBUG, get_tag(), "--------------------------------------"); return 0; } @@ -1186,12 +1231,12 @@ int ttsd_engine_setting_get_engine_list(GList** engine_list) int ttsd_engine_setting_get_engine(char** engine_id) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_ENGINE_NOT_FOUND; } @@ -1203,13 +1248,13 @@ int ttsd_engine_setting_get_engine(char** engine_id) int ttsd_engine_setting_set_engine(const char* engine_id) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } /* compare current engine and new engine.*/ if (0 == strncmp(g_cur_engine.engine_uuid, engine_id, strlen(engine_id))) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] new engine(%s) is the same as current engine(%s) \n", engine_id, g_cur_engine.engine_uuid); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] new engine(%s) is the same as current engine(%s)", engine_id, g_cur_engine.engine_uuid); return 0; } @@ -1218,14 +1263,14 @@ int ttsd_engine_setting_set_engine(const char* engine_id) /* unload engine */ if (0 != ttsd_engine_agent_unload_current_engine()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent Error] fail to unload current engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent Error] fail to unload current engine"); } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] unload current engine \n"); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] unload current engine"); } /* change current engine */ if (0 != __internal_set_current_engine(engine_id)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail __internal_set_current_engine() \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail __internal_set_current_engine()"); /* roll back to old current engine. */ __internal_set_current_engine(tmp_uuid); @@ -1239,19 +1284,19 @@ int ttsd_engine_setting_set_engine(const char* engine_id) /* load engine */ if (0 != ttsd_engine_agent_load_current_engine()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent Error] fail to load new engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent Error] fail to load new engine"); if( tmp_uuid != NULL ) free(tmp_uuid); return TTSD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] load new engine \n"); + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] load new engine"); } /* save engine id to config */ if (0 != ttsd_config_set_default_engine(engine_id)) { - SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent WARNING] Fail to save engine id to config \n"); + SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Fail to save engine id to config"); } if (tmp_uuid != NULL) @@ -1263,12 +1308,12 @@ int ttsd_engine_setting_set_engine(const char* engine_id) int ttsd_engine_setting_get_voice_list(char** engine_id, GList** voice_list) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } @@ -1277,7 +1322,7 @@ int ttsd_engine_setting_get_voice_list(char** engine_id, GList** voice_list) /* get language list from engine*/ ret = ttsd_engine_get_voice_list(voice_list); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Error] fail ttsd_engine_get_voice_list() \n"); + SLOG(LOG_ERROR, get_tag(), "[Server Error] fail ttsd_engine_get_voice_list() "); return ret; } @@ -1289,12 +1334,12 @@ int ttsd_engine_setting_get_voice_list(char** engine_id, GList** voice_list) int ttsd_engine_setting_get_default_voice(char** language, ttsp_voice_type_e* vctype) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } @@ -1305,7 +1350,7 @@ int ttsd_engine_setting_get_default_voice(char** language, ttsp_voice_type_e* vc ret = ttsd_engine_get_default_voice(&temp_lang, &temp_int); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Error] fail ttsd_engine_get_default_voice() \n"); + SLOG(LOG_ERROR, get_tag(), "[Server Error] fail ttsd_engine_get_default_voice()"); return ret; } @@ -1314,7 +1359,7 @@ int ttsd_engine_setting_get_default_voice(char** language, ttsp_voice_type_e* vc *vctype = temp_int; free(temp_lang); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Error] fail to get default language \n"); + SLOG(LOG_ERROR, get_tag(), "[Server Error] fail to get default language"); return TTSD_ERROR_OPERATION_FAILED; } @@ -1324,23 +1369,23 @@ int ttsd_engine_setting_get_default_voice(char** language, ttsp_voice_type_e* vc int ttsd_engine_setting_set_default_voice(const char* language, ttsp_voice_type_e vctype) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } if (NULL == g_cur_engine.pefuncs->is_valid_voice) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] The function of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] The function of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } int ret = -1; if(false == g_cur_engine.pefuncs->is_valid_voice(language, vctype)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Voice is NOT valid !!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Voice is NOT valid !!"); return TTSD_ERROR_INVALID_VOICE; } @@ -1352,10 +1397,10 @@ int ttsd_engine_setting_set_default_voice(const char* language, ttsp_voice_type_ ret = ttsd_config_set_default_voice(language, (int)vctype); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d) \n", + SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d)", g_cur_engine.default_lang, g_cur_engine.default_vctype); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to write default voice to config (%d) \n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to write default voice to config (%d)", ret); } return 0; @@ -1364,12 +1409,12 @@ int ttsd_engine_setting_set_default_voice(const char* language, ttsp_voice_type_ int ttsd_engine_setting_get_default_speed(ttsp_speed_e* speed) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } @@ -1382,19 +1427,19 @@ int ttsd_engine_setting_get_default_speed(ttsp_speed_e* speed) int ttsd_engine_setting_set_default_speed(const ttsp_speed_e speed) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } g_cur_engine.default_speed = speed; if (0 != ttsd_config_set_default_speed(speed)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to set default speed to config"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to set default speed to config"); } return 0; @@ -1405,7 +1450,7 @@ bool __engine_setting_cb(const char* key, const char* value, void* user_data) GList** engine_setting_list = (GList**)user_data; if (NULL == engine_setting_list || NULL == key || NULL == value) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Input parameter is NULL in engine setting callback!!!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL in engine setting callback!!!!"); return false; } @@ -1422,22 +1467,22 @@ bool __engine_setting_cb(const char* key, const char* value, void* user_data) int ttsd_engine_setting_get_engine_setting_info(char** engine_id, GList** setting_list) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } if (NULL == setting_list) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Input parameter is NULL"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL"); return TTSD_ERROR_INVALID_PARAMETER; } if (NULL == g_cur_engine.pefuncs->foreach_engine_setting) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] foreach_engine_setting() of engine is NULL!!"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] foreach_engine_setting() of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } @@ -1449,7 +1494,7 @@ int ttsd_engine_setting_get_engine_setting_info(char** engine_id, GList** settin if (0 == result && 0 < g_list_length(*setting_list)) { *engine_id = strdup(g_cur_engine.engine_uuid); } else { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get setting info : result(%d)\n", result); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get setting info : result(%d)\n", result); result = TTSD_ERROR_OPERATION_FAILED; } @@ -1459,17 +1504,17 @@ int ttsd_engine_setting_get_engine_setting_info(char** engine_id, GList** settin int ttsd_engine_setting_set_engine_setting(const char* key, const char* value) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not Initialized \n" ); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" ); return TTSD_ERROR_OPERATION_FAILED; } if (false == g_cur_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not loaded engine \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine"); return TTSD_ERROR_OPERATION_FAILED; } if (NULL == g_cur_engine.pefuncs->set_engine_setting) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] set_setting_info of engine is NULL!! \n"); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] set_setting_info of engine is NULL!!"); return TTSD_ERROR_OPERATION_FAILED; } @@ -1478,7 +1523,7 @@ int ttsd_engine_setting_set_engine_setting(const char* key, const char* value) ret = g_cur_engine.pefuncs->set_engine_setting(key, value); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to set engine setting : result(%d)\n", ret); + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to set engine setting : result(%d)\n", ret); return TTSD_ERROR_OPERATION_FAILED; } @@ -1531,27 +1576,27 @@ int ttsd_print_enginelist() if (g_list_length(g_engine_list) > 0) { iter = g_list_first(g_engine_list); - SLOG(LOG_DEBUG, TAG_TTSD, "----- engine list -----"); + SLOG(LOG_DEBUG, get_tag(), "----- engine list -----"); int i = 1; while (NULL != iter) { data = iter->data; - SLOG(LOG_DEBUG, TAG_TTSD, "[%dth]\n", i); - SLOG(LOG_DEBUG, TAG_TTSD, "engine uuid : %s\n", data->engine_uuid); - SLOG(LOG_DEBUG, TAG_TTSD, "engine name : %s\n", data->engine_name); - SLOG(LOG_DEBUG, TAG_TTSD, "engine path : %s\n", data->engine_path); - SLOG(LOG_DEBUG, TAG_TTSD, "setting ug path : %s\n", data->setting_ug_path); + SLOG(LOG_DEBUG, get_tag(), "[%dth]\n", i); + SLOG(LOG_DEBUG, get_tag(), "engine uuid : %s\n", data->engine_uuid); + SLOG(LOG_DEBUG, get_tag(), "engine name : %s\n", data->engine_name); + SLOG(LOG_DEBUG, get_tag(), "engine path : %s\n", data->engine_path); + SLOG(LOG_DEBUG, get_tag(), "setting ug path : %s\n", data->setting_ug_path); iter = g_list_next(iter); i++; } - SLOG(LOG_DEBUG, TAG_TTSD, "-----------------------"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "-----------------------"); + SLOG(LOG_DEBUG, get_tag(), " "); } else { - SLOG(LOG_DEBUG, TAG_TTSD, "----- engine list -----"); - SLOG(LOG_DEBUG, TAG_TTSD, "No Engine in directory"); - SLOG(LOG_DEBUG, TAG_TTSD, "-----------------------"); + SLOG(LOG_DEBUG, get_tag(), "----- engine list -----"); + SLOG(LOG_DEBUG, get_tag(), "No Engine in directory"); + SLOG(LOG_DEBUG, get_tag(), "-----------------------"); } return 0; diff --git a/server/ttsd_main.c b/server/ttsd_main.c index 539a2a1..57bd998 100755 --- a/server/ttsd_main.c +++ b/server/ttsd_main.c @@ -21,56 +21,68 @@ #define CLIENT_CLEAN_UP_TIME 500 +char* get_tag() +{ + return "ttsd"; +} + +ttsd_mode_e ttsd_get_mode() +{ + return TTSD_MODE_DEFAULT; +} + /* Main of TTS Daemon */ int main() { - SLOG(LOG_DEBUG, TAG_TTSD, " "); - SLOG(LOG_DEBUG, TAG_TTSD, " "); - SLOG(LOG_DEBUG, TAG_TTSD, "===== TTS DAEMON INITIALIZE"); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON DEFAULT INITIALIZE"); if (!ecore_init()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Main ERROR] fail ecore_init() \n"); + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail ecore_init() \n"); return -1; } if (0 != ttsd_initialize()) { printf("Fail to initialize tts-daemon \n"); - SLOG(LOG_ERROR, TAG_TTSD, "[Main ERROR] fail to initialize tts-daemon \n"); + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize tts-daemon"); return EXIT_FAILURE; } if (0 != ttsd_dbus_open_connection()) { printf("Fail to initialize IPC connection \n"); - SLOG(LOG_ERROR, TAG_TTSD, "[Main ERROR] fail to open dbus connection \n"); + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to open dbus connection"); return EXIT_FAILURE; } if (0 != ttsd_network_initialize()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Main ERROR] fail to initialize network \n"); + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize network"); return EXIT_FAILURE; } ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL); - SLOG(LOG_DEBUG, TAG_TTSD, "[Main] tts-daemon start...\n"); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon start...\n"); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), " "); - printf("TTS-Daemon Start...\n"); + printf("Start tts-daemon ...\n"); ecore_main_loop_begin(); - SLOG(LOG_DEBUG, TAG_TTSD, "===== TTS DAEMON FINALIZE"); + SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON DEFAULT FINALIZE"); + ttsd_network_finalize(); + ttsd_dbus_close_connection(); - ttsd_network_finalize(); + ttsd_finalize(); ecore_shutdown(); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } diff --git a/server/ttsd_main.h b/server/ttsd_main.h index 5fc8ce9..038a173 100755 --- a/server/ttsd_main.h +++ b/server/ttsd_main.h @@ -32,8 +32,6 @@ extern "C" { #endif /* TTS Daemon Define */ -#define TAG_TTSD "ttsd" - #define BASE_DIRECTORY_DEFAULT "/usr/lib/voice/tts/1.0" #define ENGINE_DIRECTORY_DEFAULT "/usr/lib/voice/tts/1.0/engine" #define ENGINE_DIRECTORY_DEFAULT_SETTING "/usr/lib/voice/tts/1.0/setting" @@ -60,6 +58,11 @@ typedef enum { TTSD_ERROR_OPERATION_FAILED = -0x0100000 | 0x25 /**< Operation failed */ }ttsd_error_e; +typedef enum { + TTSD_MODE_DEFAULT = 0, /**< Default mode for normal application */ + TTSD_MODE_NOTIFICATION, /**< Notification mode */ + TTSD_MODE_SCREEN_READER /**< Screen reader mode */ +}ttsd_mode_e; typedef enum { TTSD_INTERRUPTED_PAUSED = 0, /**< Current state change 'Pause' */ @@ -83,6 +86,12 @@ typedef struct { char* value; }engine_setting_s; +/* get daemon mode : default, notification or screen reader */ +ttsd_mode_e ttsd_get_mode(); + +/* Get log tag : default, notification, screen reader */ +char* get_tag(); + #ifdef __cplusplus } #endif diff --git a/server/ttsd_main_noti.c b/server/ttsd_main_noti.c new file mode 100755 index 0000000..523ec2e --- /dev/null +++ b/server/ttsd_main_noti.c @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +#include "ttsd_main.h" +#include "ttsd_server.h" +#include "ttsd_dbus.h" +#include "ttsd_network.h" + +#include + +#define CLIENT_CLEAN_UP_TIME 500 + +char* get_tag() +{ + return "ttsdnoti"; +} + +ttsd_mode_e ttsd_get_mode() +{ + return TTSD_MODE_NOTIFICATION; +} + +/* Main of TTS Daemon */ +int main() +{ + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON NOTI INITIALIZE"); + if (!ecore_init()) { + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail ecore_init()"); + return -1; + } + + if (0 != ttsd_initialize()) { + printf("Fail to initialize tts-daemon-noti \n"); + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize tts-daemon-noti"); + return EXIT_FAILURE; + } + + if (0 != ttsd_dbus_open_connection()) { + printf("Fail to initialize IPC connection \n"); + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to open dbus connection"); + return EXIT_FAILURE; + } + + if (0 != ttsd_network_initialize()) { + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize network"); + return EXIT_FAILURE; + } + + ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL); + + SLOG(LOG_DEBUG, get_tag(), "[Main] start tts-daemon-noti start..."); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), " "); + + printf("Start tts-daemon-noti ...\n"); + + ecore_main_loop_begin(); + + SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON NOTI FINALIZE"); + + ttsd_network_finalize(); + + ttsd_dbus_close_connection(); + + ttsd_finalize(); + + ecore_shutdown(); + + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), " "); + + return 0; +} + diff --git a/server/ttsd_main_sr.c b/server/ttsd_main_sr.c new file mode 100755 index 0000000..0add23d --- /dev/null +++ b/server/ttsd_main_sr.c @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "ttsd_main.h" +#include "ttsd_server.h" +#include "ttsd_dbus.h" +#include "ttsd_network.h" + +#include + +#define CLIENT_CLEAN_UP_TIME 500 + +char* get_tag() +{ + return "ttsdsr"; +} + +ttsd_mode_e ttsd_get_mode() +{ + return TTSD_MODE_SCREEN_READER; +} + +/* Main of TTS Daemon */ +int main() +{ + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON SR INITIALIZE"); + if (!ecore_init()) { + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail ecore_init()"); + return -1; + } + + if (0 != ttsd_initialize()) { + printf("Fail to initialize tts-daemon-sr \n"); + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize tts-daemon-sr"); + return EXIT_FAILURE; + } + + if (0 != ttsd_dbus_open_connection()) { + printf("Fail to initialize IPC connection \n"); + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to open dbus connection"); + return EXIT_FAILURE; + } + + if (0 != ttsd_network_initialize()) { + SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize network \n"); + return EXIT_FAILURE; + } + + ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL); + + SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon-sr start...\n"); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), " "); + + printf("Start tts-daemon-sr...\n"); + + ecore_main_loop_begin(); + + SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON SR FINALIZE"); + + ttsd_network_finalize(); + + ttsd_dbus_close_connection(); + + ttsd_finalize(); + + ecore_shutdown(); + + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), " "); + + return 0; +} + diff --git a/server/ttsd_network.c b/server/ttsd_network.c index f607a93..da2e18f 100755 --- a/server/ttsd_network.c +++ b/server/ttsd_network.c @@ -28,13 +28,13 @@ void __net_config_change_cb(keynode_t* node, void *data) { int network_configuration = 0; vconf_get_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND , &network_configuration); - SLOG(LOG_DEBUG, TAG_TTSD, "[Network DEBUG] Network configuration : %d", network_configuration); + SLOG(LOG_DEBUG, get_tag(), "[Network DEBUG] Network configuration : %d", network_configuration); if (network_configuration == 0) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Network] Notification : Network connection is OFF "); + SLOG(LOG_DEBUG, get_tag(), "[Network] Notification : Network connection is OFF "); g_is_connected = false; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Network] Notification : Network connection is ON "); + SLOG(LOG_DEBUG, get_tag(), "[Network] Notification : Network connection is ON "); g_is_connected = true; /* need to notify changing net to engine. */ @@ -47,7 +47,7 @@ int ttsd_network_initialize() { int network_configuration = 0; vconf_get_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND , &network_configuration); - SLOG(LOG_DEBUG, TAG_TTSD, "[Network DEBUG] Network configuration : %d", network_configuration); + SLOG(LOG_DEBUG, get_tag(), "[Network DEBUG] Network configuration : %d", network_configuration); if (network_configuration == 0) { /* "0" means the network configuration is not set. @@ -58,28 +58,28 @@ int ttsd_network_initialize() vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status); if(network_status == VCONFKEY_NETWORK_OFF){ - SLOG(LOG_DEBUG, TAG_TTSD, "[Network] Current network connection is OFF."); + SLOG(LOG_DEBUG, get_tag(), "[Network] Current network connection is OFF."); } else{ /* * This is the problem of network connection * Just terminate the application, network f/w will fix the problem automatically. */ - SLOG(LOG_WARN, TAG_TTSD, "network status is wrong or IP is not set\n"); - SLOG(LOG_WARN, TAG_TTSD, "network has problem, try again\n"); + SLOG(LOG_WARN, get_tag(), "network status is wrong or IP is not set\n"); + SLOG(LOG_WARN, get_tag(), "network has problem, try again\n"); return -1; } g_is_connected = false; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Network] Current network connection is ON."); + SLOG(LOG_DEBUG, get_tag(), "[Network] Current network connection is ON."); g_is_connected = true; } vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, __net_config_change_cb, NULL); - SLOG(LOG_DEBUG, TAG_TTSD, "[Network SUCCESS] Initialize network ...\n"); + SLOG(LOG_DEBUG, get_tag(), "[Network SUCCESS] Initialize network ...\n"); return 0; } diff --git a/server/ttsd_player.cpp b/server/ttsd_player.c similarity index 66% rename from server/ttsd_player.cpp rename to server/ttsd_player.c index f5bbfe2..a91dcc9 100755 --- a/server/ttsd_player.cpp +++ b/server/ttsd_player.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -88,10 +89,10 @@ static unsigned int g_index; static bool g_pause_info; static int g_paused_uid; - /* * Internal Interfaces */ + player_s* __player_get_item(int uid); int __save_file(const int uid, const int index, const sound_data_s data, char** filename); @@ -102,6 +103,7 @@ int __init_wave_header(WavHeader* hdr, size_t nsamples, size_t sampling_rate, in static int msg_callback(int message, void *data, void *user_param) ; + /* * Player Interfaces */ @@ -109,7 +111,7 @@ static int msg_callback(int message, void *data, void *user_param) ; int ttsd_player_init(player_result_callback_func result_cb) { if (NULL == result_cb) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] invalid parameter"); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] invalid parameter"); return TTSD_ERROR_INVALID_PARAMETER; } @@ -120,15 +122,21 @@ int ttsd_player_init(player_result_callback_func result_cb) g_index = 1; g_player_init = true; - g_pause_info = false; - g_paused_uid = -1; + if (TTSD_MODE_DEFAULT == ttsd_get_mode()) { + if (MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_EXCLUSIVE)) { + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail mm_session_init(MM_SESSION_TYPE_EXCLUSIVE)"); + } else { + SLOG(LOG_ERROR, get_tag(), "[Player SUCCESS] mm_session_init(MM_SESSION_TYPE_EXCLUSIVE)"); + } + } + return 0; } int ttsd_player_release(void) { if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized"); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized"); return TTSD_ERROR_OPERATION_FAILED; } @@ -142,13 +150,13 @@ int ttsd_player_release(void) int ttsd_player_create_instance(const int uid) { if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } /* Check uid is duplicated */ if (NULL != __player_get_item(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] uid(%d) is already registered", uid); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is already registered", uid); return -1; } @@ -157,7 +165,7 @@ int ttsd_player_create_instance(const int uid) ret = mm_player_create(&player_handle); if (ret != MM_ERROR_NONE || 0 == player_handle) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_create() : %x", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_create() : %x", ret); return -2; } @@ -168,7 +176,7 @@ int ttsd_player_create_instance(const int uid) new_client->utt_id = -1; new_client->event = TTSP_RESULT_EVENT_FINISH; - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] Create player : uid(%d), handle(%d)", uid, player_handle ); + SLOG(LOG_DEBUG, get_tag(), "[Player] Create player : uid(%d), handle(%d)", uid, player_handle ); g_player_list = g_list_append(g_player_list, new_client); @@ -179,14 +187,14 @@ int ttsd_player_create_instance(const int uid) int ttsd_player_destroy_instance(int uid) { if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } player_s* current; current = __player_get_item(uid); if (NULL == current) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] uid(%d) is not valid", uid); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); return -1; } @@ -199,7 +207,7 @@ int ttsd_player_destroy_instance(int uid) MMPlayerStateType player_state; mm_player_get_state(current->player_handle, &player_state); - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] State changed : state(%d)", player_state); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER] State changed : state(%d)", player_state); int ret = -1; /* destroy player */ @@ -209,14 +217,14 @@ int ttsd_player_destroy_instance(int uid) case MM_PLAYER_STATE_READY: ret = mm_player_unrealize(current->player_handle); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_unrealize() : %x", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_unrealize() : %x", ret); } /* NO break for destroy */ case MM_PLAYER_STATE_NULL: ret = mm_player_destroy(current->player_handle); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_destroy() : %x", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_destroy() : %x", ret); } break; @@ -249,30 +257,30 @@ int ttsd_player_destroy_instance(int uid) } } - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER Success] Destroy instance"); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER Success] Destroy instance"); return 0; } int ttsd_player_play(const int uid) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] start play : uid(%d)", uid ); + SLOG(LOG_DEBUG, get_tag(), "[Player] start play : uid(%d)", uid ); if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } if (NULL != g_playing_info) { if (uid == g_playing_info->uid) { - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] uid(%d) has already played", g_playing_info->uid); + SLOG(LOG_WARN, get_tag(), "[Player WARNING] uid(%d) has already played", g_playing_info->uid); return 0; } } /* Check sound queue size */ if (0 == ttsd_data_get_sound_data_size(uid)) { - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] A sound queue of current player(%d) is empty", uid); + SLOG(LOG_WARN, get_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", uid); return -1; } @@ -280,33 +288,33 @@ int ttsd_player_play(const int uid) player_s* current; current = __player_get_item(uid); if (NULL == current) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] uid(%d) is not valid", uid); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); return -1; } MMPlayerStateType player_state; mm_player_get_state(current->player_handle, &player_state); - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] State changed : state(%d)", player_state); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER] State changed : state(%d)", player_state); switch (player_state) { case MM_PLAYER_STATE_PLAYING: - SLOG(LOG_WARN, TAG_TTSD, "[Player] Current player is playing. Do not start new sound."); + SLOG(LOG_WARN, get_tag(), "[Player] Current player is playing. Do not start new sound."); return 0; case MM_PLAYER_STATE_PAUSED: - SLOG(LOG_WARN, TAG_TTSD, "[Player] Player is paused. Do not start new sound."); + SLOG(LOG_WARN, get_tag(), "[Player] Player is paused. Do not start new sound."); return -1; case MM_PLAYER_STATE_READY: - SLOG(LOG_WARN, TAG_TTSD, "[Player] Player is ready for next play. Do not start new sound."); + SLOG(LOG_WARN, get_tag(), "[Player] Player is ready for next play. Do not start new sound."); return -1; case MM_PLAYER_STATE_NULL: break; case MM_PLAYER_STATE_NONE: - SLOG(LOG_WARN, TAG_TTSD, "[Player] Player is created. Do not start new sound."); + SLOG(LOG_WARN, get_tag(), "[Player] Player is created. Do not start new sound."); return -1; default: @@ -316,10 +324,10 @@ int ttsd_player_play(const int uid) int ret; ret = __set_and_start(current); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail to set or start mm_player"); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail to set or start mm_player"); } - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] Started play and wait for played callback : uid(%d)", uid); + SLOG(LOG_DEBUG, get_tag(), "[Player] Started play and wait for played callback : uid(%d)", uid); return 0; } @@ -327,7 +335,7 @@ int ttsd_player_play(const int uid) int ttsd_player_next_play(int uid) { if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } @@ -335,25 +343,25 @@ int ttsd_player_next_play(int uid) player_s* current; current = __player_get_item(uid); if (NULL == current) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] uid(%d) is not valid", uid); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); g_playing_info = NULL; return -1; } if (NULL != g_playing_info) { if (uid != g_playing_info->uid) { - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] Current player(%d) is NOT uid(%d)", g_playing_info->uid, uid); + SLOG(LOG_WARN, get_tag(), "[Player WARNING] Current player(%d) is NOT uid(%d)", g_playing_info->uid, uid); return 0; } } else { - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] Current player do NOT exist"); + SLOG(LOG_WARN, get_tag(), "[Player WARNING] Current player do NOT exist"); return -1; } MMPlayerStateType player_state; mm_player_get_state(current->player_handle, &player_state); - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] State changed : state(%d)", player_state); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER] State changed : state(%d)", player_state); int ret = -1; /* stop player */ @@ -363,7 +371,7 @@ int ttsd_player_next_play(int uid) case MM_PLAYER_STATE_READY: ret = mm_player_unrealize(current->player_handle); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_unrealize() : %x", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_unrealize() : %x", ret); return -1; } break; @@ -377,17 +385,17 @@ int ttsd_player_next_play(int uid) /* Check sound queue size */ if (0 == ttsd_data_get_sound_data_size(uid)) { - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] A sound queue of current player(%d) is empty", uid); + SLOG(LOG_WARN, get_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", uid); g_playing_info = NULL; return -1; } ret = __set_and_start(current); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail to set or start mm_player"); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail to set or start mm_player"); } - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] Started play and wait for played callback : uid(%d)", uid); + SLOG(LOG_DEBUG, get_tag(), "[Player] Started play and wait for played callback : uid(%d)", uid); return 0; } @@ -395,10 +403,10 @@ int ttsd_player_next_play(int uid) int ttsd_player_stop(const int uid) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] stop player : uid(%d)", uid ); + SLOG(LOG_DEBUG, get_tag(), "[Player] stop player : uid(%d)", uid ); if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } @@ -406,7 +414,7 @@ int ttsd_player_stop(const int uid) player_s* current; current = __player_get_item(uid); if (NULL == current) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] uid(%d) is not valid", uid); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); return -1; } @@ -417,7 +425,7 @@ int ttsd_player_stop(const int uid) g_playing_info = NULL; } } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] No current playing"); + SLOG(LOG_DEBUG, get_tag(), "[Player] No current playing"); } current->utt_id = -1; @@ -425,7 +433,7 @@ int ttsd_player_stop(const int uid) MMPlayerStateType player_state; mm_player_get_state(current->player_handle, &player_state); - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] Current state(%d)", player_state); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER] Current state(%d)", player_state); int ret = -1; switch (player_state) { @@ -434,7 +442,7 @@ int ttsd_player_stop(const int uid) case MM_PLAYER_STATE_READY: ret = mm_player_unrealize(current->player_handle); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_unrealize() : %x", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_unrealize() : %x", ret); return -1; } break; @@ -446,17 +454,17 @@ int ttsd_player_stop(const int uid) break; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Player SUCCESS] Stop player : uid(%d)", uid); + SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Stop player : uid(%d)", uid); return 0; } int ttsd_player_pause(const int uid) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] pause player : uid(%d)", uid ); + SLOG(LOG_DEBUG, get_tag(), "[Player] pause player : uid(%d)", uid ); if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } @@ -464,7 +472,7 @@ int ttsd_player_pause(const int uid) player_s* current; current = __player_get_item(uid); if (NULL == current) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid); return -1; } @@ -481,16 +489,16 @@ int ttsd_player_pause(const int uid) MMPlayerStateType player_state; mm_player_get_state(current->player_handle, &player_state); - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] Current state(%d)", player_state); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER] Current state(%d)", player_state); int ret = 0; if (MM_PLAYER_STATE_PLAYING == player_state) { ret = mm_player_pause(current->player_handle); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_pause : %x ", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_pause : %x ", ret); } } else { - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] Current player is NOT 'playing'"); + SLOG(LOG_WARN, get_tag(), "[Player WARNING] Current player is NOT 'playing'"); } @@ -499,10 +507,10 @@ int ttsd_player_pause(const int uid) int ttsd_player_resume(const int uid) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] Resume player : uid(%d)", uid ); + SLOG(LOG_DEBUG, get_tag(), "[Player] Resume player : uid(%d)", uid ); if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } @@ -510,7 +518,7 @@ int ttsd_player_resume(const int uid) player_s* current; current = __player_get_item(uid); if (NULL == current) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] uid(%d) is not valid", uid); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); return -1; } @@ -522,7 +530,7 @@ int ttsd_player_resume(const int uid) MMPlayerStateType player_state; mm_player_get_state(current->player_handle, &player_state); - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] Current state(%d)", player_state); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER] Current state(%d)", player_state); int ret = -1; if (MM_PLAYER_STATE_PAUSED == player_state) { @@ -536,21 +544,21 @@ int ttsd_player_resume(const int uid) /* Current state need load and play */ ret = ttsd_player_next_play(uid); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[player] Fail to next play in resume function"); + SLOG(LOG_ERROR, get_tag(), "[player] Fail to next play in resume function"); } } else { ret = mm_player_resume(current->player_handle); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_resume() : %d", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_resume() : %d", ret); return -1; } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] Resume player"); + SLOG(LOG_DEBUG, get_tag(), "[Player] Resume player"); } g_playing_info = current; } } else { - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] Current uid is NOT paused state."); + SLOG(LOG_WARN, get_tag(), "[Player WARNING] Current uid is NOT paused state."); } return 0; @@ -559,24 +567,24 @@ int ttsd_player_resume(const int uid) int ttsd_player_get_current_client() { if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } if (NULL != g_playing_info) return g_playing_info->uid; - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] No current player"); + SLOG(LOG_WARN, get_tag(), "[Player WARNING] No current player"); return 0; } int ttsd_player_get_current_utterance_id(const int uid) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Player] get current utt id : uid(%d)", uid ); + SLOG(LOG_DEBUG, get_tag(), "[Player] get current utt id : uid(%d)", uid ); if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } @@ -584,7 +592,7 @@ int ttsd_player_get_current_utterance_id(const int uid) player_s* current; current = __player_get_item(uid); if (NULL == current) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] uid(%d) is not valid", uid); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); return -1; } @@ -594,7 +602,7 @@ int ttsd_player_get_current_utterance_id(const int uid) int ttsd_player_all_stop() { if (false == g_player_init) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Not Initialized" ); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" ); return -1; } @@ -614,7 +622,7 @@ int ttsd_player_all_stop() app_state_e state; if (0 > ttsd_data_get_client_state(data->uid, &state)) { - SLOG(LOG_ERROR, TAG_TTSD, "[player ERROR] ttsd_player_all_stop : uid is not valid "); + SLOG(LOG_ERROR, get_tag(), "[player ERROR] ttsd_player_all_stop : uid is not valid "); ttsd_player_destroy_instance(data->uid); iter = g_list_next(iter); continue; @@ -624,7 +632,7 @@ int ttsd_player_all_stop() /* unrealize player */ ret = mm_player_unrealize(data->player_handle); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_unrealize() : %x", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_unrealize() : %x", ret); } data->utt_id = -1; @@ -636,34 +644,34 @@ int ttsd_player_all_stop() } } - SLOG(LOG_DEBUG, TAG_TTSD, "[Player SUCCESS] player all stop!! "); + SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] player all stop!! "); return 0; } static Eina_Bool __player_next_play(void *data) { - SLOG(LOG_DEBUG, TAG_TTSD, "===== PLAYER NEXT PLAY"); + SLOG(LOG_DEBUG, get_tag(), "===== PLAYER NEXT PLAY"); int* uid = (int*)data; if (NULL == uid) { - SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER ERROR] uid is NULL"); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] uid is NULL"); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); return EINA_FALSE; } - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] uid = %d", *uid); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER] uid = %d", *uid); if (0 != ttsd_player_next_play(*uid)) { - SLOG(LOG_WARN, TAG_TTSD, "[PLAYER WARNING] Fail to play next"); + SLOG(LOG_WARN, get_tag(), "[PLAYER WARNING] Fail to play next"); } free(uid); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); return EINA_FALSE; } @@ -675,7 +683,7 @@ static int msg_callback(int message, void *data, void *user_param) user_data = (user_data_s*)user_param; if (NULL == user_data) { - SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER ERROR] user_param is NULL"); + SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] user_param is NULL"); return -1; } @@ -687,8 +695,8 @@ static int msg_callback(int message, void *data, void *user_param) switch (message) { case MM_MESSAGE_ERROR: { - SLOG(LOG_DEBUG, TAG_TTSD, "===== PLAYER ERROR CALLBACK"); - SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER ERROR] Info : uid(%d), utt id(%d), error file(%s)", uid, utt_id, user_data->filename); + SLOG(LOG_DEBUG, get_tag(), "===== PLAYER ERROR CALLBACK"); + SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] Info : uid(%d), utt id(%d), error file(%s)", uid, utt_id, user_data->filename); /* send error info */ g_result_callback(PLAYER_ERROR, uid, utt_id); @@ -696,7 +704,7 @@ static int msg_callback(int message, void *data, void *user_param) player_s* current; current = __player_get_item(uid); if (NULL == current) { - SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER ERROR] uid(%d) is NOT valid ", uid); + SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] uid(%d) is NOT valid ", uid); } else { current->event = TTSP_RESULT_EVENT_FINISH; } @@ -708,12 +716,12 @@ static int msg_callback(int message, void *data, void *user_param) if (NULL != g_playing_info) { if (uid == g_playing_info->uid) { g_playing_info = NULL; - SLOG(LOG_WARN, TAG_TTSD, "[PLAYER] Current Player is NOT uid(%d)", uid); + SLOG(LOG_WARN, get_tag(), "[PLAYER] Current Player is NOT uid(%d)", uid); } } - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); } break; /*MM_MESSAGE_ERROR*/ @@ -723,25 +731,25 @@ static int msg_callback(int message, void *data, void *user_param) case MM_MESSAGE_END_OF_STREAM: { - SLOG(LOG_DEBUG, TAG_TTSD, "===== END OF STREAM CALLBACK"); + SLOG(LOG_DEBUG, get_tag(), "===== END OF STREAM CALLBACK"); if (-1 == remove(user_data->filename)) { - SLOG(LOG_WARN, TAG_TTSD, "[PLAYER WARNING] Fail to remove temp file", user_data->filename); + SLOG(LOG_WARN, get_tag(), "[PLAYER WARNING] Fail to remove temp file", user_data->filename); } /* Check uid */ player_s* current; current = __player_get_item(uid); if (NULL == current) { - SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER ERROR] uid(%d) is NOT valid", uid); + SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] uid(%d) is NOT valid", uid); if (NULL != g_playing_info) { if (uid == g_playing_info->uid) { g_playing_info = NULL; - SLOG(LOG_WARN, TAG_TTSD, "[PLAYER] Current Player is NOT uid(%d)", uid); + SLOG(LOG_WARN, get_tag(), "[PLAYER] Current Player is NOT uid(%d)", uid); } } - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); return -1; } @@ -752,9 +760,9 @@ static int msg_callback(int message, void *data, void *user_param) /* send utterence finish signal */ if (TTSP_RESULT_EVENT_FINISH == current->event) { if (0 == ttsdc_send_utt_finish_message(pid, uid, utt_id)) - SLOG(LOG_DEBUG, TAG_TTSD, "[Send SUCCESS] Send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id); + SLOG(LOG_DEBUG, get_tag(), "[Send SUCCESS] Send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id); else - SLOG(LOG_ERROR, TAG_TTSD, "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id); + SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id); } /* for sync problem */ @@ -769,13 +777,13 @@ static int msg_callback(int message, void *data, void *user_param) int* uid_data = (int*) g_malloc0(sizeof(int)); *uid_data = uid; - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] uid = %d", *uid_data); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER] uid = %d", *uid_data); ecore_timer_add(0, __player_next_play, (void*)uid_data); } - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); } break; /*MM_MESSAGE_END_OF_STREAM*/ @@ -785,7 +793,7 @@ static int msg_callback(int message, void *data, void *user_param) case MM_MESSAGE_STATE_INTERRUPTED: if (MM_PLAYER_STATE_PAUSED == msg->state.current) { - SLOG(LOG_DEBUG, TAG_TTSD, "===== INTERRUPTED CALLBACK"); + SLOG(LOG_DEBUG, get_tag(), "===== INTERRUPTED CALLBACK"); ttsd_data_set_client_state(uid, APP_STATE_PAUSED); @@ -793,8 +801,8 @@ static int msg_callback(int message, void *data, void *user_param) /* send message to client about changing state */ ttsdc_send_set_state_message (pid, uid, APP_STATE_PAUSED); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); } break; @@ -847,7 +855,7 @@ int __save_file(const int uid, const int index, const sound_data_s data, char** strcpy(postfix, "amr"); break; default: - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Audio type(%d) is NOT valid", data.audio_type); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Audio type(%d) is NOT valid", data.audio_type); return -1; } @@ -855,7 +863,7 @@ int __save_file(const int uid, const int index, const sound_data_s data, char** char* temp; temp = (char*)g_malloc0(sizeof(char) * FILE_PATH_SIZE); if (NULL == temp) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player Error] make buf is failed"); + SLOG(LOG_ERROR, get_tag(), "[Player Error] make buf is failed"); return -1; } @@ -871,7 +879,7 @@ int __save_file(const int uid, const int index, const sound_data_s data, char** fp = fopen(temp, "wb"); if (fp == NULL) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] temp file open error"); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] temp file open error"); if (NULL != temp) g_free(temp); return -1; @@ -887,7 +895,7 @@ int __save_file(const int uid, const int index, const sound_data_s data, char** } if (0 >= fwrite(&header, sizeof(WavHeader), 1, fp)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail to write wav header to file"); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail to write wav header to file"); fclose(fp); if (NULL != temp) g_free(temp); @@ -899,7 +907,7 @@ int __save_file(const int uid, const int index, const sound_data_s data, char** if (size <= 0) { size = fwrite("0000000000", DEFAULT_FILE_SIZE, 1, fp); if (size <= 0) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Fail to write date"); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to write date"); fclose(fp); if (NULL != temp) g_free(temp); @@ -910,9 +918,9 @@ int __save_file(const int uid, const int index, const sound_data_s data, char** fclose(fp); *filename = temp; - SLOG(LOG_DEBUG, TAG_TTSD, " "); - 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); + SLOG(LOG_DEBUG, get_tag(), " "); + SLOG(LOG_DEBUG, get_tag(), "Filepath : %s ", *filename); + SLOG(LOG_DEBUG, get_tag(), "Header : Data size(%d), Sample rate(%d), Channel(%d) ", data.data_size, data.rate, data.channels); return 0; } @@ -920,11 +928,11 @@ 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 || 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); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] __init_wave_header : input parameter invalid"); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] hdr : %p", hdr); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] nsample : %d", nsamples); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] sampling_rate : %", sampling_rate); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] channel : %", channel); return TTSD_ERROR_INVALID_PARAMETER; } @@ -957,7 +965,7 @@ int __set_and_start(player_s* player) /* get sound data */ sound_data_s wdata; if (0 != ttsd_data_get_sound_data(player->uid, &wdata)) { - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] A sound queue of current player(%d) is empty", player->uid); + SLOG(LOG_WARN, get_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", player->uid); return -1; } @@ -972,7 +980,7 @@ int __set_and_start(player_s* player) char* sound_file = NULL; ret = __save_file(player->uid, g_index, wdata, &sound_file); if (0 != ret || NULL == sound_file) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail to make sound file"); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail to make sound file"); return -1; } @@ -983,15 +991,15 @@ int __set_and_start(player_s* player) memset(user_data->filename, 0, TEMP_FILE_MAX); strncpy( user_data->filename, sound_file, strlen(sound_file) ); - SLOG(LOG_DEBUG, TAG_TTSD, "Info : uid(%d), utt(%d), filename(%s) , event(%d)", + SLOG(LOG_DEBUG, get_tag(), "Info : uid(%d), utt(%d), filename(%s) , event(%d)", user_data->uid, user_data->utt_id, user_data->filename, user_data->event); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), " "); /* set callback func */ ret = mm_player_set_message_callback(player->player_handle, msg_callback, (void*)user_data); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Fail mm_player_set_message_callback() : %x ", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail mm_player_set_message_callback() : %x ", ret); return -1; } @@ -999,7 +1007,7 @@ int __set_and_start(player_s* player) char* err_attr_name = NULL; if (0 != access(sound_file, R_OK)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Fail to read sound file (%s)", sound_file); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to read sound file (%s)", sound_file); return -1; } @@ -1011,26 +1019,28 @@ int __set_and_start(player_s* player) if (MM_ERROR_NONE != ret) { if (NULL != err_attr_name) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Fail mm_player_set_attribute() : msg(%s), result(%x) ", err_attr_name, ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail mm_player_set_attribute() : msg(%s), result(%x) ", err_attr_name, ret); } return -1; } - ret = mm_player_ignore_session(player->player_handle); - if (MM_ERROR_NONE != ret) { - SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] fail mm_player_ignore_session() : %x", ret); + if (TTSD_MODE_DEFAULT != ttsd_get_mode()) { + ret = mm_player_ignore_session(player->player_handle); + if (MM_ERROR_NONE != ret) { + SLOG(LOG_WARN, get_tag(), "[Player WARNING] fail mm_player_ignore_session() : %x", ret); + } } - + /* realize and start mm player */ ret = mm_player_realize(player->player_handle); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_realize() : %x", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_realize() : %x", ret); return -2; } ret = mm_player_start(player->player_handle); if (MM_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_start() : %x", ret); + SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_start() : %x", ret); mm_player_unrealize(player->player_handle); return -3; @@ -1048,10 +1058,10 @@ int __set_and_start(player_s* player) /* send utterance start message */ if (0 != ttsdc_send_utt_start_message(pid, player->uid, wdata.utt_id)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", pid, player->uid, wdata.utt_id); + SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", pid, player->uid, wdata.utt_id); } } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] Don't need to send Utterance Start Signal"); + SLOG(LOG_DEBUG, get_tag(), "[PLAYER] Don't need to send Utterance Start Signal"); } g_playing_info = player; diff --git a/server/ttsd_server.cpp b/server/ttsd_server.c similarity index 63% rename from server/ttsd_server.cpp rename to server/ttsd_server.c index f5045a8..6bb8512 100755 --- a/server/ttsd_server.cpp +++ b/server/ttsd_server.c @@ -45,7 +45,6 @@ int __server_next_synthesis(int uid); int __server_set_is_synthesizing(bool flag) { g_is_synthesizing = flag; - return 0; } @@ -57,7 +56,6 @@ bool __server_get_is_synthesizing() int __server_set_is_next_synthesis(bool flag) { g_is_next_synthesis = flag; - return 0; } @@ -84,31 +82,31 @@ int __server_start_synthesis(int uid, int mode) /* check if tts-engine is running */ if (true == __server_get_is_synthesizing()) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running "); + SLOG(LOG_DEBUG, get_tag(), "[Server] TTS-engine is running "); } else { speak_data_s sdata; if (0 == ttsd_data_get_speak_data(uid, &sdata)) { utterance_t* utt = (utterance_t*)g_malloc0(sizeof(utterance_t)); if (NULL == utt) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Out of memory : utterance "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Out of memory : utterance "); return TTSD_ERROR_OUT_OF_MEMORY; } utt->uid = uid; utt->uttid = sdata.utt_id; - SLOG(LOG_DEBUG, TAG_TTSD, "-----------------------------------------------------------"); - SLOG(LOG_DEBUG, TAG_TTSD, "ID : uid (%d), uttid(%d) ", utt->uid, utt->uttid ); - SLOG(LOG_DEBUG, TAG_TTSD, "Voice : langauge(%s), type(%d), speed(%d)", sdata.lang, sdata.vctype, sdata.speed); - SLOG(LOG_DEBUG, TAG_TTSD, "Text : %s", sdata.text); - SLOG(LOG_DEBUG, TAG_TTSD, "-----------------------------------------------------------"); + SLOG(LOG_DEBUG, get_tag(), "-----------------------------------------------------------"); + SLOG(LOG_DEBUG, get_tag(), "ID : uid (%d), uttid(%d) ", utt->uid, utt->uttid ); + SLOG(LOG_DEBUG, get_tag(), "Voice : langauge(%s), type(%d), speed(%d)", sdata.lang, sdata.vctype, sdata.speed); + SLOG(LOG_DEBUG, get_tag(), "Text : %s", sdata.text); + SLOG(LOG_DEBUG, get_tag(), "-----------------------------------------------------------"); __server_set_is_synthesizing(true); int ret = 0; ret = ttsd_engine_start_synthesis(sdata.lang, sdata.vctype, sdata.text, sdata.speed, (void*)utt); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] * FAIL to start SYNTHESIS !!!! * "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR][%s] * FAIL to start SYNTHESIS !!!! * ", __FUNCTION__); __server_set_is_synthesizing(false); @@ -116,22 +114,25 @@ int __server_start_synthesis(int uid, int mode) g_free(utt); + /* mode 2 : Add text in playing state */ if (2 == mode) { __server_send_error(uid, sdata.utt_id, TTSD_ERROR_OPERATION_FAILED); + //ttsd_config_save_error(); + ttsd_server_stop(uid); int pid = ttsd_data_get_pid(uid); ttsdc_send_set_state_message(pid, uid, APP_STATE_READY); } } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] SUCCESS to start synthesis"); + SLOG(LOG_DEBUG, get_tag(), "[Server] SUCCESS to start synthesis"); } if(sdata.text != NULL) g_free(sdata.text); } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Text List is EMPTY!! "); + SLOG(LOG_DEBUG, get_tag(), "[Server] Text List is EMPTY!! "); } } @@ -147,19 +148,18 @@ int __server_play_internal(int uid, app_state_e state) int ret = 0; if (APP_STATE_PAUSED == state) { - - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] uid(%d) is 'Pause' state : Next step is resume player and start synthesis ", uid); + SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) is 'Pause' state : Next step is resume player and start synthesis ", uid); /* resume player and start speech synthesis */ if (0 != ttsd_player_resume(uid)) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] fail to ttsd_player_resume()"); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] fail to ttsd_player_resume()"); } /* mode 1 for play */ ret = __server_start_synthesis(uid, 1); } else if(APP_STATE_READY == state) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] uid(%d) is 'Ready' state : Next step is start synthesis ", uid); + SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) is 'Ready' state : Next step is start synthesis ", uid); /* mode 1 for play */ ret = __server_start_synthesis(uid, 1); @@ -172,22 +172,22 @@ int __server_play_internal(int uid, app_state_e state) int __server_next_synthesis(int uid) { - SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT SYNTHESIS & PLAY START"); + SLOG(LOG_DEBUG, get_tag(), "===== NEXT SYNTHESIS & PLAY START"); /* get current playing client */ int current_uid = ttsd_data_get_current_playing(); if (0 > current_uid) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current uid is not valid"); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current uid is not valid"); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } 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, " "); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] Engine has already been running. "); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -198,27 +198,25 @@ int __server_next_synthesis(int uid) utterance_t* utt = (utterance_t*)g_malloc0(sizeof(utterance_t)); if (NULL == utt) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to allocate memory : utterance "); - - __server_send_error(current_uid, sdata.utt_id, TTSD_ERROR_OUT_OF_MEMORY); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR][%s] fail to allocate memory : utterance ", __FUNCTION__); return TTSD_ERROR_OUT_OF_MEMORY; } utt->uid = current_uid; utt->uttid = sdata.utt_id; - SLOG(LOG_DEBUG, TAG_TTSD, "-----------------------------------------------------------"); - SLOG(LOG_DEBUG, TAG_TTSD, "ID : uid (%d), uttid(%d) ", utt->uid, utt->uttid ); - SLOG(LOG_DEBUG, TAG_TTSD, "Voice : langauge(%s), type(%d), speed(%d)", sdata.lang, sdata.vctype, sdata.speed); - SLOG(LOG_DEBUG, TAG_TTSD, "Text : %s", sdata.text); - SLOG(LOG_DEBUG, TAG_TTSD, "-----------------------------------------------------------"); + SLOG(LOG_DEBUG, get_tag(), "-----------------------------------------------------------"); + SLOG(LOG_DEBUG, get_tag(), "ID : uid (%d), uttid(%d) ", utt->uid, utt->uttid ); + SLOG(LOG_DEBUG, get_tag(), "Voice : langauge(%s), type(%d), speed(%d)", sdata.lang, sdata.vctype, sdata.speed); + SLOG(LOG_DEBUG, get_tag(), "Text : %s", sdata.text); + SLOG(LOG_DEBUG, get_tag(), "-----------------------------------------------------------"); __server_set_is_synthesizing(true); int ret = 0; ret = ttsd_engine_start_synthesis(sdata.lang, sdata.vctype, sdata.text, sdata.speed, (void*)utt); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] * FAIL to start SYNTHESIS !!!! * "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR][%s] * FAIL to start SYNTHESIS !!!! * ", __FUNCTION__); __server_set_is_synthesizing(false); @@ -235,20 +233,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] --------------------"); + SLOG(LOG_DEBUG, get_tag(), "[Server] --------------------"); + SLOG(LOG_DEBUG, get_tag(), "[Server] Text queue is empty."); + SLOG(LOG_DEBUG, get_tag(), "[Server] --------------------"); } if (0 != ttsd_player_play(current_uid)) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] __server_next_synthesis : fail ttsd_player_play() "); + SLOG(LOG_WARN, get_tag(), "[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, get_tag(), "[Server] Success to start player"); } - SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT SYNTHESIS & PLAY END"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "===== NEXT SYNTHESIS & PLAY END"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } @@ -260,21 +258,20 @@ int __server_next_synthesis(int uid) int __player_result_callback(player_event_e event, int uid, int utt_id) { switch(event) { + case PLAYER_ERROR: + SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR][%s] player result error", __FUNCTION__); + __server_send_error(uid, utt_id, TTSD_ERROR_OPERATION_FAILED); + // break; + case PLAYER_EMPTY_SOUND_QUEUE: /* check whether synthesis is running */ 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 "); + SLOG(LOG_DEBUG, get_tag(), "[SERVER Callback] all play completed "); } } break; - - case PLAYER_ERROR: - SLOG(LOG_ERROR, TAG_TTSD, "[SERVER Callback ERROR] callback : player error "); - - __server_send_error(uid, utt_id, TTSD_ERROR_OPERATION_FAILED); - break; case PLAYER_END_OF_PLAYING: break; @@ -302,15 +299,15 @@ Eina_Bool __start_next_synthesis(void *data) int __synthesis_result_callback(ttsp_result_event_e event, const void* data, unsigned int data_size, void *user_data) { - SLOG(LOG_DEBUG, TAG_TTSD, "===== SYNTHESIS RESULT CALLBACK START"); + SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS RESULT CALLBACK START"); utterance_t* utt_get_param; utt_get_param = (utterance_t*)user_data; if (NULL == utt_get_param) { - SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] User data is NULL " ); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] User data is NULL " ); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); return -1; } @@ -320,19 +317,19 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns /* Synthesis is success */ if (TTSP_RESULT_EVENT_START == event || TTSP_RESULT_EVENT_CONTINUE == event || TTSP_RESULT_EVENT_FINISH == event) { - if (TTSP_RESULT_EVENT_START == event) SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_START"); - if (TTSP_RESULT_EVENT_CONTINUE == event) SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_CONTINUE"); - if (TTSP_RESULT_EVENT_FINISH == event) SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_FINISH"); + if (TTSP_RESULT_EVENT_START == event) SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_START"); + if (TTSP_RESULT_EVENT_CONTINUE == event) SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_CONTINUE"); + if (TTSP_RESULT_EVENT_FINISH == event) SLOG(LOG_DEBUG, get_tag(), "[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 !!!! - uid(%d), uttid(%d)", uid, uttid); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] uttid is NOT valid !!!! - uid(%d), uttid(%d)", uid, uttid); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } - SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) ", + SLOG(LOG_DEBUG, get_tag(), "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) ", uid, uttid, data, data_size); /* add wav data */ @@ -349,9 +346,9 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns int channels; if (ttsd_engine_get_audio_format(&audio_type, &rate, &channels)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to get audio format "); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to get audio format "); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); return -1; } @@ -360,7 +357,7 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns temp_data.channels = channels; if (0 != ttsd_data_add_sound_data(uid, temp_data)) { - SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] Fail to add sound data : uid(%d)", utt_get_param->uid); + SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] Fail to add sound data : uid(%d)", utt_get_param->uid); } if (event == TTSP_RESULT_EVENT_FINISH) { @@ -370,13 +367,13 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns } else if (event == TTSP_RESULT_EVENT_CANCEL) { - SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_CANCEL"); + SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_CANCEL"); __server_set_is_synthesizing(false); __server_set_is_next_synthesis(true); } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event ERROR"); + SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event ERROR"); __server_set_is_synthesizing(false); __server_set_is_next_synthesis(true); } @@ -386,46 +383,101 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns free(utt_get_param); } - SLOG(LOG_DEBUG, TAG_TTSD, "===== SYNTHESIS RESULT CALLBACK END"); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS RESULT CALLBACK END"); + SLOG(LOG_DEBUG, get_tag(), " "); return 0; } +bool __get_client_cb(int pid, int uid, app_state_e state, void* user_data) +{ + /* clear client data */ + ttsd_data_clear_data(uid); + ttsd_data_set_client_state(uid, APP_STATE_READY); + + /* send message */ + if ( 0 != ttsdc_send_set_state_message(pid, uid, APP_STATE_READY)) { + /* remove client */ + ttsd_data_delete_client(uid); + } + + return true; +} + + +void __config_lang_changed_cb(const char* language, int type) +{ + char* out_lang; + ttsp_voice_type_e out_type; + int ret = -1; + + if (true == ttsd_engine_select_valid_voice(language, type, &out_lang, &out_type)) { + SLOG(LOG_ERROR, get_tag(), "[Server] vaild language : lang(%s), type(%d)", out_lang, out_type); + ret = ttsd_engine_setting_set_default_voice(out_lang, out_type); + if (0 != ret) + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set vaild language : lang(%s), type(%d)", out_lang, out_type); + + if (NULL == out_lang) + free(out_lang); + } else { + /* Current language is not available */ + if (true == ttsd_engine_select_valid_voice("en_US", type, &out_lang, &out_type)) { + ret = ttsd_engine_setting_set_default_voice(out_lang, out_type); + if (0 != ret) + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set vaild language : lang(%s), type(%d)", out_lang, out_type); + + if (NULL == out_lang) + free(out_lang); + } + } + + return; +} + + /* * Daemon init */ int ttsd_initialize() { - if (ttsd_config_initialize()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server WARNING] Fail to initialize config."); + if (ttsd_config_initialize(__config_lang_changed_cb)) { + SLOG(LOG_ERROR, get_tag(), "[Server WARNING] Fail to initialize config."); } /* player init */ if (ttsd_player_init(__player_result_callback)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to initialize player init."); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to initialize player init."); return TTSD_ERROR_OPERATION_FAILED; } /* Engine Agent initialize */ if (0 != ttsd_engine_agent_init(__synthesis_result_callback)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to engine agent initialize."); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to engine agent initialize."); return TTSD_ERROR_OPERATION_FAILED; } /* set current engine */ if (0 != ttsd_engine_agent_initialize_current_engine()) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!!" ); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] No Engine !!!" ); g_is_engine = false; } else g_is_engine = true; + + return TTSD_ERROR_NONE; +} +int ttsd_finalize() +{ + ttsd_config_finalize(); + + ttsd_player_release(); + + ttsd_engine_agent_release(); return TTSD_ERROR_NONE; } - bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_data) { int result = 1; @@ -433,10 +485,10 @@ bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_d result = ttsdc_send_hello(pid, uid); if (0 == result) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] uid(%d) should be removed.", uid); + SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) should be removed.", uid); ttsd_server_finalize(uid); } else if (-1 == result) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Hello result has error"); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Hello result has error"); } return true; @@ -445,10 +497,10 @@ bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_d Eina_Bool ttsd_cleanup_client(void *data) { - SLOG(LOG_DEBUG, TAG_TTSD, "===== CLEAN UP CLIENT START"); + SLOG(LOG_DEBUG, get_tag(), "===== CLEAN UP CLIENT START"); ttsd_data_foreach_clients(__get_client_for_clean_up, NULL); - SLOG(LOG_DEBUG, TAG_TTSD, "====="); - SLOG(LOG_DEBUG, TAG_TTSD, " "); + SLOG(LOG_DEBUG, get_tag(), "====="); + SLOG(LOG_DEBUG, get_tag(), " "); return EINA_TRUE; } @@ -461,7 +513,7 @@ int ttsd_server_initialize(int pid, int uid) { if (false == g_is_engine) { if (0 != ttsd_engine_agent_initialize_current_engine()) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!! " ); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] No Engine !!! " ); g_is_engine = false; return TTSD_ERROR_ENGINE_NOT_FOUND; @@ -471,24 +523,27 @@ int ttsd_server_initialize(int pid, int uid) } if (-1 != ttsd_data_is_client(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Uid has already been registered "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Uid has already been registered "); return TTSD_ERROR_INVALID_PARAMETER; } if (0 == ttsd_data_get_client_count()) { if (0 != ttsd_engine_agent_load_current_engine()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to load current engine "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to load current engine "); return TTSD_ERROR_OPERATION_FAILED; } + + /* Check system language */ + ttsd_config_update_language(); } if (0 != ttsd_data_new_client(pid, uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to add client info "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to add client info "); return TTSD_ERROR_OPERATION_FAILED; } if (0 != ttsd_player_create_instance(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to create player "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to create player "); return TTSD_ERROR_OPERATION_FAILED; } @@ -498,7 +553,7 @@ int ttsd_server_initialize(int pid, int uid) static Eina_Bool __quit_ecore_loop(void *data) { ecore_main_loop_quit(); - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] quit ecore main loop"); + SLOG(LOG_DEBUG, get_tag(), "[Server] quit ecore main loop"); return EINA_FALSE; } @@ -506,7 +561,7 @@ int ttsd_server_finalize(int uid) { app_state_e state; if (0 > ttsd_data_get_client_state(uid, &state)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_finalize : uid is not valid "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_finalize : uid is not valid "); return TTSD_ERROR_INVALID_PARAMETER; } @@ -518,12 +573,6 @@ int ttsd_server_finalize(int uid) /* unload engine, if ref count of client is 0 */ if (0 == ttsd_data_get_client_count()) { - if (0 != ttsd_engine_agent_release()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to release engine agent"); - } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] release engine agent"); - } - ecore_timer_add(0, __quit_ecore_loop, NULL); } @@ -534,7 +583,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice { app_state_e state; if (0 > ttsd_data_get_client_state(uid, &state)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : uid is not valid "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_add_queue : uid is not valid "); return TTSD_ERROR_INVALID_PARAMETER; } @@ -542,7 +591,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice char* temp_lang = NULL; ttsp_voice_type_e temp_type; if (true != ttsd_engine_select_valid_voice((const char*)lang, (const ttsp_voice_type_e)voice_type, &temp_lang, &temp_type)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to select valid voice "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to select valid voice "); return TTSD_ERROR_INVALID_VOICE; } else { if (NULL == temp_lang) @@ -561,7 +610,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice /* if state is APP_STATE_READY , APP_STATE_PAUSED , only need to add speak data to queue*/ if (0 != ttsd_data_add_speak_data(uid, data)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : Current state of uid is not 'ready' "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_add_queue : Current state of uid is not 'ready' "); return TTSD_ERROR_OPERATION_FAILED; } @@ -569,14 +618,14 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice /* check if engine use network */ if (ttsd_engine_agent_need_network()) { if (false == ttsd_network_is_connected()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network."); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Disconnect network. Current engine needs network."); return TTSD_ERROR_OPERATION_FAILED; } } /* mode 2 for add text */ if (0 != __server_start_synthesis(uid, 2)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to schedule synthesis : uid(%d)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] fail to schedule synthesis : uid(%d)", uid); return TTSD_ERROR_OPERATION_FAILED; } } @@ -601,19 +650,19 @@ int ttsd_server_play(int uid) { app_state_e state; if (0 > ttsd_data_get_client_state(uid, &state)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid(%d) is NOT valid ", uid); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid(%d) is NOT valid ", uid); return TTSD_ERROR_INVALID_PARAMETER; } if (APP_STATE_PLAYING == state) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state(%d) is 'play' ", uid); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state(%d) is 'play' ", uid); return TTSD_ERROR_NONE; } /* check if engine use network */ if (ttsd_engine_agent_need_network()) { if (false == ttsd_network_is_connected()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network service!!!."); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Disconnect network. Current engine needs network service!!!."); return TTSD_ERROR_OUT_OF_NETWORK; } } @@ -622,11 +671,11 @@ int ttsd_server_play(int uid) if (uid != current_uid && -1 != current_uid) { /* Send interrupt message */ - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Old uid(%d) will be interrupted into 'Pause' state ", current_uid); + SLOG(LOG_DEBUG, get_tag(), "[Server] Old uid(%d) will be interrupted into 'Pause' state ", current_uid); /* pause player */ if (0 != ttsd_player_pause(current_uid)) { - SLOG(LOG_WARN, TAG_TTSD, "[Server ERROR] fail to ttsd_player_pause() : uid (%d)", current_uid); + SLOG(LOG_WARN, get_tag(), "[Server ERROR] fail to ttsd_player_pause() : uid (%d)", current_uid); } /* change state */ @@ -639,12 +688,12 @@ int ttsd_server_play(int uid) /* Change current play */ if (0 != ttsd_data_set_client_state(uid, APP_STATE_PLAYING)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to set state : uid(%d)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set state : uid(%d)", uid); return TTSD_ERROR_OPERATION_FAILED; } if (0 != __server_play_internal(uid, state)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to start synthesis : uid(%d)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to start synthesis : uid(%d)", uid); return TTSD_ERROR_OPERATION_FAILED; } @@ -658,7 +707,7 @@ int ttsd_server_stop(int uid) { app_state_e state; if (0 > ttsd_data_get_client_state(uid, &state)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid is not valid "); return TTSD_ERROR_INVALID_PARAMETER; } @@ -669,20 +718,20 @@ int ttsd_server_stop(int uid) ttsd_data_set_client_state(uid, APP_STATE_READY); if (0 != ttsd_player_stop(uid)) - SLOG(LOG_WARN, TAG_TTSD, "[Server] Fail to ttsd_player_stop()"); + SLOG(LOG_WARN, get_tag(), "[Server] Fail to ttsd_player_stop()"); if (true == __server_get_is_synthesizing()) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running "); + SLOG(LOG_DEBUG, get_tag(), "[Server] TTS-engine is running "); int ret = 0; ret = ttsd_engine_cancel_synthesis(); if (0 != ret) - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to cancel synthesis : ret(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to cancel synthesis : ret(%d)", ret); __server_set_is_synthesizing(false); } } else { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is 'ready' "); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state is 'ready' "); } return TTSD_ERROR_NONE; @@ -692,19 +741,19 @@ int ttsd_server_pause(int uid, int* utt_id) { app_state_e state; if (0 > ttsd_data_get_client_state(uid, &state)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_pause : uid is not valid "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_pause : uid is not valid "); return TTSD_ERROR_INVALID_PARAMETER; } if (APP_STATE_PLAYING != state) { - SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is not 'play' "); + SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state is not 'play' "); return TTSD_ERROR_INVALID_STATE; } int ret = 0; ret = ttsd_player_pause(uid); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail player_pause() : ret(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] fail player_pause() : ret(%d)", ret); return TTSD_ERROR_OPERATION_FAILED; } @@ -717,17 +766,17 @@ int ttsd_server_get_support_voices(int uid, GList** voice_list) { app_state_e state; if (0 > ttsd_data_get_client_state(uid, &state)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid is not valid "); return TTSD_ERROR_INVALID_PARAMETER; } /* get voice list*/ if (0 != ttsd_engine_get_voice_list(voice_list)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail ttsd_server_get_support_voices() "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail ttsd_server_get_support_voices() "); return TTSD_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] Get supported voices "); + SLOG(LOG_DEBUG, get_tag(), "[Server SUCCESS] Get supported voices "); return TTSD_ERROR_NONE; } @@ -736,18 +785,18 @@ int ttsd_server_get_current_voice(int uid, char** language, int* voice_type) { app_state_e state; if (0 > ttsd_data_get_client_state(uid, &state)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_get_current_voice : uid is not valid "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_get_current_voice : uid is not valid "); return TTSD_ERROR_INVALID_PARAMETER; } /* get current voice */ int ret = ttsd_engine_get_default_voice(language, (ttsp_voice_type_e*)voice_type); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail ttsd_server_get_support_voices() "); + SLOG(LOG_ERROR, get_tag(), "[Server ERROR] fail ttsd_server_get_support_voices() "); return ret; } - SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type); + SLOG(LOG_DEBUG, get_tag(), "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type); return TTSD_ERROR_NONE; } @@ -761,7 +810,7 @@ int ttsd_server_setting_initialize(int uid) { if (false == g_is_engine) { if (0 != ttsd_engine_agent_initialize_current_engine()) { - SLOG(LOG_WARN, TAG_TTSD, "[Server Setting WARNING] No Engine !!! " ); + SLOG(LOG_WARN, get_tag(), "[Server Setting WARNING] No Engine !!! " ); g_is_engine = false; return TTSD_ERROR_ENGINE_NOT_FOUND; } else { @@ -770,20 +819,20 @@ int ttsd_server_setting_initialize(int uid) } if (-1 != ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] pid has already been registered "); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] pid has already been registered "); return TTSD_ERROR_INVALID_PARAMETER; } if (0 == ttsd_data_get_client_count()) { if( 0 != ttsd_engine_agent_load_current_engine() ) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to load current engine "); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to load current engine "); return TTSD_ERROR_OPERATION_FAILED; } } /* register pid */ if (0 != ttsd_setting_data_add(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to add client info "); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to add client info "); return TTSD_ERROR_OPERATION_FAILED; } @@ -793,20 +842,14 @@ int ttsd_server_setting_initialize(int uid) int ttsd_server_setting_finalize(int uid) { if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } ttsd_setting_data_delete(uid); /* unload engine, if ref count of client is 0 */ - if (0 == ttsd_data_get_client_count()) - { - if (0 != ttsd_engine_agent_release()) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to release engine agent"); - } else { - SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting SUCCESS] Release engine agent"); - } + if (0 == ttsd_data_get_client_count()) { ecore_timer_add(0, __quit_ecore_loop, NULL); } @@ -816,14 +859,14 @@ int ttsd_server_setting_finalize(int uid) int ttsd_server_setting_get_engine_list(int uid, GList** engine_list) { if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } int ret = 0; ret = ttsd_engine_setting_get_engine_list(engine_list); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine list : result(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to get engine list : result(%d)", ret); return ret; } @@ -833,46 +876,30 @@ int ttsd_server_setting_get_engine_list(int uid, GList** engine_list) int ttsd_server_setting_get_current_engine(int uid, char** engine_id) { if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } int ret = 0; ret = ttsd_engine_setting_get_engine(engine_id); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get current engine : result(%d) ", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to get current engine : result(%d) ", ret); return ret; } - return TTSD_ERROR_NONE; } -bool __get_client_cb(int pid, int uid, app_state_e state, void* user_data) -{ - /* clear client data */ - ttsd_data_clear_data(uid); - ttsd_data_set_client_state(uid, APP_STATE_READY); - - /* send message */ - if ( 0 != ttsdc_send_set_state_message(pid, uid, APP_STATE_READY)) { - /* remove client */ - ttsd_data_delete_client(uid); - } - - return true; -} - int ttsd_server_setting_set_current_engine(int uid, const char* engine_id) { /* check if uid is valid */ if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } if (true == ttsd_engine_agent_is_same_engine(engine_id)) { - SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting] new engine is the same as current engine "); + SLOG(LOG_DEBUG, get_tag(), "[Server Setting] new engine is the same as current engine "); return TTSD_ERROR_NONE; } @@ -886,7 +913,7 @@ int ttsd_server_setting_set_current_engine(int uid, const char* engine_id) int ret = 0; ret = ttsd_engine_setting_set_engine(engine_id); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set current engine : result(%d) ", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to set current engine : result(%d) ", ret); return ret; } @@ -897,7 +924,7 @@ int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_ { /* check if uid is valid */ if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -905,7 +932,7 @@ int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_ int ret = 0; ret = ttsd_engine_setting_get_voice_list(engine_id, voice_list); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get voice list : result(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to get voice list : result(%d)", ret); return ret; } @@ -916,14 +943,14 @@ int ttsd_server_setting_get_default_voice(int uid, char** language, ttsp_voice_t { /* check if uid is valid */ if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } int ret = 0; ret = ttsd_engine_setting_get_default_voice(language, vctype); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get default voice : result(%d) ", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to get default voice : result(%d) ", ret); return ret; } @@ -934,7 +961,7 @@ int ttsd_server_setting_set_default_voice(int uid, const char* language, int vct { /* check if uid is valid */ if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -942,7 +969,7 @@ int ttsd_server_setting_set_default_voice(int uid, const char* language, int vct int ret = 0; ret = ttsd_engine_setting_set_default_voice((const char*)language, (const ttsp_voice_type_e)vctype); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default voice : result(%d) ", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to set default voice : result(%d) ", ret); return ret; } @@ -953,14 +980,14 @@ int ttsd_server_setting_get_engine_setting(int uid, char** engine_id, GList** en { /* check if uid is valid */ if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } int ret = 0; ret = ttsd_engine_setting_get_engine_setting_info(engine_id, engine_setting_list); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine setting info : result(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to get engine setting info : result(%d)", ret); return ret; } @@ -971,14 +998,14 @@ int ttsd_server_setting_set_engine_setting(int uid, const char* key, const char* { /* check if uid is valid */ if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } int ret = 0; ret = ttsd_engine_setting_set_engine_setting(key, value); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set engine setting info : result(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to set engine setting info : result(%d)", ret); return ret; } @@ -989,7 +1016,7 @@ int ttsd_server_setting_get_default_speed(int uid, int* default_speed) { /* check if uid is valid */ if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -997,7 +1024,7 @@ int ttsd_server_setting_get_default_speed(int uid, int* default_speed) int ret = 0; ret = ttsd_engine_setting_get_default_speed((ttsp_speed_e*)default_speed); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get default speed : result(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to get default speed : result(%d)", ret); return ret; } @@ -1008,7 +1035,7 @@ int ttsd_server_setting_set_default_speed(int uid, int default_speed) { /* check if uid is valid */ if (-1 == ttsd_setting_data_is_setting(uid)) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid (%s)", uid); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid (%s)", uid); return TTSD_ERROR_INVALID_PARAMETER; } @@ -1016,7 +1043,7 @@ int ttsd_server_setting_set_default_speed(int uid, int default_speed) int ret = 0; ret = ttsd_engine_setting_set_default_speed((ttsp_speed_e)default_speed); if (0 != ret) { - SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default speed : result(%d)", ret); + SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to set default speed : result(%d)", ret); return ret; } diff --git a/server/ttsd_server.h b/server/ttsd_server.h index 2013b38..76a9d95 100755 --- a/server/ttsd_server.h +++ b/server/ttsd_server.h @@ -29,6 +29,8 @@ extern "C" { /** Daemon initialize */ int ttsd_initialize(); +int ttsd_finalize(); + Eina_Bool ttsd_cleanup_client(void *data); /* diff --git a/tts-server.manifest b/tts-server.manifest old mode 100644 new mode 100755 diff --git a/tts-server.rule b/tts-server.rule index 4c4c0de..de5d655 100755 --- a/tts-server.rule +++ b/tts-server.rule @@ -9,3 +9,4 @@ tts-server mdm-server w tts-server system::use_internet rw system::use_internet tts-server w tts-server stt-server rwx +tts-server sys-assert::core rwx