Change to TTS engine process 40/79740/6 accepted/tizen/common/20160719.173227 accepted/tizen/mobile/20160719.232303 accepted/tizen/wearable/20160719.232419 submit/tizen_common/20160719.085816 submit/tizen_mobile/20160719.085900 submit/tizen_wearable/20160719.085917
authorsooyeon.kim <sooyeon.kim@samsung.com>
Tue, 12 Jul 2016 13:31:21 +0000 (22:31 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Fri, 15 Jul 2016 14:28:58 +0000 (23:28 +0900)
Change-Id: I6815ce0bef8f06549207f16d046baff387b8aff6
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
32 files changed:
CMakeLists.txt
client/tts.c
client/tts_client.c
common/tts_config_mgr.c
common/tts_defs.h
doc/uix_tts_engine_main_doc.h [new file with mode: 0755]
include/CMakeLists.txt
include/tts-engine.pc.in
include/tts.h
include/ttse.h [new file with mode: 0755]
org.tizen.voice.ttsnotiserver.service
org.tizen.voice.ttsserver.service
org.tizen.voice.ttssrserver.service
packaging/tts.spec
server/CMakeLists.txt
server/ttsd_config.c
server/ttsd_data.cpp
server/ttsd_data.h
server/ttsd_dbus.c
server/ttsd_dbus_server.c
server/ttsd_engine_agent.c
server/ttsd_engine_agent.h
server/ttsd_main.c
server/ttsd_main.h
server/ttsd_main_noti.c [deleted file]
server/ttsd_main_sr.c [deleted file]
server/ttsd_network.c
server/ttsd_player.c
server/ttsd_server.c
server/ttsd_server.h
server/ttse.c [new file with mode: 0755]
server/ttsp.h [deleted file]

index b5eeead..e9bcd46 100644 (file)
@@ -36,7 +36,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common")
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED  
        aul capi-media-audio-io capi-system-info dbus-1 dlog ecore 
-       glib-2.0 libtzplatform-config libxml-2.0 vconf
+       glib-2.0 libtzplatform-config libxml-2.0 vconf bundle
 )
 
 pkg_check_modules(pkgs_test REQUIRED
index 3917840..4065997 100644 (file)
@@ -426,6 +426,10 @@ int tts_set_credential(tts_h tts, const char* credential)
                return TTS_ERROR_INVALID_STATE;
        }
 
+       if (NULL != client->credential) {
+               free(client->credential);
+               client->credential = NULL;
+       }
        client->credential = strdup(credential);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
@@ -833,6 +837,8 @@ int tts_get_error_message(tts_h tts, char** err_msg)
 
 int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id)
 {
+       SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] Add text: text(%s), language(%s), type(%d)", (NULL == text) ? "NULL" : text, (NULL == language) ? "NULL" : language, voice_type);
+
        if (0 != __tts_get_feature_enabled()) {
                return TTS_ERROR_NOT_SUPPORTED;
        }
index 0a76de5..55afe0d 100644 (file)
@@ -77,8 +77,15 @@ int tts_client_new(tts_h* tts)
 
        client->cb_ref_count = 0;
 
+       client->utt_id = 0;
+       client->reason = 0;
+       client->err_msg = NULL;
+
        client->conn_timer = NULL;
 
+       client->credential = NULL;
+       client->credential_needed = false;
+
        g_client_list = g_list_append(g_client_list, client);
 
        *tts = temp;
@@ -93,7 +100,7 @@ int tts_client_destroy(tts_h tts)
        if (tts == NULL) {
                SLOG(LOG_ERROR, TAG_TTSC, "Input parameter is NULL");
                return TTS_ERROR_INVALID_PARAMETER;
-       }       
+       }
 
        GList *iter = NULL;
        tts_client_s *data = NULL;
@@ -111,9 +118,23 @@ int tts_client_destroy(tts_h tts)
                                while (0 != data->cb_ref_count) {
                                        /* wait for release callback function */
                                }
+
+                               if (NULL != data->err_msg) {
+                                       free(data->err_msg);
+                                       data->err_msg = NULL;
+                               }
+
+                               if (NULL != data->credential) {
+                                       free(data->credential);
+                                       data->credential = NULL;
+                               }
+
                                free(data);
                                free(tts);
 
+                               data = NULL;
+                               tts = NULL;
+
                                SLOG(LOG_DEBUG, TAG_TTSC, "Client destroy");
                                g_list_free(iter);
 
index e7c6b55..6b78bfe 100644 (file)
@@ -41,7 +41,7 @@ static GSList* g_engine_list = NULL;
 
 static GSList* g_config_client_list = NULL;
 
-static tts_config_s* g_config_info;
+static tts_config_s* g_config_info = NULL;
 
 static Ecore_Fd_Handler* g_config_fd_handler_noti = NULL;
 static int g_config_fd_noti;
@@ -760,7 +760,7 @@ int __tts_config_mgr_get_engine_info()
        /* Copy default info directory to download directory */
        dp  = opendir(TTS_DEFAULT_ENGINE_INFO);
        if (NULL == dp) {
-               SLOG(LOG_DEBUG, tts_tag(), "[CONFIG] No downloadable directory : %s", TTS_DEFAULT_ENGINE_INFO);
+               SLOG(LOG_DEBUG, tts_tag(), "[CONFIG] No default directory : %s", TTS_DEFAULT_ENGINE_INFO);
        } else {
                do {
                        ret = readdir_r(dp, &entry, &dirp);
@@ -799,7 +799,7 @@ int __tts_config_mgr_get_engine_info()
        /* Get engine info from default engine directory */
        dp  = opendir(TTS_DOWNLOAD_ENGINE_INFO);
        if (NULL == dp) {
-               SLOG(LOG_DEBUG, tts_tag(), "[CONFIG] No downloadable directory : %s", TTS_DEFAULT_ENGINE_INFO);
+               SLOG(LOG_DEBUG, tts_tag(), "[CONFIG] No downloadable directory : %s", TTS_DOWNLOAD_ENGINE_INFO);
        } else {
                do {
                        ret = readdir_r(dp, &entry, &dirp);
@@ -916,16 +916,27 @@ static Eina_Bool __tts_config_mgr_engine_config_inotify_event_callback(void* dat
 
 static int __tts_config_mgr_register_engine_config_updated_event(const char* path)
 {
+       if (NULL == path) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Path is NULL");
+               return -1;
+       }
+
        /* For engine directory monitoring */
        tts_engine_inotify_s *ino = (tts_engine_inotify_s *)calloc(1, sizeof(tts_engine_inotify_s));
+       if (NULL == ino) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory");
+               return -1;
+       }
 
        ino->dir_fd = inotify_init();
        if (ino->dir_fd < 0) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to init inotify");
+               free(ino);
+               ino = NULL;
+
                return -1;
        }
 
-        /* FIX_ME *//* It doesn't need check engine directory, because daemon will change engine-process */
        ino->dir_wd = inotify_add_watch(ino->dir_fd, path, IN_CLOSE_WRITE);
        SLOG(LOG_DEBUG, tts_tag(), "Add inotify watch(%s)", path);
        if (ino->dir_wd < 0) {
@@ -959,10 +970,10 @@ static int __tts_config_mgr_unregister_engine_config_updated_event()
        if (0 < g_list_length(g_ino_list)) {
                GList *iter = NULL;
                iter = g_list_first(g_ino_list);
-               
+
                while (NULL != iter) {
                        tts_engine_inotify_s *tmp = iter->data;
-                       
+
                        if (NULL != tmp) {
                                ecore_main_fd_handler_del(tmp->dir_fd_handler);
                                inotify_rm_watch(tmp->dir_fd, tmp->dir_wd);
@@ -1024,10 +1035,23 @@ int tts_config_mgr_initialize(int uid)
                g_config_client_list = g_slist_append(g_config_client_list, temp_client);
        }
 
+       if (0 != access(TTS_HOME, F_OK)) {
+               if (0 != mkdir(TTS_HOME, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to make directory : %s", TTS_HOME);
+                       __tts_config_release_client(uid);
+                       __tts_config_release_engine();
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+               } else {
+                       SLOG(LOG_DEBUG, tts_tag(), "Success to make directory : %s", TTS_HOME);
+               }
+       }
+
        if (0 != access(TTS_CONFIG_BASE, F_OK)) {
                if (0 != mkdir(TTS_CONFIG_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
                        SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to make directory : %s", TTS_CONFIG_BASE);
-                       return -1;
+                       __tts_config_release_client(uid);
+                       __tts_config_release_engine();
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
                } else {
                        SLOG(LOG_DEBUG, tts_tag(), "Success to make directory : %s", TTS_CONFIG_BASE);
                }
@@ -1036,7 +1060,9 @@ int tts_config_mgr_initialize(int uid)
        if (0 != access(TTS_DOWNLOAD_BASE, F_OK)) {
                if (0 != mkdir(TTS_DOWNLOAD_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
                        SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to make directory : %s", TTS_DOWNLOAD_BASE);
-                       return -1;
+                       __tts_config_release_client(uid);
+                       __tts_config_release_engine();
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
                } else {
                        SLOG(LOG_DEBUG, tts_tag(), "Success to make directory : %s", TTS_DOWNLOAD_BASE);
                }
@@ -1045,7 +1071,9 @@ int tts_config_mgr_initialize(int uid)
        if (0 != access(TTS_DOWNLOAD_ENGINE_INFO, F_OK)) {
                if (0 != mkdir(TTS_DOWNLOAD_ENGINE_INFO, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
                        SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to make directory : %s", TTS_DOWNLOAD_ENGINE_INFO);
-                       return -1;
+                       __tts_config_release_client(uid);
+                       __tts_config_release_engine();
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
                } else {
                        SLOG(LOG_DEBUG, tts_tag(), "Success to make directory : %s", TTS_DOWNLOAD_ENGINE_INFO);
                }
index 5451116..c49a75a 100644 (file)
@@ -59,6 +59,7 @@ extern "C" {
 
 #define TTS_METHOD_SET_PRIVATE_DATA    "tts_method_set_private_data"
 #define TTS_METHOD_GET_PRIVATE_DATA    "tts_method_get_private_data"
+#define TTS_METHOD_SET_CREDENTIAL      "tts_method_set_credential"
 
 #define TTSD_METHOD_HELLO              "ttsd_method_hello"
 #define TTSD_METHOD_UTTERANCE_STARTED  "ttsd_method_utterance_started"
@@ -79,8 +80,9 @@ extern "C" {
 #define TTS_DEFAULT_ENGINE_INFO                tzplatform_mkpath(TZ_SYS_RO_SHARE, "/voice/tts/1.0/engine-info")
 #define TTS_DEFAULT_ENGINE_SETTING     tzplatform_mkpath(TZ_SYS_RO_SHARE, "/voice/tts/1.0/engine-setting")
 
-#define TTS_DOWNLOAD_BASE              tzplatform_mkpath(TZ_USER_HOME, "/share/.voice/tts")
-#define TTS_DOWNLOAD_ENGINE_INFO       tzplatform_mkpath(TZ_USER_HOME, "/share/.voice/tts/engine-info")
+#define TTS_HOME                       tzplatform_mkpath(TZ_USER_HOME, "/share/.voice/tts")
+#define TTS_DOWNLOAD_BASE              tzplatform_mkpath(TZ_USER_HOME, "/share/.voice/tts/1.0")
+#define TTS_DOWNLOAD_ENGINE_INFO       tzplatform_mkpath(TZ_USER_HOME, "share/.voice/tts/1.0/engine-info")
 
 #define TTS_BASE_LANGUAGE              "en_US"
 
diff --git a/doc/uix_tts_engine_main_doc.h b/doc/uix_tts_engine_main_doc.h
new file mode 100755 (executable)
index 0000000..9dade17
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2011-2016 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.
+ */
+
+
+#ifndef __TIZEN_UIX_TTS_ENGINE_DOC_H__
+#define __TIZEN_UIX_TTS_ENGINE_DOC_H__
+
+/**
+ * @ingroup CAPI_UIX_FRAMEWORK
+ * @defgroup CAPI_UIX_TTSE_MODULE TTS Engine
+ * @brief The @ref CAPI_UIX_TTSE_MODULE APIs provide functions to operate Text-To-Speech Engine.
+ *
+ *
+ * @section CAPI_UIX_TTSE_MODULE_HEADER Required Header
+ *   \#include <ttse.h>
+ *
+ *
+ * @section CAPI_UIX_TTSE_MODULE_OVERVIEW Overview
+ * Text-To-Speech Engine (below TTSE) is an engine for synthesizing voice from text and playing synthesized sound data.
+ * Using the @ref CAPI_UIX_TTSE_MODULE APIs, TTSE developers can provide TTSE service users, who want to apply TTSE, with functions necessary to operate the engine.
+ * According to the indispensability of TTSE services, there are two ways to provide them to the users. <br>
+ *
+ * <b>A. Required TTSE services</b> <br>
+ * These services are indispensable to operate TTSE. Therefore, the TTSE developers MUST implement callback functions corresponding to the required TTSE services.
+ * The following is a list of the callback functions. <br>
+ *
+ * <table>
+ * <tr>
+ * <th>FUNCTION</th>
+ * <th>DESCRIPTION</th>
+ * </tr>
+ * <tr>
+ * <td>ttse_get_info_cb()</td>
+ * <td>Called when the engine service user requests the basic information of TTS engine.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_initialize_cb()</td>
+ * <td>Called when the engine service user initializes TTS engine.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_deinitialize_cb()</td>
+ * <td>Called when the engine service user deinitializes TTS engine.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_is_valid_voice_cb()</td>
+ * <td>Called when the engine service user checks whether the voice is valid or not in TTS engine.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_foreach_supported_voices_cb()</td>
+ * <td>Called when the engine service user gets the whole supported voice list.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_set_pitch_cb()</td>
+ * <td>Called when the engine service user sets the default pitch of TTS engine.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_load_voice_cb()</td>
+ * <td>Called when the engine service user requests to load the corresponding voice type for the first time.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_unload_voice_cb()</td>
+ * <td>Called when the engine service user requests to unload the corresponding voice type or to stop using voice.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_start_synthesis_cb()</td>
+ * <td>Called when the engine service user starts to synthesize a voice, asynchronously.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_cancel_synthesis_cb()</td>
+ * <td>Called when the engine service user cancels to synthesize a voice.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_check_app_agreed_cb()</td>
+ * <td>Called when the engine service user requests for TTS engine to check whether the application agreed the usage of TTS engine.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_need_app_credential_cb()</td>
+ * <td>Called when the engine service user checks whether TTS engine needs the application's credential.</td>
+ * </tr>
+ * </table>
+ *
+ * The TTSE developers can register the above callback functions at a time with using a structure 'ttse_request_callback_s' and an API 'ttse_main()'.
+ * To operate TTSE, the following steps should be used: <br>
+ * 1. Create a structure 'ttse_request_callback_s'
+ * 2. Implement callback functions. (NOTE that the callback functions should return appropriate values in accordance with the instruction.
+ *     If the callback function returns an unstated value, TTS framework will handle it as #TTSE_ERROR_OPERATION_FAILED.) <br>
+ * 3. Register callback functions using 'ttse_main()'. (The registered callback functions will be invoked when the TTSE service users request the TTSE services.) <br>
+ * 4. Use 'service_app_main()' for working TTSE. <br>
+ *
+ * <b>B. Optional TTSE services</b> <br>
+ * Unlike the required TTSE services, these services are optional to operate TTSE. The followings are optional TTSE services. <br>
+ * - receive/provide the private data <br>
+ *
+ * If the TTSE developers want to provide the above services, use the following APIs and implement the corresponding callback functions: <br>
+ * <table>
+ * <tr>
+ * <th>FUNCTION</th>
+ * <th>DESCRIPTION</th>
+ * <th>CORRESPONDING CALLBACK</th>
+ * </tr>
+ * <tr>
+ * <td>ttse_set_private_data_set_cb()</td>
+ * <td>Sets a callback function for receiving the private data from the engine service user.</td>
+ * <td>ttse_private_data_set_cb()</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_set_private_data_requested_cb()</td>
+ * <td>Sets a callback function for providing the private data to the engine service user.</td>
+ * <td>ttse_private_data_requested_cb()</td>
+ * </tr>
+ * </table>
+ *
+ * Using the above APIs, the TTSE developers can register the optional callback functions respectively.
+ * (For normal operation, put those APIs before 'service_app_main()' starts.)
+ *
+ * Unlike callback functions, the following APIs are functions for getting and sending data. The TTSE developers can use these APIs when they implement TTSE services: <br>
+ * <table>
+ * <tr>
+ * <th>FUNCTION</th>
+ * <th>DESCRIPTION</th>
+ * </tr>
+ * <tr>
+ * <td>ttse_get_speed_range()</td>
+ * <td>Gets the speed range from Tizen platform.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_get_pitch_range()</td>
+ * <td>Gets the pitch range from Tizen platform.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_send_result()</td>
+ * <td>Sends the synthesized result to the engine service user.</td>
+ * </tr>
+ * <tr>
+ * <td>ttse_send_error()</td>
+ * <td>Sends the error to the engine service user.</td>
+ * </tr>
+ * </table>
+ *
+ *
+ * @section CAPI_UIX_TTSE_MODULE_FEATURE Related Features
+ * This API is related with the following features:<br>
+ *  - http://tizen.org/feature/speech.synthesis<br>
+ *
+ * It is recommended to design feature related codes in your application for reliability.<br>
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.<br>
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.<br>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
+ *
+ */
+
+#endif /* __TIZEN_UIX_TTS_ENGINE_DOC_H__ */
+
index cda0d5b..9e11971 100644 (file)
@@ -9,4 +9,4 @@ INSTALL(FILES "${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}-setting.pc" DESTINATI
 INSTALL(FILES "${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}-engine.pc" DESTINATION ${LIBDIR}/pkgconfig)
 INSTALL(FILES "${CMAKE_BINARY_DIR}/include/tts.h" DESTINATION ${INCLUDEDIR})
 INSTALL(FILES "${CMAKE_BINARY_DIR}/include/tts_setting.h" DESTINATION ${INCLUDEDIR})
-INSTALL(FILES "${CMAKE_BINARY_DIR}/server/ttsp.h" DESTINATION ${INCLUDEDIR})
+INSTALL(FILES "${CMAKE_BINARY_DIR}/include/ttse.h" DESTINATION ${INCLUDEDIR})
index 4f68dd5..e792a85 100644 (file)
@@ -7,4 +7,5 @@ Name: lib@PROJECT_NAME@_engine
 Description: Text To Speech client engine header
 Requires: glib-2.0 dbus-1 
 Version: @VERSION@
+Libs: -L${libdir} -l@PROJECT_NAME@_engine
 Cflags: -I${includedir}
index acabc69..eb3bd3d 100644 (file)
@@ -889,8 +889,4 @@ int tts_unset_engine_changed_cb(tts_h tts);
 }
 #endif
 
-/**
-* @}
-*/
-
 #endif /* __TTS_H__ */
diff --git a/include/ttse.h b/include/ttse.h
new file mode 100755 (executable)
index 0000000..744f459
--- /dev/null
@@ -0,0 +1,653 @@
+/*
+*  Copyright (c) 2011-2016 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.
+*/
+
+
+#ifndef __TTSE_H__
+#define __TTSE_H__
+
+#include <tizen.h>
+
+/**
+* @addtogroup CAPI_UIX_TTSE_MODULE
+* @{
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* @brief Enumerations for error codes.
+* @since_tizen 3.0
+*/
+typedef enum {
+       TTSE_ERROR_NONE                         = TIZEN_ERROR_NONE,                     /**< Successful */
+       TTSE_ERROR_OUT_OF_MEMORY                = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of Memory */
+       TTSE_ERROR_IO_ERROR                     = TIZEN_ERROR_IO_ERROR,                 /**< I/O error */
+       TTSE_ERROR_INVALID_PARAMETER            = TIZEN_ERROR_INVALID_PARAMETER,        /**< Invalid parameter */
+       TTSE_ERROR_NETWORK_DOWN                 = TIZEN_ERROR_NETWORK_DOWN,             /**< Out of network */
+       TTSE_ERROR_PERMISSION_DENIED            = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied */
+       TTSE_ERROR_INVALID_STATE                = TIZEN_ERROR_TTS | 0x01,               /**< Invalid state */
+       TTSE_ERROR_INVALID_VOICE                = TIZEN_ERROR_TTS | 0x02,               /**< Invalid voice */
+       TTSE_ERROR_OPERATION_FAILED             = TIZEN_ERROR_TTS | 0x04,               /**< Operation failed */
+       TTSE_ERROR_NOT_SUPPORTED_FEATURE        = TIZEN_ERROR_TTS | 0x06,               /**< Not supported feature */
+       TTSE_ERROR_NOT_SUPPORTED                = TIZEN_ERROR_NOT_SUPPORTED             /**< Not supported */
+} ttse_error_e;
+
+/**
+* @brief Enumerations for audio type.
+* @since_tizen 3.0
+*/
+typedef enum {
+       TTSE_AUDIO_TYPE_RAW_S16 = 0,            /**< Signed 16-bit audio type */
+       TTSE_AUDIO_TYPE_RAW_U8,                 /**< Unsigned 8-bit audio type */
+       TTSE_AUDIO_TYPE_MAX
+} ttse_audio_type_e;
+
+/**
+* @brief Enumerations for result event type.
+* @since_tizen 3.0
+*/
+typedef enum {
+       TTSE_RESULT_EVENT_FAIL          = -1,   /**< Event when the voice synthesis is failed */
+       TTSE_RESULT_EVENT_START         = 1,    /**< Event when the sound data is first data by callback function */
+       TTSE_RESULT_EVENT_CONTINUE      = 2,    /**< Event when the next sound data exist, not first and not last */
+       TTSE_RESULT_EVENT_FINISH        = 3             /**< Event when the sound data is last data or sound data is only one result */
+} ttse_result_event_e;
+
+/**
+* @brief Definitions for male voice type.
+* @since_tizen 3.0
+*/
+#define TTSE_VOICE_TYPE_MALE   1
+
+/**
+* @brief Definitions for female voice type.
+* @since_tizen 3.0
+*/
+#define TTSE_VOICE_TYPE_FEMALE 2
+
+/**
+* @brief Definitions for child's voice type.
+* @since_tizen 3.0
+*/
+#define TTSE_VOICE_TYPE_CHILD  3
+
+
+/**
+* @brief Called when TTS engine informs the engine service user about whole supported language and voice type list.
+* @details This callback function is implemented by the engine service user. Therefore, the engine developer does NOT have to implement this callback function.
+* @since_tizen 3.0
+*
+* @remarks This callback function is called by ttse_foreach_supported_voices_cb() to inform the whole supported voice list.
+*      @a user_data must be transferred from ttse_foreach_supported_voices_cb().
+*
+* @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
+*      followed by ISO 639-1 for the two-letter language code. \n
+*      For example, "ko_KR" for Korean, "en_US" for American English.
+* @param[in] type The voice type
+* @param[in] user_data The user data passed from ttse_foreach_supported_voices_cb()
+*
+* @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
+*
+* @pre ttse_foreach_supported_voices_cb() will invoke this callback function.
+*
+* @see ttse_foreach_supported_voices_cb()
+*/
+typedef bool (*ttse_supported_voice_cb)(const char* language, int type, void* user_data);
+
+/**
+* @brief Called when the engine service user initializes TTS engine.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_INVALID_STATE Already initialized
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+* @retval #TTSE_ERROR_PERMISSION_DENIED Permission denied
+*
+* @see ttse_deinitialize_cb()
+*/
+typedef int (*ttse_initialize_cb)(void);
+
+/**
+* @brief Called when the engine service user deinitializes TTS engine.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*      NOTE that the engine may be terminated automatically.
+*      When this callback function is invoked, the release of resources is necessary.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized
+*
+* @see ttse_initialize_cb()
+*/
+typedef int (*ttse_deinitialize_cb)(void);
+
+/**
+* @brief Called when the engine service user gets the whole supported voice list.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*      In this function, the engine service user's callback function 'ttse_supported_voice_cb()' is invoked repeatedly for getting all supported voices, and @a user_data must be transferred to 'ttse_supported_voice_cb()'.
+*      If 'ttse_supported_voice_cb()' returns @c false, it should be stopped to call 'ttse_supported_voice_cb()'.
+*
+*
+* @param[in] callback The callback function
+* @param[in] user_data The user data which must be passed to ttse_supported_voice_cb()
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized
+*
+* @post        This callback function invokes ttse_supported_voice_cb() repeatedly for getting all supported voices.
+*
+* @see ttse_supported_voice_cb()
+*/
+typedef int (*ttse_foreach_supported_voices_cb)(ttse_supported_voice_cb callback, void* user_data);
+
+/**
+* @brief Called when the engine service user checks whether the voice is valid or not in TTS engine.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*
+* @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
+*      followed by ISO 639-1 for the two-letter language code. \n
+*      For example, "ko_KR" for Korean, "en_US" for American English.
+* @param[in] type The voice type
+* @param[out] is_valid A variable for checking whether the corresponding voice is valid or not. \n @c true to be valid, @c false to be invalid.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+*
+* @see ttse_foreach_supported_voices_cb()
+*/
+typedef int (*ttse_is_valid_voice_cb)(const char* language, int type, bool* is_valid);
+
+/**
+* @brief Called when the engine service user sets the default pitch of TTS engine.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*
+* @param[in] pitch The default pitch
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*/
+typedef int (*ttse_set_pitch_cb)(int pitch);
+
+/**
+* @brief Called when the engine service user requests to load the corresponding voice type for the first time.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*
+* @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
+*      followed by ISO 639-1 for the two-letter language code. \n
+*      For example, "ko_KR" for Korean, "en_US" for American English.
+* @param[in] type The voice type
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized
+* @retval #TTSE_ERROR_OUT_OF_MEMORY Out of memory
+* @retval #TTSE_ERROR_INVALID_VOICE Invalid voice
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*
+* @see ttse_unload_voice_cb()
+*/
+typedef int (*ttse_load_voice_cb)(const char* language, int type);
+
+/**
+* @brief Called when the engine service user requests to unload the corresponding voice type or to stop using voice.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*
+* @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
+*      followed by ISO 639-1 for the two-letter language code. \n
+*      For example, "ko_KR" for Korean, "en_US" for American English.
+* @param[in] type The voice type
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized
+* @retval #TTSE_ERROR_INVALID_VOICE Invalid voice
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*
+* @see ttse_load_voice_cb()
+*/
+typedef int (*ttse_unload_voice_cb)(const char* language, int type);
+
+/**
+* @brief Called when the engine service user requests for TTS engine to check whether the application agreed the usage of TTS engine.
+* @details This callback function is called when the engine service user requests for TTS engine to check the application's agreement about using the engine.
+*      According to the need, the engine developer can provide some user interfaces to check the agreement.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*      If the TTS engine developer wants not to check the agreement, the developer has need to return proper values as @a is_agreed in accordance with the intention. \n @c true if the developer regards that every application agreed the usage of the engine, @c false if the developer regards that every application disagreed.
+*      NOTE that, however, there may be any legal issue unless the developer checks the agreement. Therefore, we suggest that the engine developers should provide a function to check the agreement.
+*
+* @param[in] appid The Application ID
+* @param[out] is_agreed A variable for checking whether the application agreed to use TTS engine or not. \n @c true to agree, @c false to disagree.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
+*/
+typedef int (*ttse_check_app_agreed_cb)(const char* appid, bool* is_agreed);
+
+/**
+* @brief Called when the engine service user checks whether TTS engine needs the application's credential.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*
+* @return @c true if TTS engine needs the application's credential, otherwise @c false
+*/
+typedef bool (*ttse_need_app_credential_cb)(void);
+
+/**
+* @brief Called when the engine service user starts to synthesize a voice, asynchronously.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*      In this callback function, TTS engine must transfer the synthesized result and @a user_data to the engine service user using ttse_send_result().
+*      Also, if TTS engine needs the application's credential, it can set the credential granted to the application.
+*
+* @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
+*      followed by ISO 639-1 for the two-letter language code. \n
+*      For example, "ko_KR" for Korean, "en_US" for American English.
+* @param[in] type The voice type
+* @param[in] text Texts
+* @param[in] speed The speed of speaking
+* @param[in] appid The Application ID
+* @param[in] credential The credential granted to the application
+* @param[in] user_data The user data which must be passed to ttse_send_result()
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized or already started synthesis
+* @retval #TTSE_ERROR_INVALID_VOICE Invalid voice
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+* @retval #TTSE_ERROR_NETWORK_DOWN Out of network
+* @retval #TTSE_ERROR_PERMISSION_DENIED Permission denied
+*
+* @post This function invokes ttse_send_result().
+*
+* @see ttse_send_result()
+* @see ttse_cancel_synthesis_cb()
+* @see ttse_need_app_credential_cb()
+*/
+typedef int (*ttse_start_synthesis_cb)(const char* language, int type, const char* text, int speed, const char* appid, const char* credential, void* user_data);
+
+/**
+* @brief Called when the engine service user cancels to synthesize a voice.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized or not started synthesis
+*
+* @pre The ttse_start_synthesis_cb() should be performed
+*
+* @see ttse_start_synthesis_cb()
+*/
+typedef int (*ttse_cancel_synthesis_cb)(void);
+
+/**
+* @brief Called when the engine service user requests the basic information of TTS engine.
+* @since_tizen 3.0
+*
+* @remarks This callback function is mandatory and must be registered using ttse_main().
+*      The allocated @a engine_uuid, @a engine_name, and @a engine_setting will be released internally.
+*      In order to upload the engine at Tizen Appstore, both a service app and a ui app are necessary.
+*      Therefore, @a engine_setting must be transferred to the engine service user.
+*
+* @param[out] engine_uuid UUID of engine
+* @param[out] engine_name Name of engine
+* @param[out] engine_setting The engine setting application(ui app)'s app id
+* @param[out] use_network The status for using network
+*
+* @return 0 on success, otherwise a negative error code on failure
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*
+*/
+typedef int (*ttse_get_info_cb)(char** engine_uuid, char** engine_name, char** engine_setting, bool* use_network);
+
+/**
+* @brief Called when TTS engine receives the private data from the engine service user.
+* @details This callback function is called when the engine service user sends the private data to TTS engine.
+* @since_tizen 3.0
+*
+* @remarks This callback function is optional and is registered using ttse_set_private_data_set_cb().
+*
+* @param[in] key The key field of private data.
+* @param[in] data The data field of private data.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+* @retval #TTSE_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
+*
+* @see ttse_private_data_requested_cb()
+* @see ttse_set_private_data_set_cb()
+*/
+typedef int (*ttse_private_data_set_cb)(const char* key, const char* data);
+
+/**
+* @brief Called when TTS engine provides the engine service user with the private data.
+* @details This callback function is called when the engine service user gets the private data from TTS engine.
+* @since_tizen 3.0
+*
+* @remarks This callback function is optional and is registered using ttse_set_private_data_requested_cb().
+*
+* @param[out] key The key field of private data.
+* @param[out] data The data field of private data.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+* @retval #TTSE_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
+*
+* @see ttse_private_data_set_cb()
+* @see ttse_set_private_data_requested_cb()
+*/
+typedef int (*ttse_private_data_requested_cb)(const char* key, char** data);
+
+
+/**
+* @brief A structure for the TTS engine functions.
+* @details This structure contains essential callback functions for operating TTS engine.
+* @since_tizen 3.0
+*
+* @remarks These functions are mandatory for operating TTS engine. Therefore, all functions MUST be implemented.
+*/
+typedef struct {
+       int version;                                                    /**< The version of the structure 'ttse_request_callback_s' */
+       ttse_get_info_cb                        get_info;               /**< Called when the engine service user requests the basic information of TTS engine */
+
+       ttse_initialize_cb                      initialize;             /**< Called when the engine service user initializes TTS engine */
+       ttse_deinitialize_cb                    deinitialize;           /**< Called when the engine service user deinitializes TTS engine */
+
+       ttse_foreach_supported_voices_cb        foreach_voices;         /**< Called when the engine service user gets the whole supported voice list */
+       ttse_is_valid_voice_cb                  is_valid_voice;         /**< Called when the engine service user checks whether the voice is valid or not in TTS engine */
+       ttse_set_pitch_cb                       set_pitch;              /**< Called when the engine service user sets the default pitch of TTS engine */
+
+       ttse_load_voice_cb                      load_voice;             /**< Called when the engine service user requests to load the corresponding voice type for the first time */
+       ttse_unload_voice_cb                    unload_voice;           /**< Called when the engine service user requests to unload the corresponding voice type or to stop using voice */
+
+       ttse_start_synthesis_cb                 start_synth;            /**< Called when the engine service user starts to synthesize a voice, asynchronously */
+       ttse_cancel_synthesis_cb                cancel_synth;           /**< Called when the engine service user cancels to synthesize a voice */
+
+       ttse_check_app_agreed_cb                check_app_agreed;       /**< Called when the engine service user requests for TTS engine to check whether the application agreed the usage of TTS engine */ 
+       ttse_need_app_credential_cb             need_app_credential;    /**< Called when the engine service user checks whether TTS engine needs the application's credential */
+} ttse_request_callback_s;
+
+/**
+* @brief Main function for Text-To-Speech (TTS) engine.
+* @details This function is the main function for operating TTS engine.
+*
+* @since_tizen 3.0
+*
+* @remarks The service_app_main() should be used for working the engine after this function.
+*
+* @param[in] argc The argument count(original)
+* @param[in] argv The argument(original)
+* @param[in] callback The structure of engine request callback function
+*
+* @return This function returns zero on success, or negative with error code on failure
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+* @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+*
+* @see ttse_request_callback_s
+*
+* @code
+#include <ttse.h>
+
+// Required callback functions - MUST BE IMPLEMENTED
+static int ttsengine_get_info_cb(char** engine_uuid, char** engine_name, char** engine_setting, bool* use_network);
+static int ttsengine_initialize_cb(void);
+static int ttsengine_deinitialize_cb(void);
+static int ttsengine_is_valid_voice_cb(const char* language, int type, bool* is_valid);
+static int ttsengine_foreach_supported_voices_cb(ttse_supported_voice_cb callback, void* user_data);
+static int ttsengine_set_pitch_cb(int pitch);
+static int ttsengine_load_voice_cb(const char* language, int type);
+static int ttsengine_unload_voice_cb(const char* language, int type);
+static int ttsengine_start_synthesis_cb(const char* language, int type, const char* text, int speed, void* user_data);
+static int ttsengine_cancel_synthesis_cb(void);
+static int ttsengine_check_app_agreed_cb(const char* appid, bool* is_agreed);
+static bool ttsengine_need_app_credential_cb(void);
+
+// Optional callback function
+static int ttsengine_private_data_set_cb(const char* key, const char* data);
+
+int main(int argc, char* argv[])
+{
+       // 1. Create a structure 'ttse_request_callback_s'
+       ttse_request_callback_s engine_callback = { 0, };
+
+       engine_callback.size = sizeof(ttse_request_callback_s);
+       engine_callback.version = 1;
+       engine_callback.get_info = ttsengine_get_info_cb;
+       engine_callback.initialize = ttsengine_initialize_cb;
+       engine_callback.deinitialize = ttsengine_deinitialize_cb;
+       engine_callback.foreach_voices = ttsengine_foreach_supported_voices_cb;
+       engine_callback.is_valid_voice = ttsengine_is_valid_voice_cb;
+       engine_callback.set_pitch = ttsengine_set_pitch_cb;
+       engine_callback.load_voice = ttsengine_load_voice_cb;
+       engine_callback.unload_voice = ttsengine_unload_voice_cb;
+       engine_callback.start_synth = ttsengine_start_synthesis_cb;
+       engine_callback.cancel_synth = ttsengine_cancel_synthesis_cb;
+       engine_callback.check_app_agreed = ttsengine_check_app_agreed_cb;
+       engine_callback.need_app_credential = ttsengine_need_app_credential_cb;
+
+       // 2. Run 'ttse_main()'
+       if (0 != ttse_main(argc, argv, &engine_callback)) {
+               return -1;
+       }
+
+       // Optional
+       ttse_set_private_data_set_cb(ttsengine_private_data_set_cb);
+
+       // 3. Set event callbacks for service app and Run 'service_app_main()'
+       char ad[50] = { 0, };
+
+       service_app_lifecycle_callback_s event_callback;
+       app_event_handler_h handlers[5] = { NULL, };
+
+       event_callback.create = service_app_create;
+       event_callback.terminate = service_app_terminate;
+       event_callback.app_control = service_app_control;
+
+       service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
+       service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
+       service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
+       service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
+
+       return service_app_main(argc, argv, &event_callback, ad);
+}
+
+* @endcode
+*/
+int ttse_main(int argc, char** argv, ttse_request_callback_s *callback);
+
+/**
+* @brief Gets the speed range from Tizen platform.
+* @since_tizen 3.0
+*
+* @remarks This API is used when TTS engine wants to get the speed range from Tizen platform.
+*
+* @param[out] min The minimum speed value
+* @param[out] normal The normal speed value
+* @param[out] max The maximum speed value
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*
+*/
+int ttse_get_speed_range(int* min, int* normal, int* max);
+
+/**
+* @brief Gets the pitch range from Tizen platform.
+* @since_tizen 3.0
+*
+* @remarks This API is used when TTS engine wants to get the pitch range from Tizen platform.
+*
+* @param[out] min The minimum pitch value
+* @param[out] normal The normal pitch value
+* @param[out] max The maximum pitch value
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*
+*/
+int ttse_get_pitch_range(int* min, int* normal, int* max);
+
+/**
+* @brief Sends the synthesized result to the engine service user.
+* @since_tizen 3.0
+*
+* @remarks This API is used in ttse_start_synthesis_cb(), when TTS engine sends the synthesized result to the engine service user.
+*      The synthesized result and @a user_data must be transferred to the engine service user through this function.
+*
+* @param[in] event The result event
+* @param[in] data Result data
+* @param[in] data_size Result data size
+* @param[in] audio_type The audio type
+* @param[in] rate The sample rate
+* @param[in] user_data The user data passed from ttse_start_synthesis_cb()
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*
+* @pre The ttse_main() function should be invoked before this function is called.
+*      ttse_start_synthesis_cb() will invoke this function.
+*
+* @see ttse_start_synthesis_cb()
+*/
+int ttse_send_result(ttse_result_event_e event, const void* data, unsigned int data_size,
+                       ttse_audio_type_e audio_type, int rate, void* user_data);
+
+/**
+* @brief Sends the error to the engine service user.
+* @details The following error codes can be delivered.\n
+*      #TTSE_ERROR_NONE,\n
+*      #TTSE_ERROR_OUT_OF_MEMORY,\n
+*      #TTSE_ERROR_IO_ERROR,\n
+*      #TTSE_ERROR_INVALID_PARAMETER,\n
+*      #TTSE_ERROR_NETWORK_DOWN,\n
+*      #TTSE_ERROR_PERMISSION_DENIED,\n
+*      #TTSE_ERROR_INVALID_STATE,\n
+*      #TTSE_ERROR_INVALID_VOICE,\n
+*      #TTSE_ERROR_OPERATION_FAILED,\n
+*      #TTSE_ERROR_NOT_SUPPORTED_FEATURE,\n
+*      #TTSE_ERROR_NOT_SUPPORTED.\n
+*
+* @since_tizen 3.0
+
+* @param[in] error The error reason
+* @param[in] msg The error message
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*
+* @pre The ttse_main() function should be invoked before this function is called.
+*/
+int ttse_send_error(ttse_error_e error, const char* msg);
+
+/**
+* @brief Sets a callback function for setting the private data.
+* @since_tizen 3.0
+*
+* @remarks The ttse_private_data_set_cb() function is called when the engine service user sends the private data.
+*
+* @param[in] callback_func ttse_private_data_set event callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*
+* @pre The ttse_main() function should be invoked before this function is called.
+*
+* @see ttse_private_data_set_cb()
+*/
+int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func);
+
+/**
+* @brief Sets a callback function for requesting the private data.
+* @since_tizen 3.0
+*
+* @remarks The ttse_private_data_requested_cb() function is called when the engine service user gets the private data from TTS engine.
+*
+* @param[in] callback_func ttse_private_data_requested event callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*
+* @pre The ttse_main() function should be invoked before this function is called.
+*
+* @see ttse_private_data_requested_cb()
+*/
+int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_func);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TTSE_H__ */
index ef88ac4..a48006a 100644 (file)
@@ -1,3 +1,4 @@
 [D-BUS Service]
 Name=org.tizen.voice.ttsnotiserver
-Exec=/usr/bin/tts-daemon-noti
+#Exec=/bin/sh -c "buxton2ctl get user db/voice/tts_engine | awk '{print$5}' | xargs -t -i launch_app {}-noti"
+Exec=/bin/sh -c "launch_app org.tizen.tts-engine-default-noti mode noti"
index ff59c82..cb3ee74 100644 (file)
@@ -1,3 +1,4 @@
 [D-BUS Service]
 Name=org.tizen.voice.ttsserver
-Exec=/usr/bin/tts-daemon
+#Exec=/bin/sh -c "buxton2ctl get user db/voice/tts_engine | awk '{print$5}' | xargs -t -i launch_app {}"
+Exec=/bin/sh -c "launch_app org.tizen.tts-engine-default"
index 020af4f..e0cfccf 100644 (file)
@@ -1,3 +1,4 @@
 [D-BUS Service]
 Name=org.tizen.voice.ttssrserver
-Exec=/usr/bin/tts-daemon-sr
+#Exec=/bin/sh -c "buxton2ctl get user db/voice/tts_engine | awk '{print$5}' | xargs -t -i launch_app {}-sr"
+Exec=/bin/sh -c "launch_app org.tizen.tts-engine-default-sr mode sr"
index 7a20215..b29769e 100644 (file)
@@ -20,6 +20,7 @@ BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(bundle)
 
 
 BuildRequires:  cmake
@@ -93,7 +94,6 @@ mkdir -p %{TZ_SYS_RO_SHARE}/voice/test
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
 %{_libdir}/lib*.so
-%{_bindir}/tts-daemon*
 %{TZ_SYS_RO_SHARE}/voice/tts/1.0/tts-config.xml
 %{TZ_SYS_RO_SHARE}/dbus-1/services/org.tizen.voice*
 %{TZ_SYS_RO_SHARE}/voice/test/tts-test
@@ -114,4 +114,4 @@ mkdir -p %{TZ_SYS_RO_SHARE}/voice/test
 %files engine-devel
 %defattr(-,root,root,-)
 %{_libdir}/pkgconfig/tts-engine.pc
-%{_includedir}/ttsp.h
+%{_includedir}/ttse.h
index 2ddedd1..5fd3eed 100644 (file)
@@ -4,44 +4,18 @@ SET(SRCS
        ttsd_dbus.c
        ttsd_dbus_server.c
        ttsd_engine_agent.c
-       ttsd_main.c
+       ttse.c
        ttsd_network.c
        ttsd_player.c
        ttsd_server.c
        ../common/tts_config_mgr.c
        ../common/tts_config_parser.c
 )
-       
-SET(NOTI_SRCS
-       ttsd_config.c
-       ttsd_data.cpp
-       ttsd_dbus.c
-       ttsd_dbus_server.c
-       ttsd_engine_agent.c
-       ttsd_main_noti.c
-       ttsd_network.c
-       ttsd_player.c
-       ttsd_server.c
-       ../common/tts_config_mgr.c
-       ../common/tts_config_parser.c
-)      
 
-SET(SR_SRCS
-       ttsd_config.c
-       ttsd_data.cpp
-       ttsd_dbus.c
-       ttsd_dbus_server.c
-       ttsd_engine_agent.c
-       ttsd_main_sr.c
-       ttsd_network.c
-       ttsd_player.c
-       ttsd_server.c
-       ../common/tts_config_mgr.c
-       ../common/tts_config_parser.c
-)
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/common)
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -54,16 +28,8 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIE")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 
 ## Executable ##
-ADD_EXECUTABLE("${PROJECT_NAME}-daemon" ${SRCS})
-TARGET_LINK_LIBRARIES("${PROJECT_NAME}-daemon" -ldl ${pkgs_LDFLAGS})
-
-ADD_EXECUTABLE("${PROJECT_NAME}-daemon-noti" ${NOTI_SRCS})
-TARGET_LINK_LIBRARIES("${PROJECT_NAME}-daemon-noti" -ldl ${pkgs_LDFLAGS})
-
-ADD_EXECUTABLE("${PROJECT_NAME}-daemon-sr" ${SR_SRCS})
-TARGET_LINK_LIBRARIES("${PROJECT_NAME}-daemon-sr" -ldl ${pkgs_LDFLAGS})
+ADD_LIBRARY("${PROJECT_NAME}_engine" SHARED ${SRCS})
+TARGET_LINK_LIBRARIES("${PROJECT_NAME}_engine" -ldl ${pkgs_LDFLAGS})
 
 ## Install ##
-INSTALL(TARGETS "${PROJECT_NAME}-daemon" DESTINATION bin)
-INSTALL(TARGETS "${PROJECT_NAME}-daemon-noti" DESTINATION bin)
-INSTALL(TARGETS "${PROJECT_NAME}-daemon-sr" DESTINATION bin)
+INSTALL(TARGETS "${PROJECT_NAME}_engine" DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
index d21ae3a..363b8b7 100644 (file)
@@ -28,17 +28,17 @@ void __ttsd_config_engine_changed_cb(const char* engine_id, const char* setting,
 {
        /* Need to check engine is valid */
        if (false == tts_config_check_default_engine_is_valid(engine_id)) {
-               SLOG(LOG_ERROR, get_tag(), "Engine id is NOT valid : %s", engine_id);
+               SLOG(LOG_ERROR, tts_tag(), "Engine id is NOT valid : %s", engine_id);
                return;
        }
 
        if (NULL != g_callback) {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "Call the engine reload callback : engine id(%s)", engine_id);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "Call the engine reload callback : engine id(%s)", engine_id);
                g_callback(TTS_CONFIG_TYPE_ENGINE, engine_id, 0);
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "Call the voice changed callback : lang(%s), type(%d)", language, voice_type);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "Call the voice changed callback : lang(%s), type(%d)", language, voice_type);
                g_callback(TTS_CONFIG_TYPE_VOICE, language, voice_type);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "Config changed callback is NULL");
+               SLOG(LOG_ERROR, tts_tag(), "Config changed callback is NULL");
        }
 }
 
@@ -46,14 +46,14 @@ void __ttsd_config_voice_changed_cb(const char* before_language, int before_type
 {
        /* Need to check voice is valid */
        if (false == tts_config_check_default_voice_is_valid(language, type)) {
-               SLOG(LOG_ERROR, get_tag(), "Lang(%s) type(%d) is NOT valid : %s", language, type);
+               SLOG(LOG_ERROR, tts_tag(), "Lang(%s) type(%d) is NOT valid : %s", language, type);
                return;
        }
 
        if (NULL != g_callback) {
                g_callback(TTS_CONFIG_TYPE_VOICE, language, type);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "Config changed callback is NULL");
+               SLOG(LOG_ERROR, tts_tag(), "Config changed callback is NULL");
        }
 }
 
@@ -62,7 +62,7 @@ void __ttsd_config_speech_rate_changed_cb(int value, void* user_data)
        if (NULL != g_callback) {
                g_callback(TTS_CONFIG_TYPE_SPEED, NULL, value);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "Config changed callback is NULL");
+               SLOG(LOG_ERROR, tts_tag(), "Config changed callback is NULL");
        }
 }
 
@@ -71,7 +71,7 @@ void __ttsd_config_pitch_changed_cb(int value, void* user_data)
        if (NULL != g_callback) {
                g_callback(TTS_CONFIG_TYPE_PITCH, NULL, value);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "Config changed callback is NULL");
+               SLOG(LOG_ERROR, tts_tag(), "Config changed callback is NULL");
        }
 }
 
@@ -85,7 +85,7 @@ void __ttsd_config_screen_reader_changed_cb(bool value)
 int ttsd_config_initialize(ttsd_config_changed_cb config_cb)
 {
        if (NULL == config_cb) {
-               SLOG(LOG_ERROR, get_tag(), "[Config] Invalid parameter");
+               SLOG(LOG_ERROR, tts_tag(), "[Config] Invalid parameter");
                return -1;
        }
 
@@ -95,14 +95,14 @@ int ttsd_config_initialize(ttsd_config_changed_cb config_cb)
        int ret = -1;
        ret = tts_config_mgr_initialize(getpid());
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Config] Fail to initialize config manager");
+               SLOG(LOG_ERROR, tts_tag(), "[Config] Fail to initialize config manager");
                return -1;
        }
 
        ret = tts_config_mgr_set_callback(getpid(), __ttsd_config_engine_changed_cb, __ttsd_config_voice_changed_cb, 
                __ttsd_config_speech_rate_changed_cb, __ttsd_config_pitch_changed_cb, NULL);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to set config changed : %d", ret);
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set config changed : %d", ret);
                return -1;
        }
 
@@ -121,7 +121,7 @@ int ttsd_config_finalize()
 int ttsd_config_set_screen_reader_callback(ttsd_config_screen_reader_changed_cb sr_cb)
 {
        if (NULL == sr_cb) {
-               SLOG(LOG_ERROR, get_tag(), "[Config] Invalid parameter");
+               SLOG(LOG_ERROR, tts_tag(), "[Config] Invalid parameter");
                return -1;
        }
 
@@ -129,7 +129,7 @@ int ttsd_config_set_screen_reader_callback(ttsd_config_screen_reader_changed_cb
 
        int ret = tts_config_set_screen_reader_callback(getpid(), __ttsd_config_screen_reader_changed_cb) ;
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Config] Fail to set screen reader callback");
+               SLOG(LOG_ERROR, tts_tag(), "[Config] Fail to set screen reader callback");
                return -1;
        }
        return 0;
@@ -141,7 +141,7 @@ int ttsd_config_get_default_engine(char** engine_id)
                return -1;
 
        if (0 != tts_config_mgr_get_engine(engine_id)) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get engine id");
+               SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get engine id");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -155,7 +155,7 @@ int ttsd_config_set_default_engine(const char* engine_id)
 
        if (true == tts_config_check_default_engine_is_valid(engine_id)) {
                if (0 != tts_config_mgr_set_engine(engine_id)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to set engine id");
+                       SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to set engine id");
                }
        }
 
@@ -168,7 +168,7 @@ int ttsd_config_get_default_voice(char** language, int* type)
                return -1;
 
        if (0 != tts_config_mgr_get_voice(language, type)) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get default voice");
+               SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get default voice");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -181,7 +181,7 @@ int ttsd_config_get_default_speed(int* speed)
                return -1;
 
        if (0 != tts_config_mgr_get_speech_rate(speed)) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get default speech rate");
+               SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get default speech rate");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -194,7 +194,7 @@ int ttsd_config_get_default_pitch(int* pitch)
                return -1;
 
        if (0 != tts_config_mgr_get_pitch(pitch)) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get default pitch");
+               SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get default pitch");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -204,16 +204,17 @@ int ttsd_config_get_default_pitch(int* pitch)
 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)
 {
-       SLOG(LOG_ERROR, get_tag(), "=============== TTS ERROR LOG ====================");
+       SLOG(LOG_ERROR, tts_tag(), "=============== TTS ERROR LOG ====================");
 
-       SLOG(LOG_ERROR, get_tag(), "uid(%d) uttid(%d)", uid, uttid);
-       
-       if (NULL != func)       SLOG(LOG_ERROR, get_tag(), "Function(%s) Line(%d)", func, line);
-       if (NULL != message)    SLOG(LOG_ERROR, get_tag(), "Message(%s)", message);
-       if (NULL != lang)       SLOG(LOG_ERROR, get_tag(), "Lang(%s), type(%d)", lang, vctype);
-       if (NULL != text)       SLOG(LOG_ERROR, get_tag(), "Text(%s)", text);
+       SLOG(LOG_ERROR, tts_tag(), "uid(%d) uttid(%d)", uid, uttid);
 
-       SLOG(LOG_ERROR, get_tag(), "==================================================");
+
+       SLOG(LOG_ERROR, tts_tag(), "Function(%s) Line(%d)", (NULL == func) ? "NULL" : func, line);
+       SLOG(LOG_ERROR, tts_tag(), "Message(%s)", (NULL == message) ? "NULL" : message);
+       SLOG(LOG_ERROR, tts_tag(), "Lang(%s), type(%d)", (NULL == lang) ? "NULL" : lang, vctype);
+       SLOG(LOG_ERROR, tts_tag(), "Text(%s)", (NULL == text) ? "NULL" : text);
+
+       SLOG(LOG_ERROR, tts_tag(), "==================================================");
 
        return 0;
-}
\ No newline at end of file
+}
index f2c0c4e..f02ab1d 100644 (file)
@@ -50,77 +50,77 @@ int __data_show_list()
 {
        int vsize = g_app_list.size();
 
-       SLOG(LOG_DEBUG, get_tag(), "----- client list -----");
+       SLOG(LOG_DEBUG, tts_tag(), "----- client list -----");
 
        for (int i=0; i < vsize; i++) {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[%dth] pid(%d), uid(%d), state(%d)", i, g_app_list[i].pid, g_app_list[i].uid, g_app_list[i].state);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[%dth] pid(%d), uid(%d), state(%d)", i, g_app_list[i].pid, g_app_list[i].uid, g_app_list[i].state);
        }
 
        if (0 == vsize) {
-               SLOG(LOG_DEBUG, get_tag(), "No Client");
+               SLOG(LOG_DEBUG, tts_tag(), "No Client");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "-----------------------");
+       SLOG(LOG_DEBUG, tts_tag(), "-----------------------");
 
        return TTSD_ERROR_NONE;
 }
 
 int __data_show_sound_list(int index)
 {
-       SLOG(LOG_DEBUG, get_tag(), "----- Sound list -----");
+       SLOG(LOG_DEBUG, tts_tag(), "----- Sound list -----");
        
        unsigned int i = 0;
        std::list<sound_data_s*>::iterator iter;
        for (iter = g_app_list[index].m_wav_data.begin(); iter != g_app_list[index].m_wav_data.end(); iter++) {
-               SLOG(LOG_DEBUG, get_tag(), "[%dth][%p] data(%p) data size(%ld), uttid(%d), type(%d)", 
+               SLOG(LOG_DEBUG, tts_tag(), "[%dth][%p] data(%p) data size(%ld), uttid(%d), type(%d)", 
                        i, *iter, (*iter)->data, (*iter)->data_size, (*iter)->utt_id, (*iter)->audio_type);
                i++;
        }
 
        if (i == 0) {
-               SLOG(LOG_DEBUG, get_tag(), "No Sound Data");
+               SLOG(LOG_DEBUG, tts_tag(), "No Sound Data");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "----------------------");
+       SLOG(LOG_DEBUG, tts_tag(), "----------------------");
        return TTSD_ERROR_NONE;
 }
 
 int __data_show_text_list(int index)
 {
-       SLOG(LOG_DEBUG, get_tag(), "----- Text list -----");
+       SLOG(LOG_DEBUG, tts_tag(), "----- Text list -----");
 
        unsigned int i = 0;
        std::list<speak_data_s*>::iterator iter;
        for (iter = g_app_list[index].m_speak_data.begin(); iter != g_app_list[index].m_speak_data.end(); iter++) {
-               SLOG(LOG_DEBUG, get_tag(), "[%dth][%p] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s)", 
+               SLOG(LOG_DEBUG, tts_tag(), "[%dth][%p] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s)", 
                        i + 1, *iter, (*iter)->lang, (*iter)->vctype, (*iter)->speed, (*iter)->utt_id, (*iter)->text);
                i++;
        }
 
        if (0 == i) {
-               SLOG(LOG_DEBUG, get_tag(), "No Text Data");
+               SLOG(LOG_DEBUG, tts_tag(), "No Text Data");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "---------------------");
+       SLOG(LOG_DEBUG, tts_tag(), "---------------------");
        return TTSD_ERROR_NONE;
 }
 
 int __data_show_used_voice_list(int index)
 {
-       SLOG(LOG_DEBUG, get_tag(), "----- Used voice list -----");
+       SLOG(LOG_DEBUG, tts_tag(), "----- Used voice list -----");
 
        unsigned int i = 0;
        std::list<used_voice_s>::iterator iter;
        for (iter = g_app_list[index].m_used_voice.begin(); iter != g_app_list[index].m_used_voice.end(); iter++) {
-               SLOG(LOG_DEBUG, get_tag(), "[%dth] lang(%s), vctype(%d)", i + 1, iter->lang, iter->vctype);
+               SLOG(LOG_DEBUG, tts_tag(), "[%dth] lang(%s), vctype(%d)", i + 1, iter->lang, iter->vctype);
                i++;
        }
 
        if (0 == i) {
-               SLOG(LOG_DEBUG, get_tag(), "No Voice Data");
+               SLOG(LOG_DEBUG, tts_tag(), "No Voice Data");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "---------------------------");
+       SLOG(LOG_DEBUG, tts_tag(), "---------------------------");
        return TTSD_ERROR_NONE;
 }
 
@@ -131,7 +131,7 @@ int __data_show_used_voice_list(int index)
 int ttsd_data_new_client(int pid, int uid)
 {
        if( -1 != ttsd_data_is_client(uid) ) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -156,12 +156,12 @@ int ttsd_data_delete_client(int uid)
        index = ttsd_data_is_client(uid);
        
        if (index < 0) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return -1;
        }
 
        if (0 != ttsd_data_clear_data(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] Fail to clear data");
+               SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] Fail to clear data");
                return -1;
        }
 
@@ -198,7 +198,7 @@ int ttsd_data_get_pid(int uid)
        index = ttsd_data_is_client(uid);
        
        if (index < 0)  {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -211,7 +211,7 @@ int ttsd_data_get_speak_data_size(int uid)
        index = ttsd_data_is_client(uid);
        
        if (index < 0) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -225,7 +225,7 @@ int ttsd_data_set_used_voice(int uid, const char* lang, int type)
        index = ttsd_data_is_client(uid);
 
        if (index < 0) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -234,7 +234,7 @@ int ttsd_data_set_used_voice(int uid, const char* lang, int type)
 
        for (iter = g_app_list[index].m_used_voice.begin();iter != g_app_list[index].m_used_voice.end();iter++) {
                if (0 == strcmp(lang, iter->lang) && type == iter->vctype) {
-                       SLOG(LOG_DEBUG, get_tag(), "[DATA] The voice is already registered (%s)(%d)", lang, type);
+                       SLOG(LOG_DEBUG, tts_tag(), "[DATA] The voice is already registered (%s)(%d)", lang, type);
                        return 0;
                }
        }
@@ -259,12 +259,12 @@ int ttsd_data_reset_used_voice(int uid, ttsd_used_voice_cb callback)
        index = ttsd_data_is_client(uid);
 
        if (index < 0) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == callback) {
-               SLOG(LOG_WARN, get_tag(), "[DATA WARNING] Used voice callback is NULL");
+               SLOG(LOG_WARN, tts_tag(), "[DATA WARNING] Used voice callback is NULL");
        }
 
        /* Find voice */
@@ -295,7 +295,7 @@ int ttsd_data_add_speak_data(int uid, speak_data_s* data)
        index = ttsd_data_is_client(uid);
 
        if (index < 0) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
        
@@ -316,13 +316,13 @@ int ttsd_data_get_speak_data(int uid, speak_data_s** data)
        index = ttsd_data_is_client(uid);
 
        if (index < 0) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid(%d)", uid);    
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid(%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (0 == g_app_list[index].m_speak_data.size()) {
 #ifdef DATA_DEBUG
-               SLOG(LOG_WARN, get_tag(), "[DATA WARNING] There is no speak data"); 
+               SLOG(LOG_WARN, tts_tag(), "[DATA WARNING] There is no speak data"); 
 #endif 
                return -1;
        }
@@ -343,12 +343,12 @@ int ttsd_data_add_sound_data(int uid, sound_data_s* data)
        index = ttsd_data_is_client(uid);
 
        if(index < 0) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == data) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] sound data is NULL");
+               SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] sound data is NULL");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
        /* mutex is locked */
@@ -372,7 +372,7 @@ int ttsd_data_get_sound_data(int uid, sound_data_s** data)
        index = ttsd_data_is_client(uid);
 
        if (index < 0)  {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -381,7 +381,7 @@ int ttsd_data_get_sound_data(int uid, sound_data_s** data)
 
        if (0 == g_app_list[index].m_wav_data.size()) {
 #ifdef DATA_DEBUG
-               SLOG(LOG_DEBUG, get_tag(), "[DATA] There is no wav data");
+               SLOG(LOG_DEBUG, tts_tag(), "[DATA] There is no wav data");
 #endif
                /* mutex is unlocked */
                pthread_mutex_unlock(&g_sound_data_mutex);
@@ -408,7 +408,7 @@ int ttsd_data_get_sound_data_size(int uid)
        index = ttsd_data_is_client(uid);
 
        if (index < 0)  {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -421,7 +421,7 @@ int ttsd_data_clear_data(int uid)
 
        index = ttsd_data_is_client(uid);
        if (index < 0) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -436,7 +436,7 @@ int ttsd_data_clear_data(int uid)
                }
 
                if (NULL != temp_speak) {
-                       SLOG(LOG_DEBUG, get_tag(), "[DEBUG] utt(%d), text(%s), lang(%s), vctype(%d) speed(%d)", 
+                       SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] utt(%d), text(%s), lang(%s), vctype(%d) speed(%d)", 
                                        temp_speak->utt_id, temp_speak->text, temp_speak->lang, temp_speak->vctype, temp_speak->speed);
 
                        if (NULL != temp_speak->text) {
@@ -464,7 +464,7 @@ int ttsd_data_clear_data(int uid)
                }
 
                if (NULL != temp_sound) {
-                       SLOG(LOG_ERROR, get_tag(), "[DEBUG][%p] uid(%d), event(%d) data(%p) size(%d) rate(%d) utt(%d)", 
+                       SLOG(LOG_ERROR, tts_tag(), "[DEBUG][%p] uid(%d), event(%d) data(%p) size(%d) rate(%d) utt(%d)", 
                                temp_sound, uid, temp_sound->event, temp_sound->data, temp_sound->data_size, temp_sound->rate, temp_sound->utt_id);
 
                        if (NULL != temp_sound->data) {
@@ -489,7 +489,7 @@ int ttsd_data_get_client_state(int uid, app_state_e* state)
 
        index = ttsd_data_is_client(uid);
        if (index < 0)  {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -504,7 +504,7 @@ int ttsd_data_set_client_state(int uid, app_state_e state)
 
        index = ttsd_data_is_client(uid);
        if (index < 0)  {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -513,7 +513,7 @@ int ttsd_data_set_client_state(int uid, app_state_e state)
                int vsize = g_app_list.size();
                for (int i = 0; i < vsize; i++) {
                        if(g_app_list[i].state == APP_STATE_PLAYING) {
-                               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] A playing client has already existed.");       
+                               SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] A playing client has already existed.");
                                return -1;
                        }
                }
@@ -530,7 +530,7 @@ int ttsd_data_get_current_playing()
 
        for (int i = 0; i < vsize; i++) {
                if (APP_STATE_PLAYING == g_app_list[i].state) {
-                       SLOG(LOG_DEBUG, get_tag(), "[DATA] uid(%d) is playing", g_app_list[i].uid);
+                       SLOG(LOG_DEBUG, tts_tag(), "[DATA] uid(%d) is playing", g_app_list[i].uid);
                        return g_app_list[i].uid;
                }
        }
@@ -541,7 +541,7 @@ int ttsd_data_get_current_playing()
 int ttsd_data_foreach_clients(ttsd_data_get_client_cb callback, void* user_data)
 {
        if (NULL == callback) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] input data is NULL!!");
+               SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] input data is NULL!!");
                return -1;
        }
 
@@ -565,7 +565,7 @@ int ttsd_data_foreach_clients(ttsd_data_get_client_cb callback, void* user_data)
        }
 
        for (i = 0;i < vsize;i++) {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[%dth] pid(%d), uid(%d), state(%d)", i, temp_app_list[i].pid, temp_app_list[i].uid, temp_app_list[i].state);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[%dth] pid(%d), uid(%d), state(%d)", i, temp_app_list[i].pid, temp_app_list[i].uid, temp_app_list[i].state);
                if (false == callback(temp_app_list[i].pid, temp_app_list[i].uid, temp_app_list[i].state, user_data)) {
                        break;
                }
@@ -584,7 +584,7 @@ bool ttsd_data_is_uttid_valid(int uid, int uttid)
 
        index = ttsd_data_is_client(uid);
        if (index < 0)  {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -628,7 +628,7 @@ int ttsd_data_save_error_log(int uid, FILE* fp)
        /* pid */
        pid = ttsd_data_get_pid(uid);
        if (0 > pid) {
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to get pid");
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get pid");
        } else {
                fprintf(fp, "pid - %d", pid);
        }
@@ -636,7 +636,7 @@ int ttsd_data_save_error_log(int uid, FILE* fp)
        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");
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get app state");
        } else {
                fprintf(fp, "app state - %d", state);
        }
@@ -646,7 +646,7 @@ int ttsd_data_save_error_log(int uid, FILE* fp)
 
        index = ttsd_data_is_client(uid);
        if (0 > index) {
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] Invalid client");
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid client");
                return -1;
        }
 
@@ -656,7 +656,7 @@ int ttsd_data_save_error_log(int uid, FILE* fp)
        i = 0;
        std::list<sound_data_s*>::iterator iter;
        for (iter = g_app_list[index].m_wav_data.begin(); iter != g_app_list[index].m_wav_data.end(); iter++) {
-               SLOG(LOG_DEBUG, get_tag(), "[%dth][%p] data(%p) data size(%ld), uttid(%d), type(%d)",
+               SLOG(LOG_DEBUG, tts_tag(), "[%dth][%p] data(%p) data size(%ld), uttid(%d), type(%d)",
                        i, *iter, (*iter)->data, (*iter)->data_size, (*iter)->utt_id, (*iter)->audio_type);
                i++;
        }
@@ -669,7 +669,7 @@ int ttsd_data_save_error_log(int uid, FILE* fp)
        i = 0;
        std::list<speak_data_s*>::iterator iter_speak;
        for (iter_speak = g_app_list[index].m_speak_data.begin(); iter_speak != g_app_list[index].m_speak_data.end(); iter_speak++) {
-               SLOG(LOG_DEBUG, get_tag(), "[%dth][%p] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s)",
+               SLOG(LOG_DEBUG, tts_tag(), "[%dth][%p] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s)",
                        i, *iter_speak, (*iter_speak)->lang, (*iter_speak)->vctype, (*iter_speak)->speed, (*iter_speak)->utt_id, (*iter_speak)->text);
                i++;
        }
index 2e2e187..8860968 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2016 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
@@ -15,7 +15,7 @@
 #ifndef __TTSD_DATA_H_
 #define __TTSD_DATA_H_
 
-#include "ttsp.h"
+#include "ttse.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -41,8 +41,8 @@ typedef struct {
        void*           data;
        unsigned int    data_size;
 
-       ttsp_result_event_e     event;
-       ttsp_audio_type_e       audio_type;
+       ttse_result_event_e     event;
+       ttse_audio_type_e       audio_type;
        int                     rate;
        int                     channels;
 } sound_data_s;
index 60b2799..19b322a 100644 (file)
@@ -60,7 +60,7 @@ int ttsdc_send_hello(int pid, int uid)
 {
 #if 0
        if (NULL == g_conn_sender) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available");
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
                return -1;
        }
 
@@ -81,10 +81,10 @@ int ttsdc_send_hello(int pid, int uid)
                TTSD_METHOD_HELLO);
 
        if (NULL == msg) {
-               SLOG(LOG_ERROR, get_tag(), "<<<< [Dbus ERROR] Fail to create hello message : uid(%d)", uid);
+               SLOG(LOG_ERROR, tts_tag(), "<<<< [Dbus ERROR] Fail to create hello message : uid(%d)", uid);
                return -1;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "<<<< [Dbus] Send hello message : uid(%d)", uid);
+               SLOG(LOG_DEBUG, tts_tag(), "<<<< [Dbus] Send hello message : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
@@ -98,7 +98,7 @@ int ttsdc_send_hello(int pid, int uid)
        result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
        dbus_message_unref(msg);
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] Send error (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Send error (%s)", err.message);
                dbus_error_free(&err);
        }
 
@@ -106,14 +106,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, get_tag(), ">>>> [Dbus] Get arguments error (%s)", err.message);
+                       SLOG(LOG_ERROR, tts_tag(), ">>>> [Dbus] Get arguments error (%s)", err.message);
                        dbus_error_free(&err);
                        result = -1;
                }
 
                dbus_message_unref(result_msg);
        } else {
-               SLOG(LOG_DEBUG, get_tag(), ">>>> [Dbus] Result message is NULL. Client is not available");
+               SLOG(LOG_DEBUG, tts_tag(), ">>>> [Dbus] Result message is NULL. Client is not available");
                result = 0;
        }
 
@@ -125,7 +125,7 @@ int ttsdc_send_hello(int pid, int uid)
 int ttsdc_send_message(int pid, int uid, int data, const char *method)
 {
        if (NULL == g_conn_sender) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available");
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
                return -1;
        }
 
@@ -138,19 +138,19 @@ int ttsdc_send_message(int pid, int uid, int data, const char *method)
                method);                        /* name of the signal */
 
        if (NULL == msg) {
-               SLOG(LOG_ERROR, get_tag(), "<<<< [Dbus ERROR] Fail to create message : %s", method);
+               SLOG(LOG_ERROR, tts_tag(), "<<<< [Dbus ERROR] Fail to create message : %s", method);
                return -1;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "<<<< [Dbus] Send %s message : uid(%d) data(%d)", method, uid, data);
+               SLOG(LOG_DEBUG, tts_tag(), "<<<< [Dbus] Send %s message : uid(%d) data(%d)", method, uid, data);
        }
 
        dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &data, DBUS_TYPE_INVALID);
 
        if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to Send");
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to Send");
                return -1;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Dbus] SUCCESS Send");
+               SLOG(LOG_DEBUG, tts_tag(), "[Dbus] SUCCESS Send");
                dbus_connection_flush(g_conn_sender);
        }
 
@@ -177,7 +177,7 @@ int ttsdc_send_set_state_message(int pid, int uid, int state)
 int ttsdc_send_error_message(int pid, int uid, int uttid, int reason, char* err_msg)
 {
        if (NULL == g_conn_sender) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available");
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
                return -1;
        }
 
@@ -190,7 +190,7 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason, char* err_
                TTSD_METHOD_ERROR);             /* name of the signal */
 
        if (NULL == msg) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to create error message : uid(%d)", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to create error message : uid(%d)", uid);
                return -1;
        }
 
@@ -204,9 +204,9 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason, char* err_
        dbus_message_set_no_reply(msg, TRUE);
 
        if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] <<<< error message : Out Of Memory !");
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] <<<< error message : Out Of Memory !");
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "<<<< Send error message : uid(%d), reason(%s), uttid(%d), err_msg(%s)",
+               SLOG(LOG_DEBUG, tts_tag(), "<<<< Send error message : uid(%d), reason(%s), uttid(%d), err_msg(%s)",
                         uid, __ttsd_get_error_code(reason), uttid, (NULL == err_msg) ? "NULL" : err_msg);
                dbus_connection_flush(g_conn_sender);
        }
@@ -226,7 +226,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        msg = dbus_connection_pop_message(g_conn_listener);
 
        if (true != dbus_connection_get_is_connected(g_conn_listener)) {
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] Connection is disconnected");
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Connection is disconnected");
                return ECORE_CALLBACK_RENEW;
        }
 
@@ -289,25 +289,25 @@ int ttsd_dbus_open_connection()
        /* Create connection for sender */
        g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail dbus_bus_get : %s", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail dbus_bus_get : %s", err.message);
                dbus_error_free(&err);
        }
 
        if (NULL == g_conn_sender) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to get dbus connection sender");
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to get dbus connection sender");
                return -1;
        }
 
        /* connect to the bus and check for errors */
        g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail dbus_bus_get : %s", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail dbus_bus_get : %s", err.message);
                dbus_error_free(&err);
                return -1;
        }
 
        if (NULL == g_conn_listener) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to get dbus connection");
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to get dbus connection");
                return -1;
        }
 
@@ -340,12 +340,12 @@ int ttsd_dbus_open_connection()
        /* request our name on the bus and check for errors */
        ret = dbus_bus_request_name(g_conn_listener, g_service_name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
        if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to be primary owner");
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to be primary owner");
                return -1;
        }
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to request dbus name : %s", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to request dbus name : %s", err.message);
                dbus_error_free(&err);
                return -1;
        }
@@ -359,7 +359,7 @@ int ttsd_dbus_open_connection()
        dbus_connection_flush(g_conn_listener);
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_add_match() : %s", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] dbus_bus_add_match() : %s", err.message);
                return -1;
        }
 
@@ -368,7 +368,7 @@ int ttsd_dbus_open_connection()
 
        g_dbus_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL);
        if (NULL == g_dbus_fd_handler) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to get fd handler");
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to get fd handler");
                return -1;
        }
 
@@ -387,7 +387,7 @@ int ttsd_dbus_close_connection()
 
        dbus_bus_release_name(g_conn_listener, g_service_name, &err);
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_release_name() : %s", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] dbus_bus_release_name() : %s", err.message);
                dbus_error_free(&err);
        }
 
index 65fcd58..fca0b6e 100644 (file)
@@ -24,20 +24,20 @@ extern int ttsd_data_get_pid(const int uid);
 */
 int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
 {
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS Hello");
+       SLOG(LOG_DEBUG, tts_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, get_tag(), "[OUT ERROR] Out Of Memory!");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to create reply message!!");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message!!");
        }
 
        return 0;
@@ -57,15 +57,15 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                DBUS_TYPE_INT32, &uid,
                DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS INITIALIZE");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS INITIALIZE");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts initialize : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts initialize : get arguments error (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
 
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts initialize : pid(%d), uid(%d)", pid , uid);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts initialize : pid(%d), uid(%d)", pid , uid);
                ret =  ttsd_server_initialize(pid, uid, &credential_needed);
        }
 
@@ -73,7 +73,7 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
        reply = dbus_message_new_method_return(msg);
 
        int temp = (int)credential_needed;
-       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, (int)credential_needed);
+       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, (int)credential_needed);
        if (NULL != reply) {
                dbus_message_append_args(reply,
                        DBUS_TYPE_INT32, &ret,
@@ -81,19 +81,19 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, credential_needed);
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, credential_needed);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : result(%d)", ret);
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : result(%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : Out Of Memory!");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : Fail to create reply message!!");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts initialize : Fail to create reply message!!");
        }
 
        return 0;
@@ -109,14 +109,14 @@ 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, get_tag(), ">>>>> TTS FINALIZE");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS FINALIZE");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts finalize : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts finalize : get arguments error (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts finalize : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts finalize : uid(%d)", uid);
                ret =  ttsd_server_finalize(uid);
        }
 
@@ -127,19 +127,19 @@ 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, get_tag(), "[OUT] tts finalize : result(%d)", ret);
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts finalize : result(%d)", ret);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : result(%d)", ret);
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : result(%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : Out Of Memory!");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : Fail to create reply message!!");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts finalize : Fail to create reply message!!");
        }
 
        return 0;
@@ -156,14 +156,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, get_tag(), ">>>>> TTS GET VOICES");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET VOICES");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts get supported voices : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get supported voices : get arguments error (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] get supported voices : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] get supported voices : uid(%d)", uid);
                ret = ttsd_server_get_support_voices(uid, &voice_list);
        }
 
@@ -182,7 +182,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, get_tag(), "[OUT ERROR] tts supported voices : Fail to append type");
+                               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : Fail to append type");
                                ret = TTSD_ERROR_OPERATION_FAILED;
                        } else {
 
@@ -209,19 +209,19 @@ int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg)
                                        iter = g_list_first(voice_list);
                                }
                        }
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts supported voices : result(%d)", ret);
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts supported voices : result(%d)", ret);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : result(%d)", ret);
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : result(%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] error : Out Of Memory!");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] error : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : Fail to create reply message!!");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts supported voices : Fail to create reply message!!");
        }
 
        return 0;
@@ -239,14 +239,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, get_tag(), ">>>>> TTS GET DEFAULT VOICE");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET DEFAULT VOICE");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts get default voice : Get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get default voice : Get arguments error (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts get default voice : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get default voice : uid(%d)", uid);
                ret = ttsd_server_get_current_voice(uid, &lang, &voice_type);
        }
 
@@ -261,22 +261,22 @@ int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg)
                                DBUS_TYPE_STRING, &lang,
                                DBUS_TYPE_INT32, &voice_type,
                                DBUS_TYPE_INVALID);
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[OUT] tts default voice : lang(%s), vctype(%d)", lang, voice_type);
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts default voice : lang(%s), vctype(%d)", lang, voice_type);
                } else {
                        dbus_message_append_args(reply,
                                DBUS_TYPE_INT32, &ret,
                                DBUS_TYPE_INVALID);
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : result(%d)", ret); 
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : result(%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : Out Of Memory!");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : Fail to create reply message!!");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts default voice : Fail to create reply message!!");
        }
 
        if (NULL != lang)       free(lang);
@@ -302,16 +302,16 @@ int ttsd_dbus_server_add_text(DBusConnection* conn, DBusMessage* msg)
                DBUS_TYPE_STRING, &credential,
                DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS ADD TEXT");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD TEXT");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts add text : Get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts add text : Get arguments error (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
                
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), uttid(%d), credential(%s)", 
-                       uid, text, lang, voicetype, speed, uttid, credential); 
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), uttid(%d), credential(%s)", 
+                       uid, (NULL == text) ? "NULL" : text, (NULL == lang) ? "NULL" : lang, voicetype, speed, uttid, (NULL == credential) ? "NULL" : credential);
                ret =  ttsd_server_add_queue(uid, text, lang, voicetype, speed, uttid, credential);
        }
 
@@ -322,23 +322,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, get_tag(), "[OUT] tts add text : result(%d)", ret);
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts add text : result(%d)", ret);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : result(%d)", ret);
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : result(%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : Out Of Memory!");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : Fail to create reply message!!");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts add text : Fail to create reply message!!");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
+       SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
 
        return 0;
 }
@@ -357,14 +357,14 @@ int ttsd_dbus_server_play(DBusConnection* conn, DBusMessage* msg)
                DBUS_TYPE_STRING, &credential,
                DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS PLAY");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PLAY");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts play : Get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts play : Get arguments error (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts play : uid(%d), credential(%s)", uid, credential);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts play : uid(%d), credential(%s)", uid, (NULL == credential) ? "NULL" : credential);
                ret =  ttsd_server_play(uid, credential);
        }
 
@@ -375,23 +375,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, get_tag(), "[OUT] tts play : result(%d)", ret);
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts play : result(%d)", ret);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : result(%d)", ret);
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : result(%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : Out Of Memory!");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : Fail to create reply message!!");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts play : Fail to create reply message!!");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
+       SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
 
        return 0;
 }
@@ -407,14 +407,14 @@ int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
                DBUS_TYPE_INT32, &uid, 
                DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS STOP");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS STOP");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts stop : Get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts stop : Get arguments error (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts stop : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts stop : uid(%d)", uid);
                ret = ttsd_server_stop(uid);
        }
 
@@ -427,23 +427,23 @@ int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts stop : result(%d)", ret);
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts stop : result(%d)", ret);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : result(%d)", ret);
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : result(%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : Out Of Memory!");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : Fail to create reply message!!");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts stop : Fail to create reply message!!");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
+       SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
 
        return 0;
 }
@@ -460,14 +460,14 @@ int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg)
                DBUS_TYPE_INT32, &uid, 
                DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS PAUSE");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS PAUSE");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts pause : Get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts pause : Get arguments error (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts pause : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts pause : uid(%d)", uid);
                ret = ttsd_server_pause(uid, &uttid);
        }
 
@@ -480,23 +480,23 @@ int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts pause : result(%d)", ret);
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts pause : result(%d)", ret);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : result(%d)", ret);
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : result(%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : Out Of Memory!");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : Fail to create reply message!!");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts pause : Fail to create reply message!!");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
+       SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
 
        return 0;
 }
@@ -516,14 +516,14 @@ int ttsd_dbus_server_set_private_data(DBusConnection* conn, DBusMessage* msg)
                DBUS_TYPE_STRING, &data,
                DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS set private data");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS set private data");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] tts set private data(%d)", uid);
+               SLOG(LOG_DEBUG, tts_tag(), "[IN] tts set private data(%d)", uid);
                ret = ttsd_server_set_private_data(uid, key, data);
        }
 
@@ -536,23 +536,23 @@ int ttsd_dbus_server_set_private_data(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts set private data : (%d)", ret);
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts set private data : (%d)", ret);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts set private data : (%d)", ret);
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts set private data : (%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to send reply");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to send reply");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to create reply message");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "");
+       SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+       SLOG(LOG_DEBUG, tts_tag(), "");
 
        return 0;
 }
@@ -571,14 +571,14 @@ int ttsd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg)
                DBUS_TYPE_STRING, &key,
                DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS get private data");
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS get private data");
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] tts get private data(%d)", uid);
+               SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get private data(%d)", uid);
                ret = ttsd_server_get_private_data(uid, key, &data);
        }
 
@@ -592,25 +592,28 @@ int ttsd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts get private data : Result(%d), data(%s)", ret, (NULL == data) ? "NULL" : data);
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts get private data : Result(%d), data(%s)", ret, (NULL == data) ? "NULL" : data);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts get private data : (%d)", ret);
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get private data : (%d)", ret);
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to send reply");
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to send reply");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to create reply message");
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] Fail to create reply message");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "");
+       SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+       SLOG(LOG_DEBUG, tts_tag(), "");
 
-       if (NULL != data)       free(data);
+       if (NULL != data) {
+               free(data);
+               data = NULL;
+       }
 
        return 0;
 }
index d957a10..d0eec55 100644 (file)
 /*
 * Internal data structure
 */
-typedef struct {
+typedef struct _ttsengine_info {
        /* base info */
        char*   engine_uuid;
-       char*   engine_name;
        char*   engine_path;
+       char*   engine_name;
+       char*   engine_setting_path;
 
        /* info for using engine load */
-       bool    is_set;
        bool    is_loaded;
-       bool    need_network;
-       void    *handle;
+       bool    use_network;
+
+       tts_engine_callback_s* callbacks;
 
        /* engine base setting */
        char*   default_lang;
        int     default_vctype;
        int     default_speed;
        int     default_pitch;
-
-       ttspe_funcs_s*  pefuncs;
-       ttspd_funcs_s*  pdfuncs;
-
-       int (*ttsp_load_engine)(const ttspd_funcs_s* pdfuncs, ttspe_funcs_s* pefuncs);
-       int (*ttsp_unload_engine)();
-} ttsengine_s;
-
-typedef struct {
-       char*   engine_uuid;
-       char*   engine_path;
-       char*   engine_name;
-       char*   setting_ug_path;
-       bool    use_network;
 } ttsengine_info_s;
 
 typedef struct {
@@ -71,34 +58,11 @@ typedef struct {
 /** Init flag */
 static bool g_agent_init;
 
-/** TTS engine list */
-static GList *g_engine_list;
-
 /** Current engine information */
-static ttsengine_s g_cur_engine;
+static ttsengine_info_s* g_engine_info = NULL;
 
 /** Current voice information */
-static GSList* g_cur_voices;
-
-/** Result callback function */
-static synth_result_callback g_result_cb;
-
-
-/** Set current engine */
-static int __internal_set_current_engine(const char* engine_uuid);
-
-/** Check engine id */
-static int __internal_check_engine_id(const char* engine_uuid);
-
-/** Update engine list */
-static int __internal_update_engine_list();
-
-/** Get engine info */
-static int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info);
-
-/** Callback function for result */
-bool __result_cb(ttsp_result_event_e event, const void* data, unsigned int data_size, 
-                ttsp_audio_type_e audio_type, int rate, void *user_data);
+static GSList* g_cur_voices = NULL;
 
 /** Callback function for voice list */
 static bool __supported_voice_cb(const char* language, int type, void* user_data);
@@ -106,557 +70,112 @@ static bool __supported_voice_cb(const char* language, int type, void* user_data
 /** Free voice list */
 static void __free_voice_list(GList* voice_list);
 
-/** Callback function for engine info */
-static void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name,
-                     bool use_network, void* user_data);
-
-
-/** Print list */
-static int ttsd_print_enginelist();
-
 static int ttsd_print_voicelist();
 
-static const char* __ttsd_get_engine_error_code(ttsp_error_e err)
+/** Get engine info */
+int __internal_get_engine_info(ttse_request_callback_s* callback);
+
+static const char* __ttsd_get_engine_error_code(ttse_error_e err)
 {
        switch (err) {
-       case TTSP_ERROR_NONE:                   return "TTSP_ERROR_NONE";
-       case TTSP_ERROR_OUT_OF_MEMORY:          return "TTSP_ERROR_OUT_OF_MEMORY";
-       case TTSP_ERROR_IO_ERROR:               return "TTSP_ERROR_IO_ERROR";
-       case TTSP_ERROR_INVALID_PARAMETER:      return "TTSP_ERROR_INVALID_PARAMETER";
-       case TTSP_ERROR_OUT_OF_NETWORK:         return "TTSP_ERROR_OUT_OF_NETWORK";
-       case TTSP_ERROR_INVALID_STATE:          return "TTSP_ERROR_INVALID_STATE";
-       case TTSP_ERROR_INVALID_VOICE:          return "TTSP_ERROR_INVALID_VOICE";
-       case TTSP_ERROR_OPERATION_FAILED:       return "TTSP_ERROR_OPERATION_FAILED";
+       case TTSE_ERROR_NONE:                   return "TTSE_ERROR_NONE";
+       case TTSE_ERROR_OUT_OF_MEMORY:          return "TTSE_ERROR_OUT_OF_MEMORY";
+       case TTSE_ERROR_IO_ERROR:               return "TTSE_ERROR_IO_ERROR";
+       case TTSE_ERROR_INVALID_PARAMETER:      return "TTSE_ERROR_INVALID_PARAMETER";
+       case TTSE_ERROR_NETWORK_DOWN:           return "TTSE_ERROR_NETWORK_DOWN";
+       case TTSE_ERROR_INVALID_STATE:          return "TTSE_ERROR_INVALID_STATE";
+       case TTSE_ERROR_INVALID_VOICE:          return "TTSE_ERROR_INVALID_VOICE";
+       case TTSE_ERROR_OPERATION_FAILED:       return "TTSE_ERROR_OPERATION_FAILED";
        default:
                return "Invalid error code";
        }
 }
 
-int ttsd_engine_agent_init(synth_result_callback result_cb)
-{
-       /* initialize static data */
-       if (result_cb == NULL) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] invalid parameter");
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       g_result_cb = result_cb;
-
-       g_cur_engine.engine_uuid = NULL;
-       g_cur_engine.engine_name = NULL;
-       g_cur_engine.engine_path = NULL;
-
-       g_cur_engine.is_set = false;
-       g_cur_engine.handle = NULL;
-       g_cur_engine.pefuncs = (ttspe_funcs_s*)calloc(1, sizeof(ttspe_funcs_s));
-       if (NULL == g_cur_engine.pefuncs) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to allocate memory");
-               return TTSP_ERROR_OUT_OF_MEMORY;
-       }
-
-       g_cur_engine.pdfuncs = (ttspd_funcs_s*)calloc(1, sizeof(ttspd_funcs_s));
-       if (NULL == g_cur_engine.pdfuncs) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to allocate memory");
-               free(g_cur_engine.pefuncs);
-               g_cur_engine.pefuncs = NULL;
-               return TTSP_ERROR_OUT_OF_MEMORY;
-       }
-
-       g_agent_init = true;
-
-       if (0 != ttsd_config_get_default_voice(&(g_cur_engine.default_lang), &(g_cur_engine.default_vctype))) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] There is No default voice in config");
-               /* Set default voice */
-               g_cur_engine.default_lang = strdup(TTS_BASE_LANGUAGE);
-               g_cur_engine.default_vctype = TTSP_VOICE_TYPE_FEMALE;
-       }
-
-       if (0 != ttsd_config_get_default_speed(&(g_cur_engine.default_speed))) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] There is No default speed in config");
-               g_cur_engine.default_speed = TTS_SPEED_NORMAL;
-       }
-
-       if (0 != ttsd_config_get_default_pitch(&(g_cur_engine.default_pitch))) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] There is No default pitch in config");
-               g_cur_engine.default_pitch = TTS_PITCH_NORMAL;
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Initialize Engine Agent");
-
-       return 0;
-}
-
-int ttsd_engine_agent_release()
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       /* unload current engine */
-       ttsd_engine_agent_unload_current_engine();
-
-       /* release engine list */
-       GList *iter = NULL;
-       ttsengine_info_s *data = NULL;
-
-       if (g_list_length(g_engine_list) > 0) {
-               /* Get a first item */
-               iter = g_list_first(g_engine_list);
-               while (NULL != iter) {
-                       /* Get data from item */
-                       data = iter->data;
-                       iter = g_list_remove(iter, data);
-
-                       if (NULL != data) {
-                               if (NULL != data->engine_uuid)          free(data->engine_uuid);
-                               if (NULL != data->engine_name)          free(data->engine_name);
-                               if (NULL != data->setting_ug_path)      free(data->setting_ug_path);
-                               if (NULL != data->engine_path)          free(data->engine_path);
-                               free(data);
-                       }
-               }
-       }
-       g_list_free(iter);
-
-       /* release current engine data */
-       if (g_cur_engine.engine_uuid != NULL)   free(g_cur_engine.engine_uuid);
-       if (g_cur_engine.engine_name != NULL)   free(g_cur_engine.engine_name);
-       if (g_cur_engine.engine_path != NULL)   free(g_cur_engine.engine_path);
-
-       if (g_cur_engine.pefuncs != NULL)       free(g_cur_engine.pefuncs);
-       if (g_cur_engine.pdfuncs != NULL)       free(g_cur_engine.pdfuncs);
-       if (g_cur_engine.default_lang != NULL)  free(g_cur_engine.default_lang);
-       g_result_cb = NULL;
-       g_agent_init = false;
-
-       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Release Engine Agent");
-
-       return 0;
-}
-
-int ttsd_engine_agent_initialize_current_engine()
-{
-       if (false == g_agent_init) {
-               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, get_tag(), "[Engine Agent WARNING] No engine error");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       /* 2. get current engine from config */
-       char* cur_engine_uuid = NULL;
-       bool is_get_engineid_from_config = false;
-
-       if (0 != ttsd_config_get_default_engine(&cur_engine_uuid)) {
-               /*not set current engine */
-               /*set system default engine*/
-               GList *iter = NULL;
-               ttsengine_info_s *data = NULL;
-
-               if (g_list_length(g_engine_list) > 0) {
-                       iter = g_list_first(g_engine_list);
-                       if (NULL == iter) {
-                               SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Fail to get a engine of engine list");
-                               return TTSD_ERROR_OPERATION_FAILED;
-                       }
-                       data = iter->data;
-
-                       if (NULL != data) {
-                               if (NULL != data->engine_uuid) {
-                                       cur_engine_uuid = strdup(data->engine_uuid);
-                                       ttsd_config_set_default_engine(cur_engine_uuid);
-                               } else {
-                                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Data of current engine is corrupt");
-                                       return TTSD_ERROR_OPERATION_FAILED;
-                               }
-                       }
-               } else {
-                       SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Fail to get a engine of engine list");
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
-
-               is_get_engineid_from_config = false;
-       } else {
-               is_get_engineid_from_config = true;
-       }
-
-       if (NULL == cur_engine_uuid) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Current engine id is NULL");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       /* check whether cur engine uuid is valid or not. */
-       if (0 != __internal_check_engine_id(cur_engine_uuid)) {
-               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, get_tag(), "[Engine Agent ERROR] NO TTS Engine !!");
-                       if (NULL != cur_engine_uuid) {
-                               free(cur_engine_uuid);
-                               cur_engine_uuid = NULL;
-                       }
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
-
-               if (NULL == iter) {
-                       SLOG(LOG_WARN, get_tag(), "[Engine Agent ERROR] No valid TTS Engine");
-                       if (NULL != cur_engine_uuid) {
-                               free(cur_engine_uuid);
-                               cur_engine_uuid = NULL;
-                       }
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
-
-               if (cur_engine_uuid != NULL) {
-                       free(cur_engine_uuid);
-                       cur_engine_uuid = NULL;
-               }
-               ttsengine_info_s *data = NULL;
-               data = iter->data;
-
-               if (NULL == data || NULL == data->engine_uuid) {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No valid TTS Engine");
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
-
-               cur_engine_uuid = strdup(data->engine_uuid);
-
-               is_get_engineid_from_config = false;
-       }
-
-       if (NULL != cur_engine_uuid)
-               SECURE_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, get_tag(), "[Engine Agent ERROR] fail to set current engine ");
-               if (NULL != cur_engine_uuid)    free(cur_engine_uuid);
-               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, get_tag(), "[Engine Agent ERROR] fail to set id to config");
-               }
-       }
-
-       if (NULL != cur_engine_uuid)    free(cur_engine_uuid);
-
-       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set current engine");
-
-       return 0;
-}
-
-static int __internal_check_engine_id(const char* engine_uuid)
-{
-       GList *iter = NULL;
-       ttsengine_s *data = NULL;
-
-       if (g_list_length(g_engine_list) > 0) {
-               iter = g_list_first(g_engine_list);
-
-               while (NULL != iter) {
-                       data = iter->data;
-
-                       if (0 == strncmp(engine_uuid, data->engine_uuid, strlen(data->engine_uuid)))
-                               return 0;
-
-                       iter = g_list_next(iter);
-               }
-       }
-
-       return -1;
-}
-
-void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name, 
-                            bool use_network, void* user_data)
+int ttsd_engine_agent_init()
 {
-       ttsengine_info_s* temp = (ttsengine_info_s*)user_data;
-
-       if (NULL != engine_uuid)
-               temp->engine_uuid = strdup(engine_uuid);
-
-       if (NULL != engine_name)
-               temp->engine_name = strdup(engine_name);
-
-       if (NULL != setting_ug_name)
-               temp->setting_ug_path = strdup(setting_ug_name);
-
-       temp->use_network = use_network;
-       return;
-}
-
-static int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info)
-{
-       char *error;
-       void* handle;
-
-       handle = dlopen(filepath, RTLD_LAZY);
-
-       if (!handle) {
-               SECURE_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) {
-               SECURE_SLOG(LOG_WARN, get_tag(), "[Engine Agent] Fail to open ttsp_load_engine : path(%s) message(%s)", filepath, error);
-               dlclose(handle);
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       dlsym(handle, "ttsp_unload_engine");
-       if ((error = dlerror()) != NULL) {
-               SECURE_SLOG(LOG_WARN, get_tag(), "[Engine Agent] Fail to open ttsp_unload_engine : path(%s) message(%s)", filepath, error);
-               dlclose(handle);
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       int (*get_engine_info)(ttsp_engine_info_cb callback, void* user_data);
-
-       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, get_tag(), "[Engine Agent] Fail to open ttsp_get_engine_info() :path(%s) message(%s)", filepath, error);
-               dlclose(handle);
+       if (true == g_agent_init) {
+               SLOG(LOG_WARN, tts_tag(), "[Engine Agent] Already initialized");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        ttsengine_info_s* temp;
        temp = (ttsengine_info_s*)calloc(1, sizeof(ttsengine_info_s));
        if (NULL == temp) {
-               SLOG(LOG_WARN, get_tag(), "[Engine Agent] Fail to alloc memory");
-               dlclose(handle);
+               SLOG(LOG_WARN, tts_tag(), "[Engine Agent] Fail to alloc memory");
                return TTSD_ERROR_OUT_OF_MEMORY;
        }
 
-       /* get engine info */
-       if (0 != get_engine_info(&__engine_info_cb, (void*)temp)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get engine info");
-               dlclose(handle);
-               free(temp);
-               return TTSD_ERROR_OPERATION_FAILED;
+       if (0 != ttsd_config_get_default_voice(&(temp->default_lang), &(temp->default_vctype))) {
+               SLOG(LOG_WARN, tts_tag(), "[Server WARNING] There is No default voice in config");
+               /* Set default voice */
+               temp->default_lang = strdup(TTS_BASE_LANGUAGE);
+               temp->default_vctype = TTSE_VOICE_TYPE_FEMALE;
        }
 
-       /* close engine */
-       dlclose(handle);
+       SLOG(LOG_DEBUG, tts_tag(), "[Server DEBUG] language(%s), type(%d)", temp->default_lang, temp->default_vctype);
 
-       if (TTSD_MODE_SCREEN_READER == ttsd_get_mode() && true == temp->use_network) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent WARNING] %s is invalid because of network based", temp->engine_name);
-               if (NULL != temp->engine_uuid)          free(temp->engine_uuid);
-               if (NULL != temp->engine_name)          free(temp->engine_name);
-               if (NULL != temp->setting_ug_path)      free(temp->setting_ug_path);
-               free(temp);
-               return TTSD_ERROR_OPERATION_FAILED;
+       if (0 != ttsd_config_get_default_speed(&(temp->default_speed))) {
+               SLOG(LOG_WARN, tts_tag(), "[Server WARNING] There is No default speed in config");
+               temp->default_speed = TTS_SPEED_NORMAL;
        }
 
-       temp->engine_path = strdup(filepath);
+       if (0 != ttsd_config_get_default_pitch(&(temp->default_pitch))) {
+               SLOG(LOG_WARN, tts_tag(), "[Server WARNING] There is No default pitch in config");
+               temp->default_pitch = TTS_PITCH_NORMAL;
+       }
 
-       SLOG(LOG_DEBUG, get_tag(), "----- Valid engine");
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Engine uuid : %s", temp->engine_uuid);
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Engine name : %s", temp->engine_name);
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Setting path : %s", temp->setting_ug_path);
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Engine path : %s", temp->engine_path);
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Use network : %s", temp->use_network ? "true" : "false");
-       SLOG(LOG_DEBUG, get_tag(), "-----");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
+       temp->is_loaded = false;
+       g_engine_info = temp;
 
-       *info = temp;
+       g_agent_init = true;
 
+       SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Initialize Engine Agent");
        return 0;
 }
 
-static int __internal_update_engine_list()
+int ttsd_engine_agent_release()
 {
-       /* relsease engine list */
-       GList *iter = NULL;
-       ttsengine_info_s *data = NULL;
-
-       if (g_list_length(g_engine_list) > 0) {
-               iter = g_list_first(g_engine_list);
-
-               while (NULL != iter) {
-                       data = iter->data;
-
-                       if (data != NULL)       free(data);
-                       g_engine_list = g_list_remove_link(g_engine_list, iter);
-                       g_list_free(iter);
-                       iter = g_list_first(g_engine_list);
-               }
-       }
-
-       /* get file name from engine directory and get engine information from each filename */
-       DIR *dp = NULL;
-       int ret = -1;
-       struct dirent entry;
-       struct dirent *dirp = NULL;
-       dp = opendir(TTS_DEFAULT_ENGINE);
-
-       if (dp != NULL) {
-               do {
-                       ret = readdir_r(dp, &entry, &dirp);
-                       if (0 != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to read directory");
-                               break;
-                       }
-
-                       if (NULL != dirp) {
-                               ttsengine_info_s* info;
-                               char* filepath = NULL;
-                               int file_size;
-
-                               file_size = strlen(TTS_DEFAULT_ENGINE) + strlen(dirp->d_name) + 5;
-                               filepath = (char*)calloc(file_size, sizeof(char));
-
-                               if (NULL != filepath) {
-                                       snprintf(filepath, file_size, "%s/%s", TTS_DEFAULT_ENGINE, dirp->d_name);
-                               } else {
-                                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not enough memory!!");
-                                       continue;
-                               }
-
-                               /* get its info and update engine list */
-                               if (0 == __internal_get_engine_info(filepath, &info)) {
-                                       /* add engine info to g_engine_list */
-                                       g_engine_list = g_list_append(g_engine_list, info);
-                               }
-
-                               if (NULL != filepath)   free(filepath);
-                       }
-               } while (NULL != dirp);
-
-               closedir(dp);
-       }
-
-       if (g_list_length(g_engine_list) <= 0) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No Engine");
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-#ifdef ENGINE_AGENT_DEBUG
-       ttsd_print_enginelist();
-#endif
-       return 0;
-}
-
-static int __internal_set_current_engine(const char* engine_uuid)
-{
-       /* check whether engine id is valid or not. */
-       GList *iter = NULL;
-       ttsengine_info_s *data = NULL;
-
-       bool flag = false;
-       if (g_list_length(g_engine_list) > 0) {
-               iter = g_list_first(g_engine_list);
-
-               while (NULL != iter) {
-                       data = iter->data;
-
-                       if (0 == strncmp(data->engine_uuid, engine_uuid, strlen(engine_uuid))) {
-                               flag = true;
-                               break;
-                       }
-
-                       /*Get next item*/
-                       iter = g_list_next(iter);
-               }
+       /* unload current engine */
+       if (g_engine_info->is_loaded) {
+               ttsd_engine_agent_unload_current_engine();
        }
 
-       /* If current engine does not exist, return error */
-       if (false == flag) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] 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, get_tag(), "[Engine Agent] tts engine has already been set");
-                               return 0;
-                       }
-               }
+       if (NULL != g_engine_info->default_lang) {
+               free(g_engine_info->default_lang);
+               g_engine_info->default_lang = NULL;
        }
 
-       /* set data from g_engine_list */
-       if (g_cur_engine.engine_uuid != NULL)   free(g_cur_engine.engine_uuid);
-       if (g_cur_engine.engine_name != NULL)   free(g_cur_engine.engine_name);
-       if (g_cur_engine.engine_path != NULL)   free(g_cur_engine.engine_path);
-
-       if (NULL == data->engine_uuid || NULL == data->engine_name || NULL == data->engine_path) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Engine data is NULL");
-               return TTSD_ERROR_OPERATION_FAILED;
+       if (NULL != g_engine_info->engine_uuid) {
+               free(g_engine_info->engine_uuid);
+               g_engine_info->engine_uuid = NULL;
        }
 
-       g_cur_engine.engine_uuid = strdup(data->engine_uuid);
-       g_cur_engine.engine_name = strdup(data->engine_name);
-       g_cur_engine.engine_path = strdup(data->engine_path);
-
-       g_cur_engine.handle = NULL;
-       g_cur_engine.is_loaded = false;
-       g_cur_engine.is_set = true;
-       g_cur_engine.need_network = data->use_network;
-
-       SLOG(LOG_DEBUG, get_tag(), "-----");
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Current engine uuid : %s", g_cur_engine.engine_uuid);
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Current engine name : %s", g_cur_engine.engine_name);
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Current engine path : %s", g_cur_engine.engine_path);
-       SLOG(LOG_DEBUG, get_tag(), "-----");
-
-       return 0;
-}
-
-int __ttsd_get_mode(ttsp_mode_e* mode)
-{
-       if (NULL == mode) {
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] Input parameter is null");
-               return TTSP_ERROR_INVALID_PARAMETER;
+       if (NULL != g_engine_info->engine_name) {
+               free(g_engine_info->engine_name);
+               g_engine_info->engine_name = NULL;
        }
 
-       switch (ttsd_get_mode()) {
-       case TTSD_MODE_DEFAULT:         *mode = TTSP_MODE_DEFAULT;      break;
-       case TTSD_MODE_NOTIFICATION:    *mode = TTSP_MODE_NOTIFICATION; break;
-       case TTSD_MODE_SCREEN_READER:   *mode = TTSP_MODE_SCREEN_READER;        break;
-       default:
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] tts mode is NOT valid");
+       if (NULL != g_engine_info->engine_setting_path) {
+               free(g_engine_info->engine_setting_path);
+               g_engine_info->engine_setting_path = NULL;
        }
 
-       return 0;
-}
-
-int __ttsd_engine_agent_get_speed_range(int* min, int* normal, int* max)
-{
-       if (NULL == min || NULL == normal || NULL == max) {
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] Input parameter is null");
-               return TTSP_ERROR_INVALID_PARAMETER;
+       if (NULL != g_engine_info->engine_path) {
+               free(g_engine_info->engine_path);
+               g_engine_info->engine_path = NULL;
        }
 
-       *min = TTS_SPEED_MIN;
-       *normal = TTS_SPEED_NORMAL;
-       *max = TTS_SPEED_MAX;
-
-       return 0;
-}
+       free(g_engine_info);
+       g_engine_info = NULL;
 
-int __ttsd_engine_agent_get_pitch_range(int* min, int* normal, int* max)
-{
-       if (NULL == min || NULL == normal || NULL == max) {
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] Input parameter is null");
-               return TTSP_ERROR_INVALID_PARAMETER;
-       }
+       g_agent_init = false;
 
-       *min = TTS_PITCH_MIN;
-       *normal = TTS_PITCH_NORMAL;
-       *max = TTS_PITCH_MAX;
+       SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Release Engine Agent");
 
        return 0;
 }
@@ -664,13 +183,13 @@ int __ttsd_engine_agent_get_pitch_range(int* min, int* normal, int* max)
 static bool __set_voice_info_cb(const char* language, int type, void* user_data)
 {
        if (NULL == language) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!");
                return false;
        }
 
        ttsvoice_s* voice = calloc(1, sizeof(ttsvoice_s));
        if (NULL == voice) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to allocate memory");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to allocate memory");
                return false;
        }
        voice->lang = strdup(language);
@@ -679,7 +198,7 @@ static bool __set_voice_info_cb(const char* language, int type, void* user_data)
        voice->client_ref_count = 0;
        voice->is_loaded = false;
 
-       if (0 == strcmp(g_cur_engine.default_lang, language) && g_cur_engine.default_vctype == type) {
+       if (0 == strcmp(g_engine_info->default_lang, language) && g_engine_info->default_vctype == type) {
                voice->is_default = true;
                voice->is_loaded = true;
        } else {
@@ -693,13 +212,42 @@ static bool __set_voice_info_cb(const char* language, int type, void* user_data)
 
 static int __update_voice_list()
 {
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
        /* Get voice list */
+       if (NULL != g_cur_voices) {
+               GSList *iter = NULL;
+               ttsvoice_s* data = NULL;
+
+               iter = g_slist_nth(g_cur_voices, 0);
+               while (NULL != iter) {
+                       data = iter->data;
+
+                       if (NULL != data) {
+                               if (NULL != data->lang) {
+                                       free(data->lang);
+                                       data->lang = NULL;
+                               }
+
+                               g_cur_voices = g_slist_remove(g_cur_voices, data);
+                               free(data);
+                               data = NULL;
+                       }
+
+                       iter = g_slist_nth(g_cur_voices, 0);
+               }
+       }
+
        g_cur_voices = NULL;
-       int ret = 0;
 
-       ret = g_cur_engine.pefuncs->foreach_voices(__set_voice_info_cb, NULL);
+       int ret = -1;
+       ret = g_engine_info->callbacks->foreach_voices(__set_voice_info_cb, NULL);
+
        if (0 != ret || 0 >= g_slist_length(g_cur_voices)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get voice list : result(%d)", ret);
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] fail to get voice list : result(%d)", ret);
                return -1;
        }
 
@@ -709,127 +257,103 @@ static int __update_voice_list()
        return 0;
 }
 
-int ttsd_engine_agent_load_current_engine()
+int ttsd_engine_agent_load_current_engine(ttse_request_callback_s* callback)
 {
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
+       SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent DEBUG] === ttsd_engine_agent_load_current_engine START");
 
-       if (false == g_cur_engine.is_set) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] 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, get_tag(), "[Engine Agent] Engine has already been loaded ");
-               return 0;
-       }
-
-       /* 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, get_tag(), "[Engine Agent ERROR] Fail to get current engine handle : %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, get_tag(), "[Engine Agent ERROR] Fail to link daemon to ttsp_unload_engine() : %s", error);
-               return -3;
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
+               return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       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, get_tag(), "[Engine Agent ERROR] Fail to link daemon to ttsp_load_engine() : %s", error);
-               return -3;
+       /* check whether current engine is loaded or not */
+       if (true == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent] Engine has already been loaded ");
+               return 0;
        }
 
-       /* load engine */
-       g_cur_engine.pdfuncs->version = 1;
-       g_cur_engine.pdfuncs->size = sizeof(ttspd_funcs_s);
-       g_cur_engine.pdfuncs->get_mode = __ttsd_get_mode;
-       g_cur_engine.pdfuncs->get_speed_range = __ttsd_engine_agent_get_speed_range;
-       g_cur_engine.pdfuncs->get_pitch_range = __ttsd_engine_agent_get_pitch_range;
-
-       int ret = 0;
-       ret = g_cur_engine.ttsp_load_engine(g_cur_engine.pdfuncs, g_cur_engine.pefuncs);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to load engine - %s : result(%s)",
-                        g_cur_engine.engine_path, __ttsd_get_engine_error_code(ret));
-               return TTSD_ERROR_OPERATION_FAILED;
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
-       /* engine error check */
-       if (g_cur_engine.pefuncs->size != sizeof(ttspe_funcs_s)) {
-               SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] The size of engine function is not valid");
+       if (NULL == callback->get_info
+               || NULL == callback->initialize || NULL == callback->deinitialize
+               || NULL == callback->foreach_voices || NULL == callback->is_valid_voice
+               || NULL == callback->set_pitch
+               || NULL == callback->load_voice || NULL == callback->unload_voice
+               || NULL == callback->start_synth || NULL == callback->cancel_synth
+               || NULL == callback->check_app_agreed || NULL == callback->need_app_credential) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
-       if (NULL == g_cur_engine.pefuncs->initialize ||
-               NULL == g_cur_engine.pefuncs->deinitialize ||
-               NULL == g_cur_engine.pefuncs->foreach_voices ||
-               NULL == g_cur_engine.pefuncs->is_valid_voice ||
-               NULL == g_cur_engine.pefuncs->start_synth ||
-               NULL == g_cur_engine.pefuncs->cancel_synth) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] The engine functions are NOT valid");
-               return TTSD_ERROR_OPERATION_FAILED;
+       /* Get current engine info */
+       int ret = __internal_get_engine_info(callback);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to get engine info");
+               return ret;
        }
 
-       ret = g_cur_engine.pefuncs->initialize(__result_cb);
+       /* Initialize engine */
+       ret = g_engine_info->callbacks->initialize();
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to initialize current engine : %s", __ttsd_get_engine_error_code(ret));
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to initialize current engine : %s", __ttsd_get_engine_error_code(ret));
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        /* Get voice info of current engine */
        ret = __update_voice_list();
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set voice info : result(%d)", ret);
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to set voice info : result(%d)", ret);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        /* Select default voice */
-       if (NULL != g_cur_engine.default_lang) {
-               if (true == g_cur_engine.pefuncs->is_valid_voice(g_cur_engine.default_lang, g_cur_engine.default_vctype)) {
-                       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, get_tag(), "[Engine Agent WARNING] Fail set origin default voice : lang(%s), type(%d)",
-                                g_cur_engine.default_lang, g_cur_engine.default_vctype);
+       if (NULL != g_engine_info->default_lang) {
+               bool is_valid = false;
+               ret = g_engine_info->callbacks->is_valid_voice(g_engine_info->default_lang, g_engine_info->default_vctype, &is_valid);
+               if (0 == ret) {
+                       if (true == is_valid) {
+                               SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Set origin default voice to current engine : lang(%s), type(%d)", 
+                                       g_engine_info->default_lang, g_engine_info->default_vctype);
+                       } else {
+                               SLOG(LOG_WARN, tts_tag(), "[Engine Agent WARNING] Fail to set origin default voice : lang(%s), type(%d)",
+                                       g_engine_info->default_lang, g_engine_info->default_vctype);
 
-                       return TTSD_ERROR_OPERATION_FAILED;
+                               /* TODO - Error Tolerance when Default voice is not valid */
+                               return TTSD_ERROR_OPERATION_FAILED;
+                       }
+               } else {
+                       SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail(Engine ERROR) : %s", __ttsd_get_engine_error_code(ret));
+                       return ret;
                }
        }
 
        /* load default voice */
-       if (NULL != g_cur_engine.pefuncs->load_voice) {
-               ret = g_cur_engine.pefuncs->load_voice(g_cur_engine.default_lang, g_cur_engine.default_vctype);
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Load default voice : lang(%s), type(%d)",
-                                g_cur_engine.default_lang,  g_cur_engine.default_vctype);
-               } else {
-                       SLOG(LOG_WARN, get_tag(), "[Engine Agent ERROR] Fail to load default voice : lang(%s), type(%d) result(%s)",
-                               g_cur_engine.default_lang, g_cur_engine.default_vctype, __ttsd_get_engine_error_code(ret));
+       ret = g_engine_info->callbacks->load_voice(g_engine_info->default_lang, g_engine_info->default_vctype);
+       if (0 == ret) {
+               SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Load default voice : lang(%s), type(%d)",
+                       g_engine_info->default_lang, g_engine_info->default_vctype);
+       } else {
+               SLOG(LOG_WARN, tts_tag(), "[Engine Agent ERROR] Fail to load default voice : lang(%s), type(%d) result(%s)",
+                       g_engine_info->default_lang, g_engine_info->default_vctype, __ttsd_get_engine_error_code(ret));
 
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
+               return TTSD_ERROR_OPERATION_FAILED;
        }
 
        /* set default pitch */
-       if (NULL != g_cur_engine.pefuncs->set_pitch) {
-               ret = g_cur_engine.pefuncs->set_pitch(g_cur_engine.default_pitch);
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set pitch : pitch(%d), result(%s)",
-                               g_cur_engine.default_pitch, __ttsd_get_engine_error_code(ret));
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set default pitch : pitch(%d)", g_cur_engine.default_pitch);
+       ret = g_engine_info->callbacks->set_pitch(g_engine_info->default_pitch);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to set pitch : pitch(%d), result(%s)", 
+                       g_engine_info->default_pitch, __ttsd_get_engine_error_code(ret));
+               return ret;
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Set default pitch : pitch(%d)", g_engine_info->default_pitch);
        }
 
-       g_cur_engine.is_loaded = true;
+       g_engine_info->is_loaded = true;
 
        return 0;
 }
@@ -837,35 +361,24 @@ int ttsd_engine_agent_load_current_engine()
 int ttsd_engine_agent_unload_current_engine()
 {
        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_set) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No Current Engine ");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Engine has already been unloaded ");
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Engine has already been unloaded ");
                return 0;
        }
 
        /* shutdown engine */
        int ret = 0;
-       ret = g_cur_engine.pefuncs->deinitialize();
+       ret = g_engine_info->callbacks->deinitialize();
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent] Fail deinitialize() : %s", __ttsd_get_engine_error_code(ret));
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent] Fail deinitialize() : %s", __ttsd_get_engine_error_code(ret));
        }
 
-       /* unload engine */
-       g_cur_engine.ttsp_unload_engine();
-
-       dlclose(g_cur_engine.handle);
-
        /* reset current engine data */
-       g_cur_engine.handle = NULL;
-       g_cur_engine.is_loaded = false;
+       g_engine_info->is_loaded = false;
 
        GSList *iter = NULL;
        ttsvoice_s* data = NULL;
@@ -884,22 +397,49 @@ int ttsd_engine_agent_unload_current_engine()
                iter = g_slist_nth(g_cur_voices, 0);
        }
 
+       SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent Success] Unload current engine");
+
        return 0;
 }
 
 bool ttsd_engine_agent_need_network()
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_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;
+       return g_engine_info->use_network;
+}
+
+bool ttsd_engine_agent_is_same_engine(const char* engine_id)
+{
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
+               return false;
+       }
+
+       if (NULL == engine_id) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] engine_id is NULL");
+               return false;
+       }
+
+       if (NULL == g_engine_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] g_engine_info is NULL");
+               return false;
+       }
+
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not loaded engine");
+               return false;
+       }
+
+       /* compare current engine and engine id.*/
+       if (NULL != g_engine_info->engine_uuid && 0 == strncmp(g_engine_info->engine_uuid, engine_id, strlen(engine_id))) {
+               return true;
        }
 
-       return g_cur_engine.need_network;
+       return false;
 }
 
 bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, int* out_type)
@@ -908,28 +448,37 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
                return false;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Not loaded engine");
+       if (NULL == g_engine_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] g_engine_info is NULL");
+               return false;
+       }
+
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_WARN, tts_tag(), "[Engine Agent WARNING] Not loaded engine");
                return false;
        }
 
-       SECURE_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);
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Select voice : input lang(%s), input type(%d), default lang(%s), default type(%d)", 
+               (NULL == lang) ? "NULL" : lang, type, (NULL == g_engine_info->default_lang) ? "NULL" : g_engine_info->default_lang, g_engine_info->default_vctype);
 
        /* case 1 : Both are default */
-       if (0 == strncmp(lang, "default", strlen("default")) && 0 == type) {
-               *out_lang = strdup(g_cur_engine.default_lang);
-               *out_type = g_cur_engine.default_vctype;
+       if (0 == strncmp(lang, "default", strlen(lang)) && 0 == type) {
+               if (NULL != g_engine_info->default_lang) {
+                       *out_lang = strdup(g_engine_info->default_lang);
+               } else {
+                       *out_lang = NULL;
+               }
+
+               *out_type = g_engine_info->default_vctype;
                return true;
        }
 
        /* Get voice list */
        GList* voice_list = NULL;
        int ret = 0;
-
-       ret = g_cur_engine.pefuncs->foreach_voices(__supported_voice_cb, &voice_list);
+       ret = g_engine_info->callbacks->foreach_voices(__supported_voice_cb, &voice_list);
        if (0 != ret || 0 >= g_list_length(voice_list)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get voice list : result(%d)", ret);
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] fail to get voice list : result(%d)", ret);
                return false;
        }
 
@@ -939,7 +488,7 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
        GList *iter = NULL;
        voice_s* voice;
 
-       /* lang and type are not default type */
+       /* case 2 : lang and type are not default type */
        if (0 != strncmp(lang, "default", strlen("default")) && 0 != type) {
                iter = g_list_first(voice_list);
 
@@ -959,9 +508,9 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
 
        } else if (0 != strncmp(lang, "default", strlen("default")) && 0 == type) {
                /* Only type is default */
-               if (0 == strncmp(lang, g_cur_engine.default_lang, strlen(g_cur_engine.default_lang))) {
-                       *out_lang = strdup(g_cur_engine.default_lang);
-                       *out_type = g_cur_engine.default_vctype;
+               if (0 == strncmp(lang, g_engine_info->default_lang, strlen(g_engine_info->default_lang))) {
+                       *out_lang = strdup(g_engine_info->default_lang);
+                       *out_type = g_engine_info->default_vctype;
                        result = true;
                } else {
                        voice_s* voice_selected = NULL;
@@ -972,7 +521,7 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
 
                                if (0 == strncmp(voice->language, lang, strlen(lang))) {
                                        voice_selected = voice;
-                                       if (voice->type == g_cur_engine.default_vctype) {
+                                       if (voice->type == g_engine_info->default_vctype) {
                                                voice_selected = voice;
                                                break;
                                        }
@@ -988,9 +537,9 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
                }
        } else if (0 == strncmp(lang, "default", strlen("default")) && 0 != type) {
                /* Only lang is default */
-               if (type == g_cur_engine.default_vctype) {
-                       *out_lang = strdup(g_cur_engine.default_lang);
-                       *out_type = g_cur_engine.default_vctype;
+               if (type == g_engine_info->default_vctype) {
+                       *out_lang = strdup(g_engine_info->default_lang);
+                       *out_type = g_engine_info->default_vctype;
                        result = true;
                } else {
                        voice_s* voice_selected = NULL;
@@ -999,7 +548,7 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
                                /* Get handle data from list */
                                voice = iter->data;
 
-                               if (0 == strncmp(voice->language, g_cur_engine.default_lang, strlen(g_cur_engine.default_lang))) {
+                               if (0 == strncmp(voice->language, g_engine_info->default_lang, strlen(g_engine_info->default_lang))) {
                                        voice_selected = voice;
                                        if (voice->type == type) {
                                                voice_selected = voice;
@@ -1018,7 +567,7 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
        }
 
        if (true == result) {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Selected voice : lang(%s), type(%d)", *out_lang, *out_type);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Selected voice : lang(%s), type(%d)", *out_lang, *out_type);
        }
 
        __free_voice_list(voice_list);
@@ -1026,110 +575,49 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
        return result;
 }
 
-bool ttsd_engine_agent_is_same_engine(const char* engine_id)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
-               return false;
-       }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
-               return false;
-       }
 
-       /* compare current engine and engine id.*/
-       if (0 == strncmp(g_cur_engine.engine_uuid, engine_id, strlen(engine_id))) {
-               return true;
+int ttsd_engine_agent_set_default_voice(const char* language, int vctype)
+{
+       if (NULL == language) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] language is NULL");
+               return false;
        }
 
-       return false;
-}
-
-int ttsd_engine_agent_set_default_engine(const char* engine_id)
-{
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_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))) {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] new engine(%s) is the same as current engine", engine_id);
-               return 0;
-       }
-
-       bool is_engine_loaded = false;
-       char* tmp_uuid = NULL;
-       tmp_uuid = strdup(g_cur_engine.engine_uuid);
-       if (NULL == tmp_uuid) {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Current engine id is NULL");
-                       return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       is_engine_loaded = g_cur_engine.is_loaded;
-
-       if (true == is_engine_loaded) {
-               /* unload engine */
-               if (0 != ttsd_engine_agent_unload_current_engine()) {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent Error] fail to unload current engine");
-               }
+       if (NULL == g_engine_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] g_engine_info is NULL");
+               return false;
        }
 
-       /* change current engine */
-       if (0 != __internal_set_current_engine(engine_id)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set current engine. Recovery origin engine");
-
-               /* roll back to old current engine. */
-               __internal_set_current_engine(tmp_uuid);
-               if (true == is_engine_loaded) {
-                       ttsd_engine_agent_load_current_engine();
-               }
-
-               if (tmp_uuid != NULL)   free(tmp_uuid);
-               return TTSD_ERROR_OPERATION_FAILED;
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
-       if (true == is_engine_loaded) {
-               /* load engine */
-               if (0 != ttsd_engine_agent_load_current_engine()) {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent Error] Fail to load new engine. Recovery origin engine");
-
-                       /* roll back to old current engine. */
-                       __internal_set_current_engine(tmp_uuid);
-                       if (true == is_engine_loaded) {
-                               ttsd_engine_agent_load_current_engine();
-                       }
+       int ret = -1;
+       bool is_valid = false;
+       ret = g_engine_info->callbacks->is_valid_voice(language, vctype, &is_valid);
+       if (0 == ret) {
+               if (true == is_valid) {
+                       SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Current voice is valid : lang(%s), type(%d)", 
+                               (NULL == g_engine_info->default_lang) ? "NULL" : g_engine_info->default_lang, g_engine_info->default_vctype);
+               } else {
+                       SLOG(LOG_WARN, tts_tag(), "[Engine Agent WARNING] Current voice is invalid : lang(%s), type(%d)",
+                               (NULL == g_engine_info->default_lang) ? "NULL" : g_engine_info->default_lang, g_engine_info->default_vctype);
 
-                       if (tmp_uuid != NULL)   free(tmp_uuid);
                        return TTSD_ERROR_OPERATION_FAILED;
-               } else {
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] load new engine : %s", engine_id);
                }
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail(Engine ERROR) : %s", __ttsd_get_engine_error_code(ret));
+               return ret;
        }
 
-       if (tmp_uuid != NULL)   free(tmp_uuid);
-       return 0;
-}
-
-int ttsd_engine_agent_set_default_voice(const char* language, int 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 (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;
-       }
 
-       int ret = -1;
        GSList *iter = NULL;
        ttsvoice_s* data = NULL;
 
@@ -1140,26 +628,24 @@ int ttsd_engine_agent_set_default_voice(const char* language, int vctype)
                data = iter->data;
 
                if (NULL == data) {
-                       SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Voice data is NULL");
+                       SECURE_SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Voice data is NULL");
                        return TTSD_ERROR_OPERATION_FAILED;
                }
 
+               if (NULL != data->lang) {
                if (0 == strcmp(data->lang, language) && data->type == vctype) {
                        data->is_default = true;
                        if (0 == data->client_ref_count) {
                                /* load voice */
-                               if (NULL != g_cur_engine.pefuncs->load_voice) {
-                                       ret = g_cur_engine.pefuncs->load_voice(data->lang, data->type);
+                                       ret = g_engine_info->callbacks->load_voice(data->lang, data->type);
                                        if (0 == ret) {
-                                               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] load voice : lang(%s), type(%d)", 
+                                               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] load voice : lang(%s), type(%d)", 
                                                        data->lang, data->type);
                                                data->is_loaded = true;
                                        } else {
-                                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to load voice : lang(%s), type(%d), result(%s)",
+                                               SECURE_SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to load voice : lang(%s), type(%d), result(%s)",
                                                        data->lang, data->type, __ttsd_get_engine_error_code(ret));
                                        }
-                               } else {
-                                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent ERROR] Load voice of engine function is NULL");
                                }
                        }
                        break;
@@ -1180,27 +666,23 @@ int ttsd_engine_agent_set_default_voice(const char* language, int vctype)
                data = iter->data;
 
                if (NULL == data) {
-                       SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Voice data is NULL");
+                       SECURE_SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Voice data is NULL");
                        return TTSD_ERROR_OPERATION_FAILED;
                }
 
-               if (0 == strcmp(data->lang, g_cur_engine.default_lang) && data->type == g_cur_engine.default_vctype) {
+               if (0 == strcmp(data->lang, g_engine_info->default_lang) && data->type == g_engine_info->default_vctype) {
                        data->is_default = false;
                        if (0 == data->client_ref_count) {
                                /* Unload voice */
-                               if (NULL != g_cur_engine.pefuncs->unload_voice) {
-                                       ret = g_cur_engine.pefuncs->unload_voice(data->lang, data->type);
+                               ret = g_engine_info->callbacks->unload_voice(data->lang, data->type);
                                        if (0 == ret) {
-                                               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Unload voice : lang(%s), type(%d)", 
+                                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Unload voice : lang(%s), type(%d)", 
                                                        data->lang, data->type);
                                                data->is_loaded = false;
                                        } else {
-                                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to unload voice : lang(%s), type(%d), result(%s)",
+                                       SECURE_SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to unload voice : lang(%s), type(%d), result(%s)",
                                                        data->lang, data->type, __ttsd_get_engine_error_code(ret));
                                        }
-                               } else {
-                                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent ERROR] Unload voice of engine function is NULL");
-                               }
                        }
                        break;
                }
@@ -1209,17 +691,17 @@ int ttsd_engine_agent_set_default_voice(const char* language, int vctype)
                iter = g_slist_next(iter);
        }
 
-       if (NULL != g_cur_engine.default_lang)  free(g_cur_engine.default_lang);
+       if (NULL != g_engine_info->default_lang)        free(g_engine_info->default_lang);
 
-       g_cur_engine.default_lang = strdup(language);
-       g_cur_engine.default_vctype = vctype;
+       g_engine_info->default_lang = strdup(language);
+       g_engine_info->default_vctype = vctype;
 
 #ifdef ENGINE_AGENT_DEBUG
        ttsd_print_voicelist();
 #endif
 
-       SECURE_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);
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d)",
+               g_engine_info->default_lang, g_engine_info->default_vctype);
 
        return 0;
 }
@@ -1227,11 +709,11 @@ int ttsd_engine_agent_set_default_voice(const char* language, int vctype)
 int ttsd_engine_agent_set_default_speed(int speed)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       g_cur_engine.default_speed = speed;
+       g_engine_info->default_speed = speed;
 
        return 0;
 }
@@ -1239,28 +721,28 @@ int ttsd_engine_agent_set_default_speed(int speed)
 int ttsd_engine_agent_set_default_pitch(int pitch)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_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_engine_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No engine info");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
-       if (NULL == g_cur_engine.pefuncs->set_pitch) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not support pitch");
-               return TTSD_ERROR_OPERATION_FAILED;
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
-       int ret = g_cur_engine.pefuncs->set_pitch(pitch);
+       int ret = g_engine_info->callbacks->set_pitch(pitch);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set pitch : pitch(%d), result(%s)",
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to set pitch : pitch(%d), result(%s)",
                         pitch, __ttsd_get_engine_error_code(ret));
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       g_cur_engine.default_pitch = pitch;
+       g_engine_info->default_pitch = pitch;
 
        return 0;
 }
@@ -1268,30 +750,30 @@ int ttsd_engine_agent_set_default_pitch(int pitch)
 int ttsd_engine_agent_is_credential_needed(int uid, bool* credential_needed)
 {
        if (NULL == credential_needed) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Invalid Parameter");
-               return TTSP_ERROR_INVALID_PARAMETER;
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid Parameter");
+               return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_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");
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not loaded engine");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == g_cur_engine.pefuncs->need_app_credential) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not support to check app credential");
+       if (NULL == g_engine_info->callbacks->need_app_credential) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not support to check app credential");
                return TTSD_ERROR_NOT_SUPPORTED_FEATURE;
        }
 
        bool result = false;
-       result = g_cur_engine.pefuncs->need_app_credential();
+       result = g_engine_info->callbacks->need_app_credential();
        *credential_needed = result;
 
-       return TTSP_ERROR_NONE;
+       return TTSD_ERROR_NONE;
 }
 
 /******************************************************************************************
@@ -1300,6 +782,21 @@ int ttsd_engine_agent_is_credential_needed(int uid, bool* credential_needed)
 
 int ttsd_engine_load_voice(const char* lang, const int vctype)
 {
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       if (NULL == lang) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No language parameter");
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
        /* 1. Find voice info */
        int ret = -1;
        GSList *iter = NULL;
@@ -1311,8 +808,8 @@ int ttsd_engine_load_voice(const char* lang, const int vctype)
                data = iter->data;
 
                if (NULL != data) {
-                       if (0 == strcmp(data->lang, lang) && data->type == vctype) {
-                               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Find voice : default(%d) loaded(%d) ref(%d) lang(%s) type(%d)",
+                       if (NULL != data->lang && 0 == strcmp(data->lang, lang) && data->type == vctype) {
+                               SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Find voice : default(%d) loaded(%d) ref(%d) lang(%s) type(%d)",
                                         data->is_default, data->is_loaded,  data->client_ref_count, data->lang, data->type);
                                break;
                        }
@@ -1324,7 +821,7 @@ int ttsd_engine_load_voice(const char* lang, const int vctype)
        }
 
        if (NULL == data) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] This voice is not supported voice : lang(%s) type(%d)", lang, vctype);
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] This voice is not supported voice : lang(%s) type(%d)", lang, vctype);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -1334,23 +831,19 @@ int ttsd_engine_load_voice(const char* lang, const int vctype)
        /* 3. if ref count change 0 to 1 and not default, load voice */
        if (1 == data->client_ref_count && false == data->is_default) {
                /* load voice */
-               if (NULL != g_cur_engine.pefuncs->load_voice) {
-                       ret = g_cur_engine.pefuncs->load_voice(data->lang, data->type);
+               ret = g_engine_info->callbacks->load_voice(data->lang, data->type);
                        if (0 == ret) {
-                               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Load voice : lang(%s), type(%d)", 
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Load voice : lang(%s), type(%d)", 
                                        data->lang, data->type);
                                data->is_loaded = true;
                        } else {
-                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to load voice : lang(%s), type(%d), result(%s)",
+                       SECURE_SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to load voice : lang(%s), type(%d), result(%s)",
                                        data->lang, data->type, __ttsd_get_engine_error_code(ret));
 
                                return TTSD_ERROR_OPERATION_FAILED;
                        }
                } else {
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent ERROR] Load voice of engine function is NULL");
-               }
-       } else {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Not load voice : default voice(%d) or ref count(%d)",
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Not load voice : default voice(%d) or ref count(%d)",
                        data->is_default, data->client_ref_count);
        }
 
@@ -1363,6 +856,21 @@ int ttsd_engine_load_voice(const char* lang, const int vctype)
 
 int ttsd_engine_unload_voice(const char* lang, const int vctype)
 {
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       if (NULL == lang) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No language parameter");
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
        /* 1. Find voice info */
        int ret = -1;
        GSList *iter = NULL;
@@ -1374,8 +882,8 @@ int ttsd_engine_unload_voice(const char* lang, const int vctype)
                data = iter->data;
 
                if (NULL != data) {
-                       if (0 == strcmp(data->lang, lang) && data->type == vctype) {
-                               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Find voice : default(%d) loaded(%d) ref(%d) lang(%s) type(%d)",
+                       if (NULL != data->lang && 0 == strcmp(data->lang, lang) && data->type == vctype) {
+                               SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Find voice : default(%d) loaded(%d) ref(%d) lang(%s) type(%d)",
                                         data->is_default, data->is_loaded,  data->client_ref_count, data->lang, data->type);
                                break;
                        }
@@ -1387,7 +895,7 @@ int ttsd_engine_unload_voice(const char* lang, const int vctype)
        }
 
        if (NULL == data) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] This voice is not supported voice : lang(%s) type(%d)", lang, vctype);
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] This voice is not supported voice : lang(%s) type(%d)", lang, vctype);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -1396,24 +904,20 @@ int ttsd_engine_unload_voice(const char* lang, const int vctype)
 
        /* 3. if ref count change 0 and not default, load voice */
        if (0 == data->client_ref_count && false == data->is_default) {
-               /* load voice */
-               if (NULL != g_cur_engine.pefuncs->unload_voice) {
-                       ret = g_cur_engine.pefuncs->unload_voice(data->lang, data->type);
+               /* unload voice */
+               ret = g_engine_info->callbacks->unload_voice(data->lang, data->type);
                        if (0 == ret) {
-                               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Unload voice : lang(%s), type(%d)", 
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent SUCCESS] Unload voice : lang(%s), type(%d)", 
                                        data->lang, data->type);
                                data->is_loaded = false;
                        } else {
-                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to unload voice : lang(%s), type(%d), result(%s)",
+                       SECURE_SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to unload voice : lang(%s), type(%d), result(%s)",
                                        data->lang, data->type, __ttsd_get_engine_error_code(ret));
 
                                return TTSD_ERROR_OPERATION_FAILED;
                        }
                } else {
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent ERROR] Unload voice of engine function is NULL");
-               }
-       } else {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Not unload voice : default voice(%d) or ref count(%d)",
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Not unload voice : default voice(%d) or ref count(%d)",
                        data->is_default, data->client_ref_count);
        }
 
@@ -1423,85 +927,84 @@ int ttsd_engine_unload_voice(const char* lang, const int vctype)
        return 0;
 }
 
-int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, int speed, const char* credential, void* user_param)
+int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, int speed, const char* appid, const char* credential, void* user_param)
 {
+       if (NULL == lang || NULL == text) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid parameter");
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_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 (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
        /* select voice for default */
        char* temp_lang = NULL;
        int temp_type;
        if (true != ttsd_engine_select_valid_voice(lang, vctype, &temp_lang, &temp_type)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to select default voice");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to select default voice");
                if (NULL != temp_lang)  free(temp_lang);
                return TTSD_ERROR_INVALID_VOICE;
        } else {
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Start synthesis : language(%s), type(%d), speed(%d), text(%s), credential(%s)", 
-                       temp_lang, temp_type, speed, text, credential);
-       }
-
-       if (NULL == g_cur_engine.pefuncs->start_synth) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] start_synth() of engine is NULL!!");
-               if (NULL != temp_lang)  free(temp_lang);
-               return TTSD_ERROR_OPERATION_FAILED;
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Start synthesis : language(%s), type(%d), speed(%d), text(%s), credential(%s)", 
+                       (NULL == temp_lang) ? "NULL" : temp_lang, temp_type, speed, (NULL == text) ? "NULL" : text, (NULL == credential) ? "NULL" : credential);
        }
 
        int temp_speed;
 
        if (0 == speed) {
-               temp_speed = g_cur_engine.default_speed;
+               temp_speed = g_engine_info->default_speed;
        } else {
                temp_speed = speed;
        }
 
        /* synthesize text */
        int ret = 0;
-       ret = g_cur_engine.pefuncs->start_synth(temp_lang, temp_type, text, temp_speed, credential, user_param);
+       ret = g_engine_info->callbacks->start_synth(temp_lang, temp_type, text, temp_speed, appid, credential, user_param);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ***************************************");
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] * synthesize error : %s *", __ttsd_get_engine_error_code(ret));
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ***************************************");
-               if (NULL != temp_lang)  free(temp_lang);
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] ***************************************");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] * synthesize error : %s *", __ttsd_get_engine_error_code(ret));
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] ***************************************");
+               if (NULL != temp_lang) {
+                       free(temp_lang);
+                       temp_lang = NULL;
+               }
                return ret;
        }
 
-       if (NULL != temp_lang)  free(temp_lang);
+       if (NULL != temp_lang)  {
+               free(temp_lang);
+               temp_lang = NULL;
+       }
        return 0;
 }
 
 int ttsd_engine_cancel_synthesis()
 {
        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");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == g_cur_engine.pefuncs->cancel_synth) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] cancel_synth() of engine is NULL!!");
-               return TTSD_ERROR_OPERATION_FAILED;
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
        /* stop synthesis */
        int ret = 0;
-       ret = g_cur_engine.pefuncs->cancel_synth();
+       ret = g_engine_info->callbacks->cancel_synth();
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail cancel synthesis : %s", __ttsd_get_engine_error_code(ret));
-               return TTSD_ERROR_OPERATION_FAILED;
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] fail cancel synthesis : %s", __ttsd_get_engine_error_code(ret));
        }
 
-       return 0;
+       return ret;
 }
 
 bool __supported_voice_cb(const char* language, int type, void* user_data)
@@ -1509,13 +1012,13 @@ bool __supported_voice_cb(const char* language, int type, void* user_data)
        GList** voice_list = (GList**)user_data;
 
        if (NULL == language || NULL == voice_list) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!");
                return false;
        }
 
        voice_s* voice = calloc(1, sizeof(voice_s));
        if (NULL == voice) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to allocate memory");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to allocate memory");
                return false;
        }
        voice->language = strdup(language);
@@ -1528,50 +1031,54 @@ bool __supported_voice_cb(const char* language, int type, void* user_data)
 
 int ttsd_engine_get_voice_list(GList** voice_list)
 {
+       if (NULL == voice_list) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid parameter");
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_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 (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
        int ret = 0;
-       ret = g_cur_engine.pefuncs->foreach_voices(__supported_voice_cb, (void*)voice_list);
+       ret = g_engine_info->callbacks->foreach_voices(__supported_voice_cb, (void*)voice_list);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to get voice list : %s", __ttsd_get_engine_error_code(ret));
-               return TTSD_ERROR_OPERATION_FAILED;
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to get voice list : %s", __ttsd_get_engine_error_code(ret));
        }
 
-       return 0;
+       return ret;
 }
 
 int ttsd_engine_get_default_voice(char** lang, int* vctype)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_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 (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
        if (NULL == lang || NULL == vctype) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] BAD Parameter");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] BAD Parameter");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL != g_cur_engine.default_lang) {
-               *lang = strdup(g_cur_engine.default_lang);
-               *vctype = g_cur_engine.default_vctype;
+       if (NULL != g_engine_info->default_lang) {
+               *lang = strdup(g_engine_info->default_lang);
+               *vctype = g_engine_info->default_vctype;
 
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine] Get default voice : language(%s), type(%d)", *lang, *vctype);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine] Get default voice : language(%s), type(%d)", *lang, *vctype);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Default voice is NULL");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Default voice is NULL");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -1581,29 +1088,29 @@ int ttsd_engine_get_default_voice(char** lang, int* vctype)
 int ttsd_engine_set_private_data(const char* key, const char* data)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_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] No loaded engine");
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
                return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
        if (NULL == key) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Invalid parameter");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid parameter");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == g_cur_engine.pefuncs->set_private_data) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not supported feature");
+       if (NULL == g_engine_info->callbacks->private_data_set) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not supported feature");
                return TTSD_ERROR_NOT_SUPPORTED_FEATURE;
        }
 
-       int ret = 0;
-       ret = g_cur_engine.pefuncs->set_private_data(key, data);
+       int ret = g_engine_info->callbacks->private_data_set(key, data);
+
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set private data(%d)", ret);
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to set private data(%d)", ret);
        }
 
        return ret;
@@ -1612,30 +1119,31 @@ int ttsd_engine_set_private_data(const char* key, const char* data)
 int ttsd_engine_get_private_data(const char* key, char** data)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_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] No loaded engine");
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No loaded engine");
                return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
        if (NULL == key || NULL == data) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Invalid parameter");
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid parameter");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == g_cur_engine.pefuncs->get_private_data) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not supported feature");
+
+       if (NULL == g_engine_info->callbacks->private_data_requested) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not supported feature");
                return TTSD_ERROR_NOT_SUPPORTED_FEATURE;
        }
 
        char* temp = NULL;
        int ret = 0;
-       ret = g_cur_engine.pefuncs->get_private_data(key, &temp);
+       ret = g_engine_info->callbacks->private_data_requested(key, &temp);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to get private data(%d)", ret);
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to get private data(%d)", ret);
        }
 
        *data = strdup(temp);
@@ -1643,7 +1151,6 @@ int ttsd_engine_get_private_data(const char* key, char** data)
        return ret;
 }
 
-
 void __free_voice_list(GList* voice_list)
 {
        GList *iter = NULL;
@@ -1672,54 +1179,15 @@ void __free_voice_list(GList* voice_list)
 /*
 * TTS Engine Callback Functions                                                                                        `                                 *
 */
-bool __result_cb(ttsp_result_event_e event, const void* data, unsigned int data_size, ttsp_audio_type_e audio_type, int rate, void *user_data)
-{
-       g_result_cb(event, data, data_size, audio_type, rate, user_data);
-       return true;
-}
 
 /* function for debugging */
-int ttsd_print_enginelist()
-{
-       GList *iter = NULL;
-       ttsengine_info_s *data = NULL;
-
-       if (g_list_length(g_engine_list) > 0) {
-               iter = g_list_first(g_engine_list);
-
-               SLOG(LOG_DEBUG, get_tag(), "----- engine list -----");
-
-               int i = 1;
-               while (NULL != iter) {
-                       data = iter->data;
-
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[%dth]", i);
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "engine uuid : %s", data->engine_uuid);
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "engine name : %s", data->engine_name);
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "engine path : %s", data->engine_path);
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "setting ug path : %s", data->setting_ug_path);
-
-                       iter = g_list_next(iter);
-                       i++;
-               }
-               SLOG(LOG_DEBUG, get_tag(), "-----------------------");
-               SLOG(LOG_DEBUG, get_tag(), "  ");
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "----- engine list -----");
-               SLOG(LOG_DEBUG, get_tag(), "No Engine in directory");
-               SLOG(LOG_DEBUG, get_tag(), "-----------------------");
-       }
-
-       return 0;
-}
-
 int ttsd_print_voicelist()
 {
        /* Test log */
        GSList *iter = NULL;
        ttsvoice_s* data = NULL;
 
-       SLOG(LOG_DEBUG, get_tag(), "=== Voice list ===");
+       SLOG(LOG_DEBUG, tts_tag(), "=== Voice list ===");
 
        if (g_slist_length(g_cur_voices) > 0) {
                /* Get a first item */
@@ -1731,11 +1199,11 @@ int ttsd_print_voicelist()
                        data = iter->data;
 
                        if (NULL == data || NULL == data->lang) {
-                               SLOG(LOG_ERROR, get_tag(), "[ERROR] Data is invalid");
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Data is invalid");
                                return 0;
                        }
 
-                       SLOG(LOG_DEBUG, get_tag(), "[%dth] default(%d) loaded(%d) ref(%d) lang(%s) type(%d)",
+                       SLOG(LOG_DEBUG, tts_tag(), "[%dth] default(%d) loaded(%d) ref(%d) lang(%s) type(%d)",
                                 i, data->is_default, data->is_loaded,  data->client_ref_count, data->lang, data->type);
 
                        /*Get next item*/
@@ -1744,7 +1212,120 @@ int ttsd_print_voicelist()
                }
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "==================");
+       SLOG(LOG_DEBUG, tts_tag(), "==================");
 
        return 0;
 }
+
+int __internal_get_engine_info(ttse_request_callback_s* callback)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent DEBUG] === inside __internal_get_engine_info");
+
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       if (NULL == callback->get_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       if (0 != callback->get_info(&(g_engine_info->engine_uuid), &(g_engine_info->engine_name), &(g_engine_info->engine_setting_path), &(g_engine_info->use_network))) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to get engine info");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       if (NULL != g_engine_info->engine_path) {
+               free(g_engine_info->engine_path);
+               g_engine_info->engine_path = NULL;
+       }
+       g_engine_info->engine_path = strdup("empty");
+       g_engine_info->is_loaded = false;
+
+       if (NULL != g_engine_info->callbacks) {
+               free(g_engine_info->callbacks);
+               g_engine_info->callbacks = NULL;
+       }
+       g_engine_info->callbacks = (tts_engine_callback_s*)calloc(1, sizeof(tts_engine_callback_s));
+       if (NULL == g_engine_info->callbacks) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to allocate memory");
+               return TTSD_ERROR_OUT_OF_MEMORY;
+       }
+
+       g_engine_info->callbacks->get_info = callback->get_info;
+       g_engine_info->callbacks->initialize = callback->initialize;
+       g_engine_info->callbacks->deinitialize = callback->deinitialize;
+       g_engine_info->callbacks->foreach_voices = callback->foreach_voices;
+       g_engine_info->callbacks->is_valid_voice = callback->is_valid_voice;
+       g_engine_info->callbacks->set_pitch = callback->set_pitch;
+       g_engine_info->callbacks->load_voice = callback->load_voice;
+       g_engine_info->callbacks->unload_voice = callback->unload_voice;
+       g_engine_info->callbacks->start_synth = callback->start_synth;
+       g_engine_info->callbacks->cancel_synth = callback->cancel_synth;
+       g_engine_info->callbacks->check_app_agreed = callback->check_app_agreed;
+       g_engine_info->callbacks->need_app_credential = callback->need_app_credential;
+
+       g_engine_info->callbacks->private_data_set = NULL;
+       g_engine_info->callbacks->private_data_requested = NULL;
+
+       SLOG(LOG_DEBUG, tts_tag(), "--- Valid Engine ---");
+       SLOG(LOG_DEBUG, tts_tag(), "Engine uuid : %s", g_engine_info->engine_uuid);
+       SLOG(LOG_DEBUG, tts_tag(), "Engine name : %s", g_engine_info->engine_name);
+       SLOG(LOG_DEBUG, tts_tag(), "Engine path : %s", g_engine_info->engine_path);
+       SLOG(LOG_DEBUG, tts_tag(), "Engine setting path : %s", g_engine_info->engine_setting_path);
+       SLOG(LOG_DEBUG, tts_tag(), "Use network : %s", g_engine_info->use_network ? "true" : "false");
+       SLOG(LOG_DEBUG, tts_tag(), "--------------------");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
+
+       return TTSD_ERROR_NONE;
+
+}
+
+
+/** Set callbacks of the current engine */
+int ttsd_engine_agent_set_private_data_set_cb(ttse_private_data_set_cb callback)
+{
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       if (NULL == g_engine_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] The engine is not valid");
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not loaded engine");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       g_engine_info->callbacks->private_data_set = callback;
+
+       return TTSD_ERROR_NONE;
+}
+
+int ttsd_engine_agent_set_private_data_requested_cb(ttse_private_data_requested_cb callback)
+{
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       if (NULL == g_engine_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] The engine is not valid");
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (false == g_engine_info->is_loaded) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not loaded engine");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       g_engine_info->callbacks->private_data_requested = callback;
+
+       return TTSD_ERROR_NONE;
+}
+
+
index 4434c44..c3eda4f 100644 (file)
 extern "C" {
 #endif
 
-typedef int (*synth_result_callback)(ttsp_result_event_e event, const void* data, unsigned int data_size, 
-                                    ttsp_audio_type_e audio_type, int rate, void *user_data);
 
 /*
 * tts Engine Agent Interfaces
 */
 
 /** Init engine agent */
-int ttsd_engine_agent_init(synth_result_callback result_cb);
+int ttsd_engine_agent_init();
 
 /** Release engine agent */
 int ttsd_engine_agent_release();
 
-/** Set current engine */
-int ttsd_engine_agent_initialize_current_engine();
-
 /** load current engine */
 int ttsd_engine_agent_load_current_engine();
 
+/** Set callbacks of the current engine */
+int ttsd_engine_agent_set_private_data_set_cb(ttse_private_data_set_cb callback);
+int ttsd_engine_agent_set_private_data_requested_cb(ttse_private_data_requested_cb callback);
+
 /** Unload current engine */
 int ttsd_engine_agent_unload_current_engine();
 
@@ -74,7 +73,7 @@ int ttsd_engine_load_voice(const char* lang, int vctype);
 
 int ttsd_engine_unload_voice(const char* lang, int vctype);
 
-int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, int speed, const char* credential, void* user_param);
+int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, int speed, const char* appid, const char* credential, void* user_param);
 
 int ttsd_engine_cancel_synthesis();
 
index 4565cfb..34fd6ca 100644 (file)
 
 static Ecore_Timer* g_check_client_timer = NULL;
 
-const char* get_tag()
-{
-       return "ttsd";
-}
-
 const char* tts_tag()
 {
        return "ttsd";
@@ -37,63 +32,3 @@ ttsd_mode_e ttsd_get_mode()
 {
        return TTSD_MODE_DEFAULT;
 }
-
-/* Main of TTS Daemon */
-int main()
-{
-       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, get_tag(), "[Main ERROR] Fail ecore_init()");
-               return -1;
-       }
-
-       if (0 != ttsd_dbus_open_connection()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to open dbus connection");
-               return EXIT_FAILURE;
-       }
-
-       if (0 != ttsd_initialize()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to initialize tts-daemon"); 
-               return EXIT_FAILURE;
-       }
-
-       if (0 != ttsd_network_initialize()) {
-               SLOG(LOG_WARN, get_tag(), "[Main WARNING] Fail to initialize network");
-       }
-
-       g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
-       if (NULL == g_check_client_timer) {
-               SLOG(LOG_WARN, get_tag(), "[Main Warning] Fail to create timer of client check");
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon start..."); 
-       SLOG(LOG_DEBUG, get_tag(), "=====");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-       
-       ecore_main_loop_begin();
-
-       SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON DEFAULT FINALIZE");
-
-       if (NULL != g_check_client_timer) {
-               ecore_timer_del(g_check_client_timer);
-       }
-
-       ttsd_dbus_close_connection();
-
-       ttsd_network_finalize();
-
-       ttsd_finalize();
-
-       ecore_shutdown();
-
-       SLOG(LOG_DEBUG, get_tag(), "=====");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
index d440129..05f4a10 100644 (file)
@@ -25,7 +25,7 @@
 #include <dlog.h>
 #include <errno.h>
 
-#include "ttsp.h"
+#include "ttse.h"
 #include "tts_defs.h"
 
 #ifdef __cplusplus
@@ -76,11 +76,37 @@ typedef struct {
        int type;
 } voice_s;
 
+typedef struct {
+       int version;
+
+       ttse_get_info_cb                        get_info;
+
+       ttse_initialize_cb                      initialize;
+       ttse_deinitialize_cb                    deinitialize;
+
+       ttse_foreach_supported_voices_cb        foreach_voices;
+       ttse_is_valid_voice_cb                  is_valid_voice;
+       ttse_set_pitch_cb                       set_pitch;
+
+       ttse_load_voice_cb                      load_voice;
+       ttse_unload_voice_cb                    unload_voice;
+
+       ttse_start_synthesis_cb                 start_synth;
+       ttse_cancel_synthesis_cb                cancel_synth;
+
+       ttse_check_app_agreed_cb                check_app_agreed;
+       ttse_need_app_credential_cb             need_app_credential;
+       ttse_private_data_set_cb                private_data_set;
+       ttse_private_data_requested_cb          private_data_requested;
+} tts_engine_callback_s;
+
+
 /* get daemon mode : default, notification or screen reader */
 ttsd_mode_e ttsd_get_mode();
 
 /* Get log tag : default, notification, screen reader */
-const char* get_tag();
+//const char* get_tag();
+const char* tts_tag();
 
 #ifdef __cplusplus
 }
diff --git a/server/ttsd_main_noti.c b/server/ttsd_main_noti.c
deleted file mode 100644 (file)
index c517503..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-*  Copyright (c) 2011-2016 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 <Ecore.h>
-
-#define CLIENT_CLEAN_UP_TIME 500
-
-static Ecore_Timer* g_check_client_timer = NULL;
-
-const char* get_tag()
-{
-       return "ttsdnoti";
-}
-
-const char* tts_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_dbus_open_connection()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to open dbus connection");
-               return EXIT_FAILURE;
-       }
-
-       if (0 != ttsd_initialize()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to initialize tts-daemon-noti"); 
-               return EXIT_FAILURE;
-       }
-
-       if (0 != ttsd_network_initialize()) {
-               SLOG(LOG_WARN, get_tag(), "[Main WARNING] Fail to initialize network");
-       }
-
-       g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
-       if (NULL == g_check_client_timer) {
-               SLOG(LOG_WARN, get_tag(), "[Main Warning] Fail to create timer of client check");
-       }
-
-       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(), "  ");
-       
-       ecore_main_loop_begin();
-
-       SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON NOTI FINALIZE");
-
-       if (NULL != g_check_client_timer) {
-               ecore_timer_del(g_check_client_timer);
-       }
-
-       ttsd_dbus_close_connection();
-
-       ttsd_network_finalize();
-
-       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
deleted file mode 100644 (file)
index 97e2461..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-*  Copyright (c) 2011-2016 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 <Ecore.h>
-
-#define CLIENT_CLEAN_UP_TIME 500
-
-static Ecore_Timer* g_check_client_timer = NULL;
-
-const char* get_tag()
-{
-       return "ttsdsr";
-}
-
-const char* tts_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_dbus_open_connection()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to open dbus connection");
-               return EXIT_FAILURE;
-       }
-
-       if (0 != ttsd_initialize()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to initialize tts-daemon-sr"); 
-               return EXIT_FAILURE;
-       }
-
-       if (0 != ttsd_network_initialize()) {
-               SLOG(LOG_WARN, get_tag(), "[Main WARNING] Fail to initialize network");
-       }
-
-       g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
-       if (NULL == g_check_client_timer) {
-               SLOG(LOG_WARN, get_tag(), "[Main Warning] Fail to create timer of client check");
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon-sr start..."); 
-       SLOG(LOG_DEBUG, get_tag(), "=====");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-       
-       ecore_main_loop_begin();
-
-       SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON SR FINALIZE");
-
-       if (NULL != g_check_client_timer) {
-               ecore_timer_del(g_check_client_timer);
-       }
-
-       ttsd_dbus_close_connection();
-
-       ttsd_network_finalize();
-
-       ttsd_finalize();
-
-       ecore_shutdown();
-
-       SLOG(LOG_DEBUG, get_tag(), "=====");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
index 9ee3cf5..748a345 100644 (file)
@@ -35,11 +35,11 @@ bool ttsd_network_is_connected()
        vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status);
 
        if (network_status == VCONFKEY_NETWORK_OFF) {
-               SLOG(LOG_WARN, get_tag(), "[Network] Current network connection is OFF.");
+               SLOG(LOG_WARN, tts_tag(), "[Network] Current network connection is OFF.");
                return false;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Network] Network status is %d", network_status);
+       SLOG(LOG_DEBUG, tts_tag(), "[Network] Network status is %d", network_status);
 
        return true;
 }
\ No newline at end of file
index 6f41654..8a6dec4 100644 (file)
@@ -36,7 +36,7 @@ typedef struct {
        app_state_e             state;  /** client state */
 
        /* Current utterance information */
-       ttsp_result_event_e     event;  /** event of last utterance */
+       ttse_result_event_e     event;  /** event of last utterance */
 
        bool                    is_paused_data;
        int                     idx;
@@ -57,7 +57,7 @@ static player_s* g_playing_info;
 /* player state */
 static audio_state_e g_audio_state;
 
-static ttsp_audio_type_e g_audio_type;
+static ttse_audio_type_e g_audio_type;
 
 static int g_sampling_rate;
 
@@ -96,10 +96,10 @@ player_s* __player_get_item(int uid)
 
 void __player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *extra_info, void *user_data)
 {
-       SLOG(LOG_DEBUG, get_tag(), "===== Focus state changed cb");
+       SLOG(LOG_DEBUG, tts_tag(), "===== Focus state changed cb");
 
        if (stream_info != g_stream_info_h) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Invalid stream info handle");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Invalid stream info handle");
                return;
        }
 
@@ -107,18 +107,18 @@ void __player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus
        sound_stream_focus_state_e state_for_playback ;
        ret = sound_manager_get_focus_state(g_stream_info_h, &state_for_playback, NULL);
        if (SOUND_MANAGER_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to get focus state");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to get focus state");
                return;
        }
 
-       SLOG(LOG_WARN, get_tag(), "[Player] focus state changed to (%d) with reason(%d)", (int)state_for_playback, (int)reason_for_change);
+       SLOG(LOG_WARN, tts_tag(), "[Player] focus state changed to (%d) with reason(%d)", (int)state_for_playback, (int)reason_for_change);
 
        if (AUDIO_STATE_PLAY == g_audio_state && SOUND_STREAM_FOCUS_STATE_RELEASED == state_for_playback) {
                if (TTSD_MODE_DEFAULT == ttsd_get_mode()) {
                        g_audio_state = AUDIO_STATE_READY;
        
                        if (NULL == g_playing_info) {
-                               SLOG(LOG_WARN, get_tag(), "[Player WARNING] No current player");
+               SLOG(LOG_WARN, tts_tag(), "[Player WARNING] No current player");
                                return;
                        }
 
@@ -133,22 +133,22 @@ void __player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus
                                ttsdc_send_set_state_message(pid, g_playing_info->uid, APP_STATE_PAUSED);
                        }
                } else {
-                       SLOG(LOG_DEBUG, get_tag(), "[Player] Ignore focus state cb - mode(%d)", ttsd_get_mode());
+                       SLOG(LOG_DEBUG, tts_tag(), "[Player] Ignore focus state cb - mode(%d)", ttsd_get_mode());
                }
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "=====");
-       SLOG(LOG_DEBUG, get_tag(), "");
+       SLOG(LOG_DEBUG, tts_tag(), "=====");
+       SLOG(LOG_DEBUG, tts_tag(), "");
 
        return;
 }
 
-static int __create_audio_out(ttsp_audio_type_e type, int rate)
+static int __create_audio_out(ttse_audio_type_e type, int rate)
 {
        int ret = -1;
        audio_sample_type_e sample_type;
 
-       if (TTSP_AUDIO_TYPE_RAW_S16 == type) {
+       if (TTSE_AUDIO_TYPE_RAW_S16 == type) {
                sample_type = AUDIO_SAMPLE_TYPE_S16_LE;
        } else {
                sample_type = AUDIO_SAMPLE_TYPE_U8;
@@ -158,10 +158,10 @@ static int __create_audio_out(ttsp_audio_type_e type, int rate)
        if (AUDIO_IO_ERROR_NONE != ret) {
                g_audio_state = AUDIO_STATE_NONE;
                g_audio_h = NULL;
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to create audio");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to create audio");
                return -1;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Create audio");
+               SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Create audio");
        }
 
        g_audio_type = type;
@@ -175,17 +175,17 @@ static int __create_audio_out(ttsp_audio_type_e type, int rate)
 static int __destroy_audio_out()
 {
        if (NULL == g_audio_h) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Current handle is not valid");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Current handle is not valid");
                return -1;
        }
 
        int ret = -1;
        ret = audio_out_destroy(g_audio_h);
        if (AUDIO_IO_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to destroy audio");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to destroy audio");
                return -1;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Destroy audio");
+               SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Destroy audio");
        }
 
        g_audio_type = 0;
@@ -199,7 +199,7 @@ static int __destroy_audio_out()
 
 static void __end_play_thread(void *data, Ecore_Thread *thread)
 {
-       SLOG(LOG_ERROR, get_tag(), "===== End thread");
+       SLOG(LOG_ERROR, tts_tag(), "===== End thread");
 }
 
 static void __set_policy_for_playing(int volume)
@@ -209,41 +209,25 @@ static void __set_policy_for_playing(int volume)
        if (TTSD_MODE_DEFAULT == ttsd_get_mode()) {
                ret = sound_manager_acquire_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
                if (SOUND_MANAGER_ERROR_NONE != ret) {
-                       SLOG(LOG_WARN, get_tag(), "[Player WARNING] Fail to acquire focus");
+                       SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to acquire focus");
                }
                ret = audio_out_set_stream_info(g_audio_h, g_stream_info_h);
                if (AUDIO_IO_ERROR_NONE != ret) {
-                       SLOG(LOG_WARN, get_tag(), "[Player WARNING] Fail to set stream info");
+                       SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to set stream info");
                }
        }
 
-       /* Set volume policy */
-/*
-       SLOG(LOG_WARN, get_tag(), "[Player WARNING] set volume policy");
-       ret = sound_manager_set_volume_voice_policy(volume);
-       if (SOUND_MANAGER_ERROR_NONE != ret) {
-               SLOG(LOG_WARN, get_tag(), "[Player WARNING] Fail to set volume policy");
-       }
-*/
        return;
 }
 
 static void __unset_policy_for_playing()
 {
        int ret;
-       /* Unset volume policy */
-/*
-       SLOG(LOG_WARN, get_tag(), "[Player WARNING] unset volume policy");
-       ret = sound_manager_unset_volume_voice_policy();
-       if (SOUND_MANAGER_ERROR_NONE != ret) {
-               SLOG(LOG_WARN, get_tag(), "[Player WARNING] Fail to unset volume policy");
-       }
-*/
        /* Unset stream info */
        if (TTSD_MODE_DEFAULT == ttsd_get_mode()) {
                ret = sound_manager_release_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
                if (SOUND_MANAGER_ERROR_NONE != ret) {
-                       SLOG(LOG_WARN, get_tag(), "[Player WARNING] Fail to release focus");
+                       SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to release focus");
                }
        }
 
@@ -252,10 +236,10 @@ static void __unset_policy_for_playing()
 
 static void __play_thread(void *data, Ecore_Thread *thread)
 {
-       SLOG(LOG_DEBUG, get_tag(), "===== Start thread");
+       SLOG(LOG_DEBUG, tts_tag(), "===== Start thread");
 
        if (NULL == g_playing_info) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] No current player");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] No current player");
                return;
        }
 
@@ -283,9 +267,9 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                /* Request unprepare */
                                ret = audio_out_unprepare(g_audio_h);
                                if (AUDIO_IO_ERROR_NONE != ret) {
-                                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+                                       SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
                                } else {
-                                       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Unprepare audio");
+                                       SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
                                }
 
                                g_audio_state = AUDIO_STATE_READY;
@@ -294,20 +278,20 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                __unset_policy_for_playing();
                                return;
                        }
-                       SLOG(LOG_INFO, get_tag(), "[Player] Sound info : id(%d) data(%p) size(%d) audiotype(%d) rate(%d) event(%d)", 
+                       SLOG(LOG_INFO, tts_tag(), "[Player] Sound info : id(%d) data(%p) size(%d) audiotype(%d) rate(%d) event(%d)", 
                                sound_data->utt_id, sound_data->data, sound_data->data_size, sound_data->audio_type, sound_data->rate, sound_data->event);
                } else {
                        sound_data = NULL;
                        ret = ttsd_data_get_sound_data(player->uid, &sound_data);
                        if (0 != ret || NULL == sound_data) {
                                /* empty queue */
-                               SLOG(LOG_DEBUG, get_tag(), "[Player] No sound data. Waiting mode");
+                               SLOG(LOG_DEBUG, tts_tag(), "[Player] No sound data. Waiting mode");
                                /* release audio & recover session */
                                ret = audio_out_unprepare(g_audio_h);
                                if (AUDIO_IO_ERROR_NONE != ret) {
-                                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+                                       SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
                                } else {
-                                       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Unprepare audio");
+                                       SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
                                }
                                g_audio_state = AUDIO_STATE_READY;
 
@@ -319,11 +303,11 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                        usleep(10000);
                                        if (NULL == g_playing_info) {
                                                /* current playing uid is replaced */
-                                               SLOG(LOG_DEBUG, get_tag(), "[Player] Finish thread");
+                                               SLOG(LOG_DEBUG, tts_tag(), "[Player] Finish thread");
                                                return;
                                        } else if (0 < ttsd_data_get_sound_data_size(player->uid)) {
                                                /* new audio data come */
-                                               SLOG(LOG_DEBUG, get_tag(), "[Player] Resume thread");
+                                               SLOG(LOG_DEBUG, tts_tag(), "[Player] Resume thread");
                                                break;
                                        }
                                }
@@ -341,22 +325,22 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                         * When previous wdata's event is 'finish' and current wdata's event is 'finish',
                         * the player should send utt started event.
                         */
-                       if (TTSP_RESULT_EVENT_START == sound_data->event ||
-                          (TTSP_RESULT_EVENT_FINISH == player->event && TTSP_RESULT_EVENT_FINISH == sound_data->event)) {
+                       if (TTSE_RESULT_EVENT_START == sound_data->event ||
+                          (TTSE_RESULT_EVENT_FINISH == player->event && TTSE_RESULT_EVENT_FINISH == sound_data->event)) {
                                int pid = ttsd_data_get_pid(player->uid);
 
                                if (pid <= 0) {
-                                       SLOG(LOG_WARN, get_tag(), "[Send WARNIING] Current player is not valid");
+                                       SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
                                        /* unset volume policy, volume will be 100% */
                                        __unset_policy_for_playing();
                                        return;
                                }
 
                                if (0 != ttsdc_send_utt_start_message(pid, player->uid, sound_data->utt_id)) {
-                                       SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", 
+                                       SLOG(LOG_ERROR, tts_tag(), "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", 
                                                pid, player->uid, sound_data->utt_id);
                                }
-                               SLOG(LOG_DEBUG, get_tag(), "[Player] Start utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
+                               SLOG(LOG_DEBUG, tts_tag(), "[Player] Start utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
                        }
 
                        /* Save last event to check utterance start */
@@ -364,35 +348,35 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                        idx = 0;
 
                        if (NULL == sound_data->data || 0 >= sound_data->data_size) {
-                               if (TTSP_RESULT_EVENT_FINISH == sound_data->event) {
-                                       SLOG(LOG_DEBUG, get_tag(), "No sound data");
+                               if (TTSE_RESULT_EVENT_FINISH == sound_data->event) {
+                                       SLOG(LOG_DEBUG, tts_tag(), "No sound data");
                                        /* send utterence finish signal */
                                        int pid = ttsd_data_get_pid(player->uid);
 
                                        if (pid <= 0) {
-                                               SLOG(LOG_WARN, get_tag(), "[Send WARNIING] Current player is not valid");
+                                               SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
                                                /* unset volume policy, volume will be 100% */
                                                __unset_policy_for_playing();
                                                return;
                                        }
                                        if (0 != ttsdc_send_utt_finish_message(pid, player->uid, sound_data->utt_id)) {
-                                               SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", 
+                                               SLOG(LOG_ERROR, tts_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", 
                                                        pid, player->uid, sound_data->utt_id);
                                        }
                                }
-                               SLOG(LOG_DEBUG, get_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
+                               SLOG(LOG_DEBUG, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
                                continue;
                        }
                }
 
                if (g_sampling_rate != sound_data->rate || g_audio_type != sound_data->audio_type) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Player] Change audio handle : org type(%d) org rate(%d)", g_audio_type, g_sampling_rate);
+                       SLOG(LOG_DEBUG, tts_tag(), "[Player] Change audio handle : org type(%d) org rate(%d)", g_audio_type, g_sampling_rate);
                        if (NULL != g_audio_h) {
                                __destroy_audio_out();
                        }
 
                        if (0 > __create_audio_out(sound_data->audio_type, sound_data->rate)) {
-                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to create audio out");
+                               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to create audio out");
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
                                return;
@@ -413,30 +397,30 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                /* Request prepare */
                                ret = audio_out_prepare(g_audio_h);
                                if (AUDIO_IO_ERROR_NONE != ret) {
-                                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to prepare audio : %d", ret);
+                                       SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to prepare audio : %d", ret);
                                        g_playing_info = NULL;
                                        /* unset volume policy, volume will be 100% */
                                        __unset_policy_for_playing();
                                        return;
                                }
-                               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Prepare audio");
+                               SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Prepare audio");
                                g_audio_state = AUDIO_STATE_PLAY;
                        }
 
                        char* temp_data = sound_data->data;
                        ret = audio_out_write(g_audio_h, &temp_data[idx], len);
                        if (0 > ret) {
-                               SLOG(LOG_WARN, get_tag(), "[Player WARNING] Fail to audio write - %d", ret);
+                               SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to audio write - %d", ret);
                        } else {
                                idx += len;
                        }
 
                        if (NULL == g_playing_info && APP_STATE_PAUSED != player->state) {
-                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Current player is NULL");
+                               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Current player is NULL");
                                g_audio_state = AUDIO_STATE_READY;
                                ret = audio_out_unprepare(g_audio_h);
                                if (AUDIO_IO_ERROR_NONE != ret) {
-                                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+                                       SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
                                }
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
@@ -462,14 +446,14 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                                player->idx = idx;
 
                                g_audio_state = AUDIO_STATE_READY;
-                               SLOG(LOG_DEBUG, get_tag(), "[Player] Stop player thread by pause");
+                               SLOG(LOG_DEBUG, tts_tag(), "[Player] Stop player thread by pause");
 
                                /* Request prepare */
                                ret = audio_out_unprepare(g_audio_h);
                                if (AUDIO_IO_ERROR_NONE != ret) {
-                                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+                                       SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
                                } else {
-                                       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Unprepare audio");
+                                       SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
                                }
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
@@ -480,14 +464,14 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                if (NULL == g_playing_info && APP_STATE_READY == player->state) {
                        /* player_stop */ 
                        g_audio_state = AUDIO_STATE_READY;
-                       SLOG(LOG_DEBUG, get_tag(), "[Player] Stop player thread");
+                       SLOG(LOG_DEBUG, tts_tag(), "[Player] Stop player thread");
 
                        /* Request prepare */
                        ret = audio_out_unprepare(g_audio_h);
                        if (AUDIO_IO_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+                               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
                        } else {
-                               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Unprepare audio");
+                               SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
                        }
 
                        if (NULL != sound_data) {
@@ -505,26 +489,26 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                }
 
                if ((APP_STATE_PLAYING == player->state || APP_STATE_PAUSED == player->state) &&
-                       (TTSP_RESULT_EVENT_FINISH == sound_data->event)) {
+                       (TTSE_RESULT_EVENT_FINISH == sound_data->event)) {
                        /* send utterence finish signal */
                        int pid = ttsd_data_get_pid(player->uid);
 
                        if (pid <= 0) {
-                               SLOG(LOG_WARN, get_tag(), "[Send WARNIING] Current player is not valid");
+                               SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
                                return;
                        }
 
                        if (0 != ttsdc_send_utt_finish_message(pid, player->uid, sound_data->utt_id)) {
-                               SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", 
+                               SLOG(LOG_ERROR, tts_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", 
                                        pid, player->uid, sound_data->utt_id);
                                /* unset volume policy, volume will be 100% */
                                __unset_policy_for_playing();
                                return;
                        }
 
-                       SLOG(LOG_DEBUG, get_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
+                       SLOG(LOG_DEBUG, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
                }
 
                if (NULL != sound_data) {
@@ -538,11 +522,11 @@ static void __play_thread(void *data, Ecore_Thread *thread)
                }
 
                if (NULL == g_playing_info) {
-                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Current player is NULL");
+                       SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Current player is NULL");
                        g_audio_state = AUDIO_STATE_READY;
                        ret = audio_out_unprepare(g_audio_h);
                        if (AUDIO_IO_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+                               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
                        }
                        /* unset volume policy, volume will be 100% */
                        __unset_policy_for_playing();
@@ -567,13 +551,15 @@ int ttsd_player_init()
 
        ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_INFORMATION, __player_focus_state_cb, NULL, &g_stream_info_h);
        if (SOUND_MANAGER_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to create stream info");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to create stream info");
                return -1;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Create stream info");
+               SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Create stream info");
        }
 
-       ret = __create_audio_out(TTSP_AUDIO_TYPE_RAW_S16, 16000);
+       ecore_thread_max_set(1);
+
+       ret = __create_audio_out(TTSE_AUDIO_TYPE_RAW_S16, 16000);
        if (0 != ret)
                return -1;
 
@@ -585,15 +571,15 @@ int ttsd_player_init()
 int ttsd_player_release(void)
 {
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        int ret;
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] ==========================");
-       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] Active thread count : %d", ecore_thread_active_get());
-       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] ==========================");
+       SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] ==========================");
+       SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] Active thread count : %d", ecore_thread_active_get());
+       SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] ==========================");
 
        /* The thread should be released */
        int thread_count = ecore_thread_active_get();
@@ -603,14 +589,14 @@ int ttsd_player_release(void)
 
                count++;
                if (20 == count) {
-                       SLOG(LOG_WARN, get_tag(), "[Player WARNING!!] Thread is blocked. Player release continue.");
+                       SLOG(LOG_WARN, tts_tag(), "[Player WARNING!!] Thread is blocked. Player release continue.");
                        break;
                }
 
                thread_count = ecore_thread_active_get();
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] Thread is released");
+       SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] Thread is released");
 
        ret = __destroy_audio_out();
        if (0 != ret)
@@ -618,9 +604,9 @@ int ttsd_player_release(void)
 
        ret = sound_manager_destroy_stream_information(g_stream_info_h);
        if (SOUND_MANAGER_ERROR_NONE != ret) {
-               SLOG(LOG_WARN, get_tag(), "[Player WARNING] Fail to destroy stream info");
+               SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to destroy stream info");
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Destroy stream info");
+               SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Destroy stream info");
        }
 
        /* clear g_player_list */
@@ -633,30 +619,30 @@ int ttsd_player_release(void)
 int ttsd_player_create_instance(int uid)
 {
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
                return -1;
        }
 
        /* Check uid is duplicated */
        if (NULL != __player_get_item(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is already registered", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%d) is already registered", uid);
                return -1;
        }
 
        player_s* new_client = (player_s*)calloc(1, sizeof(player_s));
        if (NULL == new_client) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to allocate memory");
-               return TTSP_ERROR_OUT_OF_MEMORY;
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to allocate memory");
+               return TTSE_ERROR_OUT_OF_MEMORY;
        }
 
        new_client->uid = uid;
-       new_client->event = TTSP_RESULT_EVENT_FINISH;
+       new_client->event = TTSE_RESULT_EVENT_FINISH;
        new_client->state = APP_STATE_READY;
        new_client->is_paused_data = false;
        new_client->idx = 0;
        new_client->paused_data = NULL;
        
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] Create player : uid(%d)", uid);
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Player] Create player : uid(%d)", uid);
 
        g_player_list = g_list_append(g_player_list, new_client);
 
@@ -666,14 +652,14 @@ int ttsd_player_create_instance(int uid)
 int ttsd_player_destroy_instance(int uid)
 {
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
                return -1;
        }
 
        player_s* current;
        current = __player_get_item(uid);
        if (NULL == current) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%d) is not valid", uid);
                return -1;
        }
 
@@ -709,7 +695,7 @@ int ttsd_player_destroy_instance(int uid)
                }
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[PLAYER Success] Destroy instance");
+       SLOG(LOG_DEBUG, tts_tag(), "[PLAYER Success] Destroy instance");
 
        return 0;
 }
@@ -717,25 +703,25 @@ int ttsd_player_destroy_instance(int uid)
 int ttsd_player_play(int uid)
 {
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
                return -1;
        }
 
        if (NULL != g_playing_info) {
                if (uid == g_playing_info->uid) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Player] uid(%d) has already played", g_playing_info->uid);
+                       SLOG(LOG_DEBUG, tts_tag(), "[Player] uid(%d) has already played", g_playing_info->uid);
                        return 0;
                } else {
-                       SLOG(LOG_WARN, get_tag(), "[Player WARNING] stop old player (%d)", g_playing_info->uid);
+                       SLOG(LOG_WARN, tts_tag(), "[Player WARNING] stop old player (%d)", g_playing_info->uid);
                        ttsd_player_stop(g_playing_info->uid);
                }
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player] start play : uid(%d)", uid);
+       SLOG(LOG_DEBUG, tts_tag(), "[Player] start play : uid(%d)", uid);
 
        /* Check sound queue size */
        if (0 == ttsd_data_get_sound_data_size(uid)) {
-               SLOG(LOG_WARN, get_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", uid);
+               SLOG(LOG_WARN, tts_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", uid);
                return -1;
        }
 
@@ -743,7 +729,7 @@ int ttsd_player_play(int uid)
        player_s* current;
        current = __player_get_item(uid);
        if (NULL == current) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%d) is not valid", uid);
                return -1;
        }
 
@@ -751,10 +737,10 @@ int ttsd_player_play(int uid)
 
        g_playing_info = current;
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] Active thread count : %d", ecore_thread_active_get());
+       SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] Active thread count : %d", ecore_thread_active_get());
 
        if (0 < ttsd_data_get_sound_data_size(current->uid)) {
-               SLOG(LOG_DEBUG, get_tag(), "[Player] Run thread");
+               SLOG(LOG_DEBUG, tts_tag(), "[Player] Run thread");
                ecore_thread_run(__play_thread, __end_play_thread, NULL, NULL);
        }
 
@@ -764,7 +750,7 @@ int ttsd_player_play(int uid)
 int ttsd_player_stop(int uid)
 {
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
                return -1;
        }
 
@@ -772,7 +758,7 @@ int ttsd_player_stop(int uid)
        player_s* current;
        current = __player_get_item(uid);
        if (NULL == current) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%d) is not valid", uid);
                return -1;
        }
 
@@ -783,7 +769,7 @@ int ttsd_player_stop(int uid)
                        g_playing_info = NULL;
                }
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Player] No current playing");
+               SLOG(LOG_DEBUG, tts_tag(), "[Player] No current playing");
        }
 
        if (true == current->is_paused_data) {
@@ -798,15 +784,15 @@ int ttsd_player_stop(int uid)
                }
        }
 
-       current->event = TTSP_RESULT_EVENT_FINISH;
+       current->event = TTSE_RESULT_EVENT_FINISH;
        current->state = APP_STATE_READY;
        current->is_paused_data = false;
        current->idx = 0;
 
        if (NULL == g_playing_info) {
-               SLOG(LOG_DEBUG, get_tag(), "[Player] ==========================");
-               SLOG(LOG_ERROR, get_tag(), "[Player] Active thread count : %d", ecore_thread_active_get());
-               SLOG(LOG_DEBUG, get_tag(), "[Player] ==========================");
+               SLOG(LOG_DEBUG, tts_tag(), "[Player] ==========================");
+               SLOG(LOG_ERROR, tts_tag(), "[Player] Active thread count : %d", ecore_thread_active_get());
+               SLOG(LOG_DEBUG, tts_tag(), "[Player] ==========================");
 
                /* The thread should be released */
                int thread_count = ecore_thread_active_get();
@@ -816,19 +802,19 @@ int ttsd_player_stop(int uid)
 
                        count++;
                        if (30 == count) {
-                               SLOG(LOG_WARN, get_tag(), "[Player WARNING!!] Thread is blocked. Player release continue.");
+                               SLOG(LOG_WARN, tts_tag(), "[Player WARNING!!] Thread is blocked. Player release continue.");
                                break;
                        }
 
                        thread_count = ecore_thread_active_get();
                }
 
-               SLOG(LOG_DEBUG, get_tag(), "[Player] ==========================");
-               SLOG(LOG_ERROR, get_tag(), "[Player] Active thread count : %d", ecore_thread_active_get());
-               SLOG(LOG_DEBUG, get_tag(), "[Player] ==========================");
+               SLOG(LOG_DEBUG, tts_tag(), "[Player] ==========================");
+               SLOG(LOG_ERROR, tts_tag(), "[Player] Active thread count : %d", ecore_thread_active_get());
+               SLOG(LOG_DEBUG, tts_tag(), "[Player] ==========================");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Stop player : uid(%d)", uid);
+       SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Stop player : uid(%d)", uid);
 
        return 0;
 }
@@ -836,7 +822,7 @@ int ttsd_player_stop(int uid)
 int ttsd_player_clear(int uid)
 {
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
                return -1;
        }
 
@@ -844,7 +830,7 @@ int ttsd_player_clear(int uid)
        player_s* current;
        current = __player_get_item(uid);
        if (NULL == current) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); 
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%d) is not valid", uid); 
                return -1;
        }
 
@@ -860,22 +846,22 @@ int ttsd_player_clear(int uid)
                }
        }
 
-       current->event = TTSP_RESULT_EVENT_FINISH;
+       current->event = TTSE_RESULT_EVENT_FINISH;
        current->state = APP_STATE_READY;
        current->is_paused_data = false;
        current->idx = 0;
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Clear player : uid(%d)", uid);
+       SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Clear player : uid(%d)", uid);
 
        return 0;
 }
 
 int ttsd_player_pause(int uid)
 {
-       SLOG(LOG_DEBUG, get_tag(), "[Player] pause player : uid(%d)", uid);
+       SLOG(LOG_DEBUG, tts_tag(), "[Player] pause player : uid(%d)", uid);
 
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
                return -1;
        }
 
@@ -883,7 +869,7 @@ int ttsd_player_pause(int uid)
        player_s* current;
        current = __player_get_item(uid);
        if (NULL == current) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid);
                return -1;
        }
 
@@ -899,9 +885,9 @@ int ttsd_player_pause(int uid)
 
        current->state = APP_STATE_PAUSED;
        
-       SLOG(LOG_DEBUG, get_tag(), "[Player] ==========================");
-       SLOG(LOG_ERROR, get_tag(), "[Player] Active thread count : %d", ecore_thread_active_get());
-       SLOG(LOG_DEBUG, get_tag(), "[Player] ==========================");
+       SLOG(LOG_DEBUG, tts_tag(), "[Player] ==========================");
+       SLOG(LOG_ERROR, tts_tag(), "[Player] Active thread count : %d", ecore_thread_active_get());
+       SLOG(LOG_DEBUG, tts_tag(), "[Player] ==========================");
 
        /* The thread should be released */
        int thread_count = ecore_thread_active_get();
@@ -911,28 +897,28 @@ int ttsd_player_pause(int uid)
 
                count++;
                if (30 == count) {
-                       SLOG(LOG_WARN, get_tag(), "[Player WARNING!!] Thread is blocked. Player release continue.");
+                       SLOG(LOG_WARN, tts_tag(), "[Player WARNING!!] Thread is blocked. Player release continue.");
                        break;
                }
 
                thread_count = ecore_thread_active_get();
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player] ==========================");
-       SLOG(LOG_ERROR, get_tag(), "[Player] Active thread count : %d", ecore_thread_active_get());
-       SLOG(LOG_DEBUG, get_tag(), "[Player] ==========================");
+       SLOG(LOG_DEBUG, tts_tag(), "[Player] ==========================");
+       SLOG(LOG_ERROR, tts_tag(), "[Player] Active thread count : %d", ecore_thread_active_get());
+       SLOG(LOG_DEBUG, tts_tag(), "[Player] ==========================");
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Pause player : uid(%d)", uid);
+       SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Pause player : uid(%d)", uid);
 
        return 0;
 }
 
 int ttsd_player_resume(int uid)
 {
-       SLOG(LOG_DEBUG, get_tag(), "[Player] Resume player : uid(%d)", uid);
+       SLOG(LOG_DEBUG, tts_tag(), "[Player] Resume player : uid(%d)", uid);
 
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
                return -1;
        }
 
@@ -940,7 +926,7 @@ int ttsd_player_resume(int uid)
        player_s* current;
        current = __player_get_item(uid);
        if (NULL == current) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] uid(%d) is not valid", uid);
                return -1;
        }
 
@@ -951,7 +937,7 @@ int ttsd_player_resume(int uid)
        current->state = APP_STATE_PLAYING;
        g_playing_info = current;
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player] Run thread");
+       SLOG(LOG_DEBUG, tts_tag(), "[Player] Run thread");
        ecore_thread_run(__play_thread, __end_play_thread, NULL, NULL);
 
        return 0;
@@ -960,7 +946,7 @@ int ttsd_player_resume(int uid)
 int ttsd_player_all_stop()
 {
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
+               SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Not Initialized");
                return -1;
        }
 
@@ -979,14 +965,14 @@ int ttsd_player_all_stop()
 
                        app_state_e state;
                        if (0 > ttsd_data_get_client_state(data->uid, &state)) {
-                               SLOG(LOG_ERROR, get_tag(), "[player ERROR] uid(%d) is not valid", data->uid);
+                               SLOG(LOG_ERROR, tts_tag(), "[player ERROR] uid(%d) is not valid", data->uid);
                                ttsd_player_destroy_instance(data->uid);
                                iter = g_list_next(iter);
                                continue;
                        }
 
                        if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state) {
-                               data->event = TTSP_RESULT_EVENT_FINISH;
+                               data->event = TTSE_RESULT_EVENT_FINISH;
                                data->state = APP_STATE_READY;
 
                                if (true == data->is_paused_data) {
@@ -1010,7 +996,7 @@ int ttsd_player_all_stop()
                }
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] player all stop!!");
+       SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] player all stop!!");
 
        return 0;
 }
index 4addebd..c133a7e 100644 (file)
@@ -23,7 +23,6 @@
 #include "ttsd_network.h"
 #include "ttsd_player.h"
 #include "ttsd_server.h"
-#include "ttsp.h"
 
 
 typedef enum {
@@ -38,7 +37,7 @@ typedef struct {
 } utterance_t;
 
 /* If current engine exist */
-static bool    g_is_engine;
+//static bool  g_is_engine;
 
 /* If engine is running */
 static ttsd_synthesis_control_e        g_synth_control;
@@ -89,7 +88,7 @@ static Eina_Bool __wait_synthesis(void *data)
 
 static int __synthesis(int uid, const char* credential)
 {
-       SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS  START");
+       SLOG(LOG_DEBUG, tts_tag(), "===== SYNTHESIS  START");
 
        speak_data_s* speak_data = NULL;
        if (0 == ttsd_data_get_speak_data(uid, &speak_data)) {
@@ -97,11 +96,16 @@ static int __synthesis(int uid, const char* credential)
                        return 0;
                }
 
+               int pid = ttsd_data_get_pid(uid);
+               char appid[128] = {0, };
+               if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
+                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id");
+               }
+
                if (NULL == speak_data->lang || NULL == speak_data->text) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Current data is NOT valid");
+                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Current data is NOT valid");
                        ttsd_server_stop(uid);
 
-                       int pid = ttsd_data_get_pid(uid);
                        ttsdc_send_set_state_message(pid, uid, APP_STATE_READY);
 
                        if (NULL != speak_data) {
@@ -121,18 +125,18 @@ static int __synthesis(int uid, const char* credential)
                g_utt.uid = uid;
                g_utt.uttid = speak_data->utt_id;
 
-               SLOG(LOG_DEBUG, get_tag(), "-----------------------------------------------------------");
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "ID : uid (%d), uttid(%d) ", g_utt.uid, g_utt.uttid);
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "Voice : langauge(%s), type(%d), speed(%d)", speak_data->lang, speak_data->vctype, speak_data->speed);
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "Text : %s", speak_data->text);
-               SECURE_SLOG(LOG_DEBUG, get_tag(), "Credential : %s", credential);
-               SLOG(LOG_DEBUG, get_tag(), "-----------------------------------------------------------");
+               SLOG(LOG_DEBUG, tts_tag(), "-----------------------------------------------------------");
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "ID : uid (%d), uttid(%d) ", g_utt.uid, g_utt.uttid);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "Voice : langauge(%s), type(%d), speed(%d)", speak_data->lang, speak_data->vctype, speak_data->speed);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "Text : %s", speak_data->text);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "Credential : %s", credential);
+               SLOG(LOG_DEBUG, tts_tag(), "-----------------------------------------------------------");
 
                int ret = 0;
                __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DOING);
-               ret = ttsd_engine_start_synthesis(speak_data->lang, speak_data->vctype, speak_data->text, speak_data->speed, credential, NULL);
+               ret = ttsd_engine_start_synthesis(speak_data->lang, speak_data->vctype, speak_data->text, speak_data->speed, appid, credential, NULL);
                if (0 != ret) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] * FAIL to start SYNTHESIS !!!! * ");
+                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to start SYNTHESIS !!!! * ");
 
                        __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
 
@@ -156,8 +160,8 @@ static int __synthesis(int uid, const char* credential)
                }
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS  END");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
+       SLOG(LOG_DEBUG, tts_tag(), "===== SYNTHESIS  END");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
 
        return 0;
 }
@@ -165,43 +169,47 @@ static int __synthesis(int uid, const char* credential)
 /*
 * TTS Server Callback Functions
 */
-int __synthesis_result_callback(ttsp_result_event_e event, const void* data, unsigned int data_size, 
-                               ttsp_audio_type_e audio_type, int rate, void *user_data)
+int ttsd_send_error(ttse_error_e error, const char* msg)
+{
+       return 0;
+}
+
+int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data)
+
 {
-       SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS RESULT CALLBACK START");
+       SLOG(LOG_DEBUG, tts_tag(), "===== SEND SYNTHESIS RESULT START");
 
        int uid = g_utt.uid;
        int uttid = g_utt.uttid;
 
        /* 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, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_START");
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) audiotype(%d) rate(%d)", 
+       if (TTSE_RESULT_EVENT_START == event || TTSE_RESULT_EVENT_CONTINUE == event || TTSE_RESULT_EVENT_FINISH == event) {
+               if (TTSE_RESULT_EVENT_START == event) {
+                       SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_START");
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) audiotype(%d) rate(%d)", 
                                uid, uttid, data, data_size, audio_type, rate);
-               } else if (TTSP_RESULT_EVENT_FINISH == event) {
-                       SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_FINISH");
-                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) audiotype(%d) rate(%d)", 
+               } else if (TTSE_RESULT_EVENT_FINISH == event) {
+                       SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_FINISH");
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) audiotype(%d) rate(%d)", 
                                uid, uttid, data, data_size, audio_type, rate);
                } else {
-                       /*if (TTSP_RESULT_EVENT_CONTINUE == event)  SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_CONTINUE");*/
+                       /*if (TTSE_RESULT_EVENT_CONTINUE == event)  SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_CONTINUE");*/
                }
 
 
                if (false == ttsd_data_is_uttid_valid(uid, uttid)) {
                        __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
-                       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(), "  ");
+                       SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] uttid is NOT valid !!!! - uid(%d), uttid(%d)", uid, uttid);
+                       SLOG(LOG_DEBUG, tts_tag(), "=====");
+                       SLOG(LOG_DEBUG, tts_tag(), "  ");
                        return 0;
                }
 
-               if (rate <= 0 || audio_type < 0 || audio_type > TTSP_AUDIO_TYPE_MAX) {
+               if (rate <= 0 || audio_type < 0 || audio_type > TTSE_AUDIO_TYPE_MAX) {
                        __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
-                       SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] audio data is invalid");
-                       SLOG(LOG_DEBUG, get_tag(), "=====");
-                       SLOG(LOG_DEBUG, get_tag(), "  ");
+                       SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] audio data is invalid");
+                       SLOG(LOG_DEBUG, tts_tag(), "=====");
+                       SLOG(LOG_DEBUG, tts_tag(), "  ");
                        return 0;
                }
 
@@ -209,7 +217,7 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
                sound_data_s* temp_sound_data = NULL;
                temp_sound_data = (sound_data_s*)calloc(1, sizeof(sound_data_s));
                if (NULL == temp_sound_data) {
-                       SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] Out of memory");
+                       SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Out of memory");
                        return 0;
                }
                
@@ -222,13 +230,13 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
                        if (NULL != temp_sound_data->data) {
                                memcpy(temp_sound_data->data, data, data_size);
                                temp_sound_data->data_size = data_size;
-                               SLOG(LOG_ERROR, get_tag(), "[DEBUG][free] uid(%d), event(%d) sound_data(%p) data(%p) size(%d)", 
+                               SLOG(LOG_ERROR, tts_tag(), "[DEBUG][free] uid(%d), event(%d) sound_data(%p) data(%p) size(%d)", 
                                        uid, event, temp_sound_data, temp_sound_data->data, temp_sound_data->data_size);
                        } else {
-                               SLOG(LOG_ERROR, get_tag(), "Fail to allocate memory");
+                               SLOG(LOG_ERROR, tts_tag(), "Fail to allocate memory");
                        }
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "Sound data is NULL");
+                       SLOG(LOG_ERROR, tts_tag(), "Sound data is NULL");
                }
 
                temp_sound_data->utt_id = uttid;
@@ -237,15 +245,15 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
                temp_sound_data->rate = rate;
 
                if (0 != ttsd_data_add_sound_data(uid, temp_sound_data)) {
-                       SECURE_SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] Fail to add sound data : uid(%d)", uid);
+                       SECURE_SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Fail to add sound data : uid(%d)", uid);
                }
 
-               if (event == TTSP_RESULT_EVENT_FINISH) {
+               if (event == TTSE_RESULT_EVENT_FINISH) {
                        __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
                }
 
                if (0 != ttsd_player_play(uid)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to play sound : uid(%d)", uid);
+                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to play sound : uid(%d)", uid);
 
                        /* Change ready state */
                        ttsd_server_stop(uid);
@@ -255,13 +263,13 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
                        ttsdc_send_set_state_message(tmp_pid, uid, APP_STATE_READY);
                }
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_ERROR");
+               SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_ERROR");
                __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
        }
 
 
-       /*SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS RESULT CALLBACK END");
-       SLOG(LOG_DEBUG, get_tag(), "  ");*/
+       /*SLOG(LOG_DEBUG, tts_tag(), "===== SYNTHESIS RESULT CALLBACK END");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");*/
 
        return 0;
 }
@@ -286,22 +294,23 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
        switch (type) {
        case TTS_CONFIG_TYPE_ENGINE:
        {
+               /* TODO - Determine the policy when engine process get engine changed cb */
                if (NULL == str_param) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server] engine id from config is NULL");
+                       SLOG(LOG_ERROR, tts_tag(), "[Server] engine id from config is NULL");
                        return;
                }
 
                int ret = 0;
                if (true == ttsd_engine_agent_is_same_engine(str_param)) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Server Setting] new engine is the same as current engine");
+                       SLOG(LOG_DEBUG, tts_tag(), "[Server Setting] new engine is the same as current engine");
                        ret = ttsd_engine_agent_unload_current_engine();
                        if (0 != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to unload current engine : result(%d)", ret);
+                               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to unload current engine : result(%d)", ret);
                        }
 
                        ret = ttsd_engine_agent_load_current_engine();
                        if (0 != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to load current engine : result (%d)", ret);
+                               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to load current engine : result (%d)", ret);
                        }
                        return;
                }
@@ -314,19 +323,13 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
 
                ttsd_engine_cancel_synthesis();
 
-               /* set engine */
-               ret = ttsd_engine_agent_set_default_engine(str_param);
-               if (0 != ret) {
-                       SLOG(LOG_WARN, get_tag(), "[Server Setting WARNING] Fail to set current engine : result(%d)", ret);
-               }
-
                break;
        }
 
        case TTS_CONFIG_TYPE_VOICE:
        {
                if (NULL == str_param) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server] language from config is NULL");
+                       SLOG(LOG_ERROR, tts_tag(), "[Server] language from config is NULL");
                        return;
                }
 
@@ -335,13 +338,13 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
                int ret = -1;
 
                if (true == ttsd_engine_select_valid_voice(str_param, int_param, &out_lang, &out_type)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server] valid language : lang(%s), type(%d)", out_lang, out_type);
+                       SLOG(LOG_ERROR, tts_tag(), "[Server] valid language : lang(%s), type(%d)", out_lang, out_type);
                        ret = ttsd_engine_agent_set_default_voice(out_lang, out_type);
                        if (0 != ret)
-                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set valid language : lang(%s), type(%d)", out_lang, out_type);
+                               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set valid language : lang(%s), type(%d)", out_lang, out_type);
                } else {
                        /* Current language is not available */
-                       SLOG(LOG_WARN, get_tag(), "[Server WARNING] Fail to set voice : lang(%s), type(%d)", str_param, int_param);
+                       SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Fail to set voice : lang(%s), type(%d)", str_param, int_param);
                }
                if (NULL != out_lang)   free(out_lang);
                break;
@@ -354,7 +357,7 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
                        int ret = 0;
                        ret = ttsd_engine_agent_set_default_speed(int_param);
                        if (0 != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set default speed : result(%d)", ret);
+                               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set default speed : result(%d)", ret);
                        }       
                }
                break;
@@ -367,7 +370,7 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
                        int ret = 0;
                        ret = ttsd_engine_agent_set_default_pitch(int_param);
                        if (0 != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set default pitch : result(%d)", ret);
+                               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set default pitch : result(%d)", ret);
                        }       
                }
                break;
@@ -382,7 +385,7 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
 
 bool __terminate_client(int pid, int uid, app_state_e state, void* user_data)
 {
-       SLOG(LOG_DEBUG, get_tag(), "=== Start to terminate client [%d] ===", uid);
+       SLOG(LOG_DEBUG, tts_tag(), "=== Start to terminate client [%d] ===", uid);
        ttsd_server_finalize(uid);
        return true;
 }
@@ -396,10 +399,10 @@ Eina_Bool ttsd_terminate_daemon(void *data)
 void __screen_reader_changed_cb(bool value)
 {
        if (TTSD_MODE_SCREEN_READER == ttsd_get_mode() && false == value) {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] Screen reader is OFF. Start to terminate tts daemon");
+               SLOG(LOG_DEBUG, tts_tag(), "[Server] Screen reader is OFF. Start to terminate tts daemon");
                ecore_timer_add(1, ttsd_terminate_daemon, NULL);
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] Screen reader is %s", value ? "ON" : "OFF");
+               SLOG(LOG_DEBUG, tts_tag(), "[Server] Screen reader is %s", value ? "ON" : "OFF");
        }
        return;
 }
@@ -434,33 +437,38 @@ static void __register_sig_handler()
        signal(SIGQUIT, __sig_handler);
 }
 
-int ttsd_initialize()
+int ttsd_initialize(ttse_request_callback_s *callback)
 {
        /* Register signal handler */
        __register_sig_handler();
        
        if (ttsd_config_initialize(__config_changed_cb)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server WARNING] Fail to initialize config.");
+               SLOG(LOG_ERROR, tts_tag(), "[Server WARNING] Fail to initialize config.");
        }
 
        /* player init */
        if (ttsd_player_init()) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to initialize player init.");
+               SLOG(LOG_ERROR, tts_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, get_tag(), "[Server ERROR] Fail to engine agent initialize.");
+       if (0 != ttsd_engine_agent_init()) {
+               SLOG(LOG_ERROR, tts_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, get_tag(), "[Server WARNING] No Engine !!!");
-               g_is_engine = false;
-       } else
-               g_is_engine = true;
+       //if (0 != ttsd_engine_agent_initialize_current_engine(callback)) {
+       //      SLOG(LOG_WARN, tts_tag(), "[Server WARNING] No Engine !!!" );
+       //      g_is_engine = false;
+       //} else
+       //      g_is_engine = true;
+
+       if (0 != ttsd_engine_agent_load_current_engine(callback)) {
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to load current engine");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
 
        __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
 
@@ -492,6 +500,47 @@ int ttsd_finalize()
        return TTSD_ERROR_NONE;
 }
 
+/*
+* TTS Server Functions for Client
+*/
+
+int ttsd_server_initialize(int pid, int uid, bool* credential_needed)
+{
+       if (-1 != ttsd_data_is_client(uid)) {
+               SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Uid has already been registered");
+               return TTSD_ERROR_NONE;
+       }
+
+       if (0 != ttsd_engine_agent_is_credential_needed(uid, credential_needed)) {
+               SLOG(LOG_ERROR, tts_tag(), "Server ERROR] Fail to get credential necessity");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+       if (0 != ttsd_data_new_client(pid, uid)) {
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add client info");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       if (0 != ttsd_player_create_instance(uid)) {
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to create player");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       return TTSD_ERROR_NONE;
+}
+
+static Eina_Bool __quit_ecore_loop(void *data)
+{
+       ttsd_dbus_close_connection();
+
+       ttsd_network_finalize();
+
+       ttsd_finalize();
+
+       ecore_main_loop_quit();
+       return EINA_FALSE;
+}
+
+
 static void __read_proc()
 {
        DIR *dp = NULL;
@@ -512,12 +561,12 @@ static void __read_proc()
 
        dp = opendir("/proc");
        if (NULL == dp) {
-               SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to open proc");
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to open proc");
        } else {
                do {
                        ret = readdir_r(dp, &entry, &dirp);
                        if (0 != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to readdir");
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to readdir");
                                break;
                        }
 
@@ -542,7 +591,7 @@ bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_d
                iter = g_list_nth(g_proc_list, i);
                if (NULL != iter) {
                        if (pid == GPOINTER_TO_INT(iter->data)) {
-                               SLOG(LOG_DEBUG, get_tag(), "uid (%d) is running", uid);
+                               SLOG(LOG_DEBUG, tts_tag(), "uid (%d) is running", uid);
                                exist = true;
                                break;
                        }
@@ -550,7 +599,7 @@ bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_d
        }
        
        if (false == exist) {
-               SLOG(LOG_ERROR, get_tag(), "uid (%d) should be removed", uid);
+               SLOG(LOG_ERROR, tts_tag(), "uid (%d) should be removed", uid);
                ttsd_server_finalize(uid);
        }
 
@@ -558,22 +607,22 @@ bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_d
 #if 0
        char appid[128] = {0, };
        if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to get app id");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id");
        }
 
        if (0 < strlen(appid)) {
-               SLOG(LOG_DEBUG, get_tag(), "[%d] is running app - %s", pid, appid);
+               SLOG(LOG_DEBUG, tts_tag(), "[%d] is running app - %s", pid, appid);
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[%d] is daemon or no_running app", pid);
+               SLOG(LOG_DEBUG, tts_tag(), "[%d] is daemon or no_running app", pid);
 
                int result = 1;
                result = ttsdc_send_hello(pid, uid);
 
                if (0 == result) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) should be removed.", uid);
+                       SLOG(LOG_DEBUG, tts_tag(), "[Server] uid(%d) should be removed.", uid);
                        ttsd_server_finalize(uid);
                } else if (-1 == result) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Hello result has error");
+                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Hello result has error");
                }
        }
        return true;
@@ -583,72 +632,26 @@ 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, get_tag(), "===== CLEAN UP CLIENT START");
+       SLOG(LOG_DEBUG, tts_tag(), "===== CLEAN UP CLIENT START");
        __read_proc();
-       ttsd_data_foreach_clients(__get_client_for_clean_up, NULL);
-       SLOG(LOG_DEBUG, get_tag(), "=====");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return EINA_TRUE;
-}
 
-/*
-* TTS Server Functions for Client
-*/
-
-int ttsd_server_initialize(int pid, int uid, bool* credential_needed)
-{
-       if (false == g_is_engine) {
-               if (0 != ttsd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_WARN, get_tag(), "[Server WARNING] No Engine !!!");
-                       g_is_engine = false;
-
-                       return TTSD_ERROR_ENGINE_NOT_FOUND;
+       if (0 < ttsd_data_get_client_count()) {
+       ttsd_data_foreach_clients(__get_client_for_clean_up, NULL);
                } else {
-                       g_is_engine = true;
-               }
-       }
-
-       if (-1 != ttsd_data_is_client(uid)) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Uid has already been registered");
-               return TTSD_ERROR_NONE;
-       }
-
-       if (0 == ttsd_data_get_client_count()) {
-               if (0 != ttsd_engine_agent_load_current_engine()) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to load current engine");
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
-       }
-
-       if (0 != ttsd_engine_agent_is_credential_needed(uid, credential_needed)) {
-               SLOG(LOG_ERROR, get_tag(), "Server ERROR] Fail to get credential necessity");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-       if (0 != ttsd_data_new_client(pid, uid)) {
-               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, get_tag(), "[Server ERROR] Fail to create player");
-               return TTSD_ERROR_OPERATION_FAILED;
+               ecore_timer_add(0, __quit_ecore_loop, NULL);
        }
 
-       return TTSD_ERROR_NONE;
-}
+       SLOG(LOG_DEBUG, tts_tag(), "=====");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
 
-static Eina_Bool __quit_ecore_loop(void *data)
-{
-       ecore_main_loop_quit();
-       return EINA_FALSE;
+       return EINA_TRUE;
 }
 
 void __used_voice_cb(const char* lang, int type)
 {
-       SLOG(LOG_DEBUG, get_tag(), "[Server] Request to unload voice (%s,%d)", lang, type);
+       SLOG(LOG_DEBUG, tts_tag(), "[Server] Request to unload voice (%s,%d)", lang, type);
        if (0 != ttsd_engine_unload_voice(lang, type)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to unload voice");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to unload voice");
        }
 }
 
@@ -656,7 +659,7 @@ int ttsd_server_finalize(int uid)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_finalize : uid is not valid");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_finalize : uid is not valid");
        }
 
        ttsd_server_stop(uid);
@@ -666,7 +669,7 @@ int ttsd_server_finalize(int uid)
 
        /* Need to unload voice when used voice is unregistered */
        if (0 != ttsd_data_reset_used_voice(uid, __used_voice_cb)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set used voice");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set used voice");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -674,7 +677,7 @@ int ttsd_server_finalize(int uid)
 
        /* unload engine, if ref count of client is 0 */
        if (0 == ttsd_data_get_client_count()) {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] Quit main loop");
+               SLOG(LOG_DEBUG, tts_tag(), "[Server] Quit main loop");
                ecore_timer_add(0, __quit_ecore_loop, NULL);
        }
 
@@ -685,7 +688,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, get_tag(), "[Server ERROR] ttsd_server_add_queue : uid is not valid");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_add_queue : uid is not valid");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -693,20 +696,20 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
        char* temp_lang = NULL;
        int temp_type;
        if (true != ttsd_engine_select_valid_voice((const char*)lang, voice_type, &temp_lang, &temp_type)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to select valid voice");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to select valid voice");
                if (NULL != temp_lang)  free(temp_lang);
                return TTSD_ERROR_INVALID_VOICE;
        }
 
        if (NULL == temp_lang) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to select valid voice : result lang is NULL");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to select valid voice : result lang is NULL");
                return TTSD_ERROR_INVALID_VOICE;
        }
        
        speak_data_s* speak_data = NULL;
        speak_data = (speak_data_s*)calloc(1, sizeof(speak_data_s));
        if (NULL == speak_data) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to allocate memory");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory");
                if (NULL != temp_lang)  free(temp_lang);
                return TTSD_ERROR_OPERATION_FAILED;
        }
@@ -721,7 +724,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, speak_data)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to add speak data");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add speak data");
                if (NULL != temp_lang)  free(temp_lang);
                if (NULL != speak_data) {
                        if (NULL != speak_data->lang)   free(speak_data->lang);
@@ -739,9 +742,9 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
 
        if (0 != ttsd_data_set_used_voice(uid, temp_lang, temp_type)) {
                /* Request load voice */
-               SLOG(LOG_DEBUG, get_tag(), "[Server] Request to load voice");
+               SLOG(LOG_DEBUG, tts_tag(), "[Server] Request to load voice");
                if (0 != ttsd_engine_load_voice(temp_lang, temp_type)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to load voice");
+                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to load voice");
                }
        }
 
@@ -751,14 +754,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, get_tag(), "[Server ERROR] Disconnect network. Current engine needs network.");
+                               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Disconnect network. Current engine needs network.");
                                return TTSD_ERROR_OPERATION_FAILED;
                        }
                }
 
                /* Check whether tts-engine is running or not */
                if (TTSD_SYNTHESIS_CONTROL_DOING == __server_get_synth_control()) {
-                       SLOG(LOG_WARN, get_tag(), "[Server WARNING] Engine has already been running.");
+                       SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Engine has already been running.");
                } else {
                        __synthesis(uid, credential);
                }
@@ -788,37 +791,37 @@ int ttsd_server_play(int uid, const char* credential)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid(%d) is NOT valid  ", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid(%d) is NOT valid  ", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (APP_STATE_PLAYING == state) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state(%d) is 'play' ", uid);
+               SLOG(LOG_WARN, tts_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, get_tag(), "[Server ERROR] Disconnect network. Current engine needs network service!!!.");
+                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Disconnect network. Current engine needs network service!!!.");
                        return TTSD_ERROR_OUT_OF_NETWORK;
                }
        }
 
        int current_uid = ttsd_data_get_current_playing();
-       SLOG(LOG_ERROR, get_tag(), "[Server] playing uid (%d)", current_uid);
+       SLOG(LOG_ERROR, tts_tag(), "[Server] playing uid (%d)", current_uid);
 
        if (uid != current_uid && -1 != current_uid) {
                if (TTSD_MODE_DEFAULT != ttsd_get_mode()) {
                        /* Send interrupt message */
-                       SLOG(LOG_DEBUG, get_tag(), "[Server] Old uid(%d) will be interrupted into 'Stop' state ", current_uid);
+                       SLOG(LOG_DEBUG, tts_tag(), "[Server] Old uid(%d) will be interrupted into 'Stop' state ", current_uid);
 
                        /* pause player */
                        if (0 != ttsd_server_stop(current_uid)) {
-                               SLOG(LOG_WARN, get_tag(), "[Server ERROR] Fail to stop : uid (%d)", current_uid);
+                               SLOG(LOG_WARN, tts_tag(), "[Server ERROR] Fail to stop : uid (%d)", current_uid);
                        }
                        if (0 != ttsd_player_stop(current_uid)) {
-                               SLOG(LOG_WARN, get_tag(), "[Server ERROR] Fail to player stop : uid (%d)", current_uid);
+                               SLOG(LOG_WARN, tts_tag(), "[Server ERROR] Fail to player stop : uid (%d)", current_uid);
                        }
 
                        intptr_t pcurrent_uid = (intptr_t)current_uid;
@@ -827,11 +830,11 @@ int ttsd_server_play(int uid, const char* credential)
                        /* Default mode policy of interrupt is "Pause" */
 
                        /* Send interrupt message */
-                       SLOG(LOG_DEBUG, get_tag(), "[Server] Old uid(%d) will be interrupted into 'Pause' state ", current_uid);
+                       SLOG(LOG_DEBUG, tts_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, get_tag(), "[Server ERROR] Fail to ttsd_player_pause() : uid (%d)", current_uid);
+                               SLOG(LOG_WARN, tts_tag(), "[Server ERROR] Fail to ttsd_player_pause() : uid (%d)", current_uid);
                        }
 
                        /* change state */
@@ -844,22 +847,22 @@ int ttsd_server_play(int uid, const char* credential)
 
        /* Change current play */
        if (0 != ttsd_data_set_client_state(uid, APP_STATE_PLAYING)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set state : uid(%d)", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set state : uid(%d)", uid);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        if (APP_STATE_PAUSED == state) {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) is 'Pause' state : resume player", uid);
+               SLOG(LOG_DEBUG, tts_tag(), "[Server] uid(%d) is 'Pause' state : resume player", uid);
 
                /* Resume player */
                if (0 != ttsd_player_resume(uid)) {
-                       SLOG(LOG_WARN, get_tag(), "[Server WARNING] Fail to ttsd_player_resume()");
+                       SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Fail to ttsd_player_resume()");
                }
        }
 
        /* Check whether tts-engine is running or not */
        if (TTSD_SYNTHESIS_CONTROL_DOING == __server_get_synth_control()) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Engine has already been running.");
+               SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Engine has already been running.");
        } else {
                __synthesis(uid, credential);
        }
@@ -872,24 +875,24 @@ int ttsd_server_stop(int uid)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid is not valid");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid is not valid");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state) {
                if (TTSD_SYNTHESIS_CONTROL_DOING == __server_get_synth_control()) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Server] TTS-engine is running");
+                       SLOG(LOG_DEBUG, tts_tag(), "[Server] TTS-engine is running");
 
                        int ret = 0;
                        ret = ttsd_engine_cancel_synthesis();
                        if (0 != ret)
-                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to cancel synthesis : ret(%d)", ret);
+                               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to cancel synthesis : ret(%d)", ret);
                }
 
                __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
 
                if (0 != ttsd_player_clear(uid))
-                       SLOG(LOG_WARN, get_tag(), "[Server] Fail to ttsd_player_stop()");
+                       SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_player_stop()");
 
                ttsd_data_set_client_state(uid, APP_STATE_READY);
        }
@@ -904,19 +907,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, get_tag(), "[Server ERROR] ttsd_server_pause : uid is not valid");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_pause : uid is not valid");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (APP_STATE_PLAYING != state) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state is not 'play'");
+               SLOG(LOG_WARN, tts_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, get_tag(), "[Server ERROR] Fail player_pause() : ret(%d)", ret);
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail player_pause() : ret(%d)", ret);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -929,17 +932,18 @@ 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, get_tag(), "[Server ERROR] uid is not valid");
+               SLOG(LOG_ERROR, tts_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, get_tag(), "[Server ERROR] Fail ttsd_server_get_support_voices()");
-               return TTSD_ERROR_OPERATION_FAILED;
+       int ret = ttsd_engine_get_voice_list(voice_list); 
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail ttsd_server_get_support_voices() : ret(%d)", ret);
+               return ret;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Server SUCCESS] Get supported voices");
+       SLOG(LOG_DEBUG, tts_tag(), "[Server SUCCESS] Get supported voices");
 
        return TTSD_ERROR_NONE;
 }
@@ -948,18 +952,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, get_tag(), "[Server ERROR] ttsd_server_get_current_voice : uid is not valid");
+               SLOG(LOG_ERROR, tts_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, voice_type);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail ttsd_server_get_support_voices()");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail ttsd_server_get_support_voices() : ret(%d)", ret);
                return ret;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type);
+       SLOG(LOG_DEBUG, tts_tag(), "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type);
 
        return TTSD_ERROR_NONE;
 }
@@ -968,20 +972,20 @@ int ttsd_server_set_private_data(int uid, const char* key, const char* data)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid(%d) is NOT valid", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid(%d) is NOT valid", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (APP_STATE_READY != state) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Current state(%d) is NOT 'READY'", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Current state(%d) is NOT 'READY'", uid);
                return TTSD_ERROR_INVALID_STATE;
        }
 
        int ret = ttsd_engine_set_private_data(key, data);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set private data");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set private data : ret(%d)", ret);
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] Set private data");
+               SLOG(LOG_DEBUG, tts_tag(), "[Server] Set private data");
        }
 
        return ret;
@@ -991,21 +995,56 @@ int ttsd_server_get_private_data(int uid, const char* key, char** data)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid(%d) is NOT valid", uid);
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid(%d) is NOT valid", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (APP_STATE_READY != state) {
-               SLOG(LOG_WARN, get_tag(), "[Server ERROR] Current state(%d) is NOT 'READY'", uid);
+               SLOG(LOG_WARN, tts_tag(), "[Server ERROR] Current state(%d) is NOT 'READY'", uid);
                return TTSD_ERROR_INVALID_STATE;
        }
 
        int ret = ttsd_engine_get_private_data(key, data);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to get private data");
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get private data : ret(%d)", ret);
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] Get private data");
+               SLOG(LOG_DEBUG, tts_tag(), "[Server] Get private data");
+       }
+
+       return ret;
+}
+
+int ttsd_set_private_data_set_cb(ttse_private_data_set_cb callback)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "[Server] Set private data set cb");
+
+       int ret = 0;
+       ret = ttsd_engine_agent_set_private_data_set_cb(callback);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set private data set cb : ret(%d)", ret);
+       }
+
+       return ret;
+}
+
+int ttsd_set_private_data_requested_cb(ttse_private_data_requested_cb callback)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "[Server] Set private data requested cb");
+
+       int ret = 0;
+       ret = ttsd_engine_agent_set_private_data_requested_cb(callback);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set private data requested cb : ret(%d)", ret);
        }
 
        return ret;
-}
\ No newline at end of file
+}
+
+/*
+int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data)
+{}
+
+int ttsd_send_error(ttse_error_e error, const char* msg)
+{}
+*/
+
index d044f64..d2fadb9 100644 (file)
@@ -18,6 +18,8 @@
 #include <glib.h>
 #include <Ecore.h>
 
+#include "ttse.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -25,12 +27,20 @@ extern "C" {
 /**
 * Server APIs
 */
-int ttsd_initialize();
+int ttsd_initialize(ttse_request_callback_s *callback);
 
 int ttsd_finalize();
 
 Eina_Bool ttsd_cleanup_client(void *data);
 
+Eina_Bool ttsd_get_daemon_exist();
+
+int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data);
+int ttsd_send_error(ttse_error_e error, const char* msg);
+
+int ttsd_set_private_data_set_cb(ttse_private_data_set_cb callback);
+int ttsd_set_private_data_requested_cb(ttse_private_data_requested_cb callback);
+
 /*
 * Server API for client
 */
diff --git a/server/ttse.c b/server/ttse.c
new file mode 100755 (executable)
index 0000000..f18c724
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+*  Copyright (c) 2011-2016 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 <bundle.h>
+#include <bundle_internal.h>
+#include <dlog.h>
+#include <Ecore.h>
+
+#include "ttse.h"
+
+#define CLIENT_CLEAN_UP_TIME 500
+
+static Ecore_Timer* g_check_client_timer = NULL;
+
+static ttsd_mode_e g_tts_mode = TTSD_MODE_DEFAULT;
+
+const char* tts_tag()
+{
+       if (TTSD_MODE_NOTIFICATION == g_tts_mode) {
+               return "ttsdnoti";
+       } else if (TTSD_MODE_SCREEN_READER == g_tts_mode) {
+               return "ttsdsr";
+       } else {
+               return "ttsd";
+       }
+}
+
+ttsd_mode_e ttsd_get_mode()
+{
+       return g_tts_mode;
+}
+
+void ttsd_set_mode(ttsd_mode_e mode)
+{
+       g_tts_mode = mode;
+       return;
+}
+
+int ttse_main(int argc, char** argv, ttse_request_callback_s *callback)
+{
+       bundle *b = NULL;
+       ttsd_mode_e mode = TTSD_MODE_DEFAULT;
+
+       b = bundle_import_from_argv(argc, argv);
+       if (NULL != b) {
+               char *val = NULL;
+               if (0 == bundle_get_str(b, "mode", &val)) {
+                       if (NULL != val) {
+                               if (!strcmp("noti", val)) {
+                                       mode = TTSD_MODE_NOTIFICATION;
+                               } else if (!strcmp("sr", val)) {
+                                       mode = TTSD_MODE_SCREEN_READER;
+                               } else {
+                                       SLOG(LOG_WARN, tts_tag(), "[WARNING] mode (%s)", val);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] NULL data");
+                       }
+               } else {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get data from bundle");
+               }
+               bundle_free(b);
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get bundle");
+       }
+
+       ttsd_set_mode(mode);
+
+       SLOG(LOG_DEBUG, tts_tag(), "Start engine as [%d] mode", mode);
+
+       if (!ecore_init()) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to initialize Ecore");
+               return -1;
+       }
+
+       if (0 != ttsd_dbus_open_connection()) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to open dbus connection");
+               return -1;
+       }
+
+       if (0 != ttsd_initialize(callback)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to initialize");
+               return -1;
+       }
+
+       if (0 != ttsd_network_initialize()) {
+               SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to initialize network");
+       }
+
+       g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
+       if (NULL == g_check_client_timer) {
+               SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to create timer");
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "====");
+       SLOG(LOG_DEBUG, tts_tag(), "");
+
+       return 0;
+}
+
+int ttse_get_speed_range(int* min, int* normal, int* max)
+{
+       if (NULL == min || NULL == normal || NULL == max) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is null");
+               return TTSE_ERROR_INVALID_PARAMETER;
+       }
+
+       *min = TTS_SPEED_MIN;
+       *normal = TTS_SPEED_NORMAL;
+       *max = TTS_SPEED_MAX;
+
+       return 0;
+}
+
+int ttse_get_pitch_range(int* min, int* normal, int* max)
+{
+       if (NULL == min || NULL == normal || NULL == max) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is null");
+               return TTSE_ERROR_INVALID_PARAMETER;
+       }
+
+       *min = TTS_PITCH_MIN;
+       *normal = TTS_PITCH_NORMAL;
+       *max = TTS_PITCH_MAX;
+
+       return 0;
+}
+
+int ttse_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data)
+{
+       int ret;
+
+       if (NULL == data) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is null");
+               return TTSE_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = ttsd_send_result(event, data, data_size, audio_type, rate, user_data);
+
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to send result");
+       }
+
+       return ret;
+}
+
+int ttse_send_error(ttse_error_e error, const char* msg)
+{
+       int ret;
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is null");
+               return TTSE_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = ttsd_send_error(error, msg);
+
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to send error");
+       }
+
+       return ret;
+}
+
+int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func)
+{
+       int ret = ttsd_set_private_data_set_cb(callback_func);
+
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set private data set cb");
+       }
+
+       return ret;
+}
+
+int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_func)
+{
+       int ret = ttsd_set_private_data_requested_cb(callback_func);
+
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set private data requested cb");
+       }
+
+       return ret;
+}
diff --git a/server/ttsp.h b/server/ttsp.h
deleted file mode 100644 (file)
index 5bd6e7e..0000000
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
-*  Copyright (c) 2011-2016 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.
-*/
-
-
-#ifndef __TTSP_H__
-#define __TTSP_H__
-
-#include <errno.h>
-#include <stdbool.h>
-#include <tizen.h>
-
-/**
-* @addtogroup TTS_ENGINE_MODULE
-* @{
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** 
- * @brief Enumeration for error code.
-*/
-typedef enum {
-       TTSP_ERROR_NONE                         = TIZEN_ERROR_NONE,             /**< Successful */
-       TTSP_ERROR_OUT_OF_MEMORY                = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
-       TTSP_ERROR_IO_ERROR                     = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
-       TTSP_ERROR_INVALID_PARAMETER            = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
-       TTSP_ERROR_OUT_OF_NETWORK               = TIZEN_ERROR_NETWORK_DOWN,     /**< Network is down */
-       TTSP_ERROR_TIMED_OUT                    = TIZEN_ERROR_TIMED_OUT,        /**< No answer from the daemon */
-       TTSP_ERROR_PERMISSION_DENIED            = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
-       TTSP_ERROR_NOT_SUPPORTED                = TIZEN_ERROR_NOT_SUPPORTED,    /**< TTS NOT supported */
-       TTSP_ERROR_INVALID_STATE                = TIZEN_ERROR_TTS | 0x01,       /**< Invalid state */
-       TTSP_ERROR_INVALID_VOICE                = TIZEN_ERROR_TTS | 0x02,       /**< Invalid voice */
-       TTSP_ERROR_ENGINE_NOT_FOUND             = TIZEN_ERROR_TTS | 0x03,       /**< No available engine */
-       TTSP_ERROR_OPERATION_FAILED             = TIZEN_ERROR_TTS | 0x04,       /**< Operation failed */
-       TTSP_ERROR_AUDIO_POLICY_BLOCKED         = TIZEN_ERROR_TTS | 0x05,       /**< Audio policy blocked */
-       TTSP_ERROR_NOT_SUPPORTED_FEATURE        = TIZEN_ERROR_TTS | 0x06        /**< Not supported feature of current engine*/
-} ttsp_error_e;
-
-/**
-* @brief Enumerations of audio type.
-*/
-typedef enum {
-       TTSP_AUDIO_TYPE_RAW_S16 = 0,    /**< Signed 16-bit audio sample */
-       TTSP_AUDIO_TYPE_RAW_U8,         /**< Unsigned 8-bit audio sample */
-       TTSP_AUDIO_TYPE_MAX
-} ttsp_audio_type_e;
-
-/**
-* @brief Enumerations of result event type.
-*/
-typedef enum {
-       TTSP_RESULT_EVENT_FAIL          = -1, /**< event when the voice synthesis is failed */
-       TTSP_RESULT_EVENT_START         = 1,  /**< event when the sound data is first data by callback function */
-       TTSP_RESULT_EVENT_CONTINUE      = 2,  /**< event when the next sound data exist, not first and not last */
-       TTSP_RESULT_EVENT_FINISH        = 3   /**< event when the sound data is last data or sound data is only one result */
-} ttsp_result_event_e;
-
-/**
-* @brief Enumerations of TTS mode.
-*/
-typedef enum {
-       TTSP_MODE_DEFAULT       = 0,    /**< Default mode for normal application */
-       TTSP_MODE_NOTIFICATION  = 1,    /**< Notification mode */
-       TTSP_MODE_SCREEN_READER = 2     /**< Accessibiliity mode */
-} ttsp_mode_e;
-
-/** 
-* @brief Defines of voice type.
-*/
-#define TTSP_VOICE_TYPE_MALE   1
-#define TTSP_VOICE_TYPE_FEMALE 2
-#define TTSP_VOICE_TYPE_CHILD  3
-
-/** 
-* @brief Called when the daemon gets synthesized result.
-* 
-* @param[in] event A result event
-* @param[in] data Result data
-* @param[in] data_size Result data size
-* @param[in] audio_type A audio type 
-* @param[in] rate A sample rate 
-* @param[in] user_data The user data passed from the start synthesis function
-*
-* @return @c true to continue with the next iteration of synthesis \n @c false to stop
-*
-* @pre ttspe_start_synthesis() will invoke this callback.
-*
-* @see ttspe_start_synthesis()
-*/
-typedef bool (*ttspe_result_cb)(ttsp_result_event_e event, const void* data, unsigned int data_size, 
-                       ttsp_audio_type_e audio_type, int rate, void *user_data);
-
-/**
-* @brief Called when the daemon gets a language and a voice type.
-*
-* @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code
-*              followed by ISO 639-1 for the two-letter language code. \n
-*              For example, "ko_KR" for Korean, "en_US" for American English.
-* @param[in] type A voice type
-* @param[in] user_data The user data passed from the the foreach function
-*
-* @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
-*
-* @pre ttspe_foreach_supported_voices() will invoke this callback. 
-*
-* @see ttspe_foreach_supported_voices()
-*/
-typedef bool (*ttspe_supported_voice_cb)(const char* language, int type, void* user_data);
-
-/**
-* @brief Initializes the engine.
-*
-* @param[in] callbacks A callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_INVALID_STATE Already initialized
-* @retval #TTSP_ERROR_OPERATION_FAILED Operation failed
-* 
-* @see ttspe_deinitialize()
-*/
-typedef int (*ttspe_initialize)(ttspe_result_cb callback);
-
-/**
-* @brief Deinitializes the engine.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_STATE Not initialized
-* 
-* @see ttspe_initialize()
-*/
-typedef int (*ttspe_deinitialize)(void);
-
-/**
-* @brief Retrieves all supported voices of the engine using callback function.
-*
-* @param[in] callback A callback function
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_INVALID_STATE Not initialized
-*
-* @post        This function invokes ttspe_supported_voice_cb() repeatedly for getting all supported languages. 
-*
-* @see ttspe_supported_voice_cb()
-*/
-typedef int (*ttspe_foreach_supported_voices)(ttspe_supported_voice_cb callback, void* user_data);
-
-/**
-* @brief Checks whether the voice is valid or not.
-*
-* @param[in] language A language
-* @param[in] type A voice type
-*
-* @return @c true to be valid \n @c false not to be valid
-*
-* @see ttspe_foreach_supported_voices()
-*/
-typedef bool (*ttspe_is_valid_voice)(const char* language, int type);
-
-/**
-* @brief Sets default pitch.
-*
-* @param[in] pitch default pitch
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_INVALID_STATE Not initialized
-* @retval #TTSP_ERROR_OPERATION_FAILED Fail
-*/
-typedef int (*ttspe_set_pitch)(int pitch);
-
-/**
-* @brief Gets credential necessity.
-*
-* @return @c true to be needed app credential, \n @c false not to be needed app credential.
-*
-*/
-typedef bool (*ttspe_need_app_credential)(void);
-
-/**
-* @brief Load voice of the engine.
-*
-* @param[in] language language
-* @param[in] type voice type
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_INVALID_STATE Not initialized
-* @retval #TTSP_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #TTSP_ERROR_INVALID_VOICE Invalid voice
-* @retval #TTSP_ERROR_OPERATION_FAILED Fail
-*
-* @see ttspe_unload_voice()
-*/
-typedef int (*ttspe_load_voice)(const char* language, int type);
-
-/**
-* @brief Unload voice of the engine.
-*
-* @param[in] language language
-* @param[in] type voice type
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_INVALID_STATE Not initialized
-* @retval #TTSP_ERROR_INVALID_VOICE Invalid voice
-* @retval #TTSP_ERROR_OPERATION_FAILED Fail
-*
-* @see ttspe_load_voice()
-*/
-typedef int (*ttspe_unload_voice)(const char* language, int type);
-
-/**
-* @brief Starts voice synthesis, asynchronously.
-*
-* @param[in] language A language
-* @param[in] type A voice type
-* @param[in] text Texts
-* @param[in] speed A speaking speed
-* @parma[in] credential The app credential to allow recognition
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_INVALID_STATE Not initialized or already started synthesis
-* @retval #TTSP_ERROR_INVALID_VOICE Invalid voice
-* @retval #TTSP_ERROR_OPERATION_FAILED Operation failed
-* @retval #TTSP_ERROR_OUT_OF_NETWORK Out of network
-* @retval #TTSP_ERROR_PERMISSION_DENIED Permission denied
-*
-* @post This function invokes ttspe_result_cb().
-* 
-* @see ttspe_result_cb()
-* @see ttspe_cancel_synthesis()
-*/
-typedef int (*ttspe_start_synthesis)(const char* language, int type, const char* text, int speed, const char* credential, void* user_data);
-
-/**
-* @brief Cancels voice synthesis.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_STATE Not initialized or not started synthesis
-*
-* @pre The ttspe_start_synthesis() should be performed
-*
-* @see ttspe_start_synthesis()
-*/
-typedef int (*ttspe_cancel_synthesis)(void);
-
-/**
-* @brief Set private data.
-* @since_tizen 3.0
-*
-* @param[in] key Key field of private data.
-* @param[in] data Data field of private data.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSE_ERROR_NONE Successful
-* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSE_ERROR_OPERATION_FAILED Operation failed
-*
-* @see ttse_get_private_data()
-*/
-typedef int (* ttspe_set_private_data)(const char* key, const char* data);
-
-/**
-* @brief Get private data.
-* @since_tizen 3.0
-*
-* @param[out] key Key field of private data.
-* @param[out] data Data field of private data.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSE_ERROR_NONE Successful
-* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSE_ERROR_OPERATION_FAILED Operation failed
-*
-* @see ttse_set_private_data()
-*/
-typedef int (* ttspe_get_private_data)(const char* key, char** data);
-
-
-/**
-* @brief Gets the mode.
-*
-* @param[out] mode The tts daemon mode
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-*
-*/
-typedef int (*ttspd_get_mode)(ttsp_mode_e* mode);
-
-/**
-* @brief Gets the speed range.
-*
-* @param[out] min The minimun speed value
-* @param[out] normal The normal speed value
-* @param[out] max The maximum speed value
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-*
-*/
-typedef int (*ttspd_get_speed_range)(int* min, int* normal, int* max);
-
-/**
-* @brief Gets the pitch range.
-*
-* @param[out] min The minimun pitch value
-* @param[out] normal The normal pitch value
-* @param[out] max The maximum pitch value
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-*
-*/
-typedef int (*ttspd_get_pitch_range)(int* min, int* normal, int* max);
-
-/**
-* @brief A structure of the engine functions
-*/
-typedef struct {
-       int size;                                               /**< Size of structure */    
-       int version;                                            /**< Version */
-
-       ttspe_initialize                initialize;             /**< Initialize engine */
-       ttspe_deinitialize              deinitialize;           /**< Shutdown engine */
-
-       /* Get / Set engine information */
-       ttspe_foreach_supported_voices  foreach_voices;         /**< Get voice list */
-       ttspe_is_valid_voice            is_valid_voice;         /**< Check voice */
-       ttspe_set_pitch                 set_pitch;              /**< Set default pitch */
-
-       /* Load / Unload voice */
-       ttspe_load_voice                load_voice;             /**< Load voice */
-       ttspe_unload_voice              unload_voice;           /**< Unload voice */
-       ttspe_need_app_credential       need_app_credential;    /**< Get app credential necessity*/
-
-       /* Control synthesis */
-       ttspe_start_synthesis           start_synth;            /**< Start synthesis */
-       ttspe_cancel_synthesis          cancel_synth;           /**< Cancel synthesis */
-       ttspe_set_private_data          set_private_data;       /**< Set private data */
-       ttspe_get_private_data          get_private_data;       /**< Get private data */
-} ttspe_funcs_s;
-
-/**
-* @brief A structure of the daemon functions
-*/
-typedef struct {
-       int size;                                               /**< size */
-       int version;                                            /**< version */
-
-       ttspd_get_mode                  get_mode;               /**< Get mode */
-       ttspd_get_speed_range           get_speed_range;        /**< Get speed range */
-       ttspd_get_pitch_range           get_pitch_range;        /**< Get pitch range */
-} ttspd_funcs_s;
-
-/**
-* @brief Loads the engine by the daemon.
-*
-* @param[in] pdfuncs The daemon functions
-* @param[out] pefuncs The engine functions
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_OPERATION_FAILED Operation failed
-*
-* @pre The ttsp_get_engine_info() should be successful.
-* @post The daemon calls the engine functions of ttspe_funcs_s.
-*
-* @see ttsp_get_engine_info()
-* @see ttsp_unload_engine()
-*/
-int ttsp_load_engine(ttspd_funcs_s* pdfuncs, ttspe_funcs_s* pefuncs);
-
-/**
-* @brief Unloads the engine by the daemon. 
-*
-* @pre The ttsp_load_engine() should be performed.
-*
-* @see ttsp_load_engine()
-*/
-void ttsp_unload_engine(void);
-
-/**
-* @brief Called to get this engine base information.
-*
-* @param[in] engine_uuid The engine id
-* @param[in] engine_name The engine name
-* @param[in] setting_ug_name The setting ug name
-* @param[in] use_network @c true to need network \n @c false not to need network
-* @param[in] user_data The user data passed from the engine info function
-*
-* @pre ttsp_get_engine_info() will invoke this callback. 
-*
-* @see ttsp_get_engine_info()
-*/
-typedef void (*ttsp_engine_info_cb)(const char* engine_uuid, const char* engine_name, const char* setting_ug_name, 
-                                    bool use_network, void* user_data);
-
-/**
-* @brief Gets base information of the engine by the daemon.
-*
-* @param[in] callback A callback function
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_OPERATION_FAILED Operation failed
-*
-* @post        This function invokes ttsp_engine_info_cb() for getting engine information.
-*
-* @see ttsp_engine_info_cb()
-* @see ttsp_load_engine()
-*/
-int ttsp_get_engine_info(ttsp_engine_info_cb callback, void* user_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
-* @}@}
-*/
-
-#endif /* __TTSP_H__ */