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
return TTS_ERROR_INVALID_STATE;
}
+ if (NULL != client->credential) {
+ free(client->credential);
+ client->credential = NULL;
+ }
client->credential = strdup(credential);
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
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;
}
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;
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;
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);
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;
/* 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);
/* 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);
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) {
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);
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);
}
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);
}
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);
}
#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"
#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"
--- /dev/null
+/*
+ * 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__ */
+
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})
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}
}
#endif
-/**
-* @}
-*/
-
#endif /* __TTS_H__ */
--- /dev/null
+/*
+* 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__ */
[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"
[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"
[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"
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(bundle)
BuildRequires: cmake
%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
%files engine-devel
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/tts-engine.pc
-%{_includedir}/ttsp.h
+%{_includedir}/ttse.h
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}")
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)
{
/* 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");
}
}
{
/* 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");
}
}
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");
}
}
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");
}
}
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;
}
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;
}
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;
}
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;
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;
}
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");
}
}
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;
}
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;
}
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;
}
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
+}
{
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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 */
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;
}
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;
}
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 */
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_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);
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;
}
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 != 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) {
}
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) {
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;
}
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;
}
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;
}
}
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;
}
}
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;
}
}
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;
}
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;
}
/* 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);
}
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);
}
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;
}
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++;
}
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++;
}
/*
-* 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
#ifndef __TTSD_DATA_H_
#define __TTSD_DATA_H_
-#include "ttsp.h"
+#include "ttse.h"
#ifdef __cplusplus
extern "C" {
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;
{
#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;
}
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);
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);
}
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;
}
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;
}
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);
}
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;
}
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;
}
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);
}
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;
}
/* 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;
}
/* 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;
}
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;
}
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;
}
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);
}
*/
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;
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);
}
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,
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;
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);
}
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;
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);
}
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 {
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;
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);
}
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);
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);
}
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;
}
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);
}
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;
}
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);
}
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;
}
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);
}
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;
}
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);
}
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;
}
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);
}
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;
}
/*
* 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 {
/** 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);
/** 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;
}
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);
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 {
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;
}
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;
}
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;
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)
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;
}
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);
} 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;
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;
}
}
} 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;
/* 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;
}
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);
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
}
/******************************************************************************************
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;
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;
}
}
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;
}
/* 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);
}
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;
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;
}
}
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;
}
/* 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);
}
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)
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);
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;
}
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;
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);
return ret;
}
-
void __free_voice_list(GList* voice_list)
{
GList *iter = NULL;
/*
* 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 */
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*/
}
}
- 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;
+}
+
+
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();
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();
static Ecore_Timer* g_check_client_timer = NULL;
-const char* get_tag()
-{
- return "ttsd";
-}
-
const char* tts_tag()
{
return "ttsd";
{
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;
-}
-
#include <dlog.h>
#include <errno.h>
-#include "ttsp.h"
+#include "ttse.h"
#include "tts_defs.h"
#ifdef __cplusplus
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
}
+++ /dev/null
-/*
-* 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;
-}
-
+++ /dev/null
-/*
-* 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;
-}
-
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
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;
/* 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;
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;
}
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;
}
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;
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;
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;
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)
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");
}
}
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;
}
/* 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;
__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;
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;
}
}
* 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 */
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;
/* 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();
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();
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) {
}
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) {
}
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();
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;
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();
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)
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 */
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);
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;
}
}
}
- SLOG(LOG_DEBUG, get_tag(), "[PLAYER Success] Destroy instance");
+ SLOG(LOG_DEBUG, tts_tag(), "[PLAYER Success] Destroy instance");
return 0;
}
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;
}
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;
}
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);
}
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;
}
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;
}
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) {
}
}
- 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();
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;
}
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;
}
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;
}
}
}
- 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;
}
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;
}
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();
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;
}
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;
}
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;
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;
}
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) {
}
}
- SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] player all stop!!");
+ SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] player all stop!!");
return 0;
}
#include "ttsd_network.h"
#include "ttsd_player.h"
#include "ttsd_server.h"
-#include "ttsp.h"
typedef enum {
} 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;
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)) {
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) {
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);
}
}
- 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;
}
/*
* 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;
}
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;
}
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;
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);
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;
}
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;
}
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;
}
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;
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;
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;
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;
}
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;
}
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);
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;
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;
}
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;
}
}
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);
}
#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;
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");
}
}
{
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);
/* 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;
}
/* 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);
}
{
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;
}
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;
}
/* 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);
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");
}
}
/* 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);
}
{
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;
/* 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 */
/* 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);
}
{
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);
}
{
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;
}
{
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;
}
{
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;
}
{
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;
{
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)
+{}
+*/
+
#include <glib.h>
#include <Ecore.h>
+#include "ttse.h"
+
#ifdef __cplusplus
extern "C" {
#endif
/**
* 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
*/
--- /dev/null
+/*
+* 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;
+}
+++ /dev/null
-/*
-* 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__ */