/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
#include <Ecore.h>
#include <iconv.h>
#include <sys/stat.h>
-#include <sys/types.h>
+#include <sys/types.h>
#include <sys/wait.h>
#include <system_info.h>
#include <vconf.h>
static const char* __tts_get_error_code(tts_error_e err)
{
- switch(err) {
+ switch (err) {
case TTS_ERROR_NONE: return "TTS_ERROR_NONE";
case TTS_ERROR_OUT_OF_MEMORY: return "TTS_ERROR_OUT_OF_MEMORY";
case TTS_ERROR_IO_ERROR: return "TTS_ERROR_IO_ERROR";
void __tts_config_voice_changed_cb(const char* before_lang, int before_voice_type, const char* language, int voice_type, bool auto_voice, void* user_data)
{
- SLOG(LOG_DEBUG, TAG_TTSC, "Voice changed : Before lang(%s) type(%d) , Current lang(%s), type(%d)",
- before_lang, before_voice_type, language, voice_type);
+ SLOG(LOG_DEBUG, TAG_TTSC, "Voice changed : Before lang(%s) type(%d) , Current lang(%s), type(%d)",
+ before_lang, before_voice_type, language, voice_type);
GList* client_list = NULL;
client_list = tts_client_get_client_list();
}
}
- return;
+ return;
}
int tts_create(tts_h* tts)
}
SLOG(LOG_DEBUG, TAG_TTSC, "===== Create TTS");
-
+
/* check param */
if (NULL == tts) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
default:
break;
}
-
+
if (0 == tts_client_get_size()) {
if (0 != tts_dbus_close_connection()) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection");
/* check state */
if (client->current_state != TTS_STATE_CREATED) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_ERROR_INVALID_STATE;
/* check state */
if (client->current_state != TTS_STATE_CREATED) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_ERROR_INVALID_STATE;
if (NULL == mode) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter(mode) is NULL");
return TTS_ERROR_INVALID_PARAMETER;
- }
+ }
*mode = client->mode;
-
+
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
if (TTS_ERROR_ENGINE_NOT_FOUND == ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to initialize : %s", __tts_get_error_code(ret));
-
+
client->reason = TTS_ERROR_ENGINE_NOT_FOUND;
client->utt_id = -1;
if (NULL != client->state_changed_cb) {
tts_client_use_callback(client);
- client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
+ client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
tts_client_not_use_callback(client);
} else {
SLOG(LOG_WARN, TAG_TTSC, "State changed callback is NULL");
/* check state */
if (client->current_state != TTS_STATE_CREATED) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_ERROR_INVALID_STATE;
/* check state */
if (client->current_state != TTS_STATE_READY) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'READY'");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'READY'");
return TTS_ERROR_INVALID_STATE;
}
if (NULL != client->state_changed_cb) {
tts_client_use_callback(client);
- client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
+ client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
tts_client_not_use_callback(client);
SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
}
if (0 != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
ret = TTS_ERROR_OPERATION_FAILED;
- }
+ }
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
/* Request call remote method */
int ret = 0;
ret = tts_config_mgr_get_voice(lang, vctype);
- if (0 != ret) {
+ if (0 != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
return __tts_convert_config_error_code(ret);
} else {
SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] Default language(%s), type(%d)", *lang, *vctype);
}
-
+
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get max text count : A handle is not valid");
return TTS_ERROR_INVALID_PARAMETER;
}
-
+
if (TTS_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get max text count : Current state is NOT 'READY'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get max text count : Current state is NOT 'READY'.");
return TTS_ERROR_INVALID_STATE;
}
*state = client->current_state;
- switch(*state) {
+ switch (*state) {
case TTS_STATE_CREATED: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Created'"); break;
case TTS_STATE_READY: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Ready'"); break;
case TTS_STATE_PLAYING: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Playing'"); break;
}
if (TTS_STATE_CREATED == client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Current state is 'CREATED'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Current state is 'CREATED'.");
return TTS_ERROR_INVALID_STATE;
}
if (NULL == language)
temp = strdup("default");
- else
+ else
temp = strdup(language);
- client->current_utt_id ++;
+ client->current_utt_id++;
if (client->current_utt_id == 10000) {
client->current_utt_id = 1;
}
}
if (TTS_STATE_PLAYING == client->current_state || TTS_STATE_CREATED == client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] The current state is invalid.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] The current state is invalid.");
return TTS_ERROR_INVALID_STATE;
}
if (NULL != client->state_changed_cb) {
tts_client_use_callback(client);
- client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
+ client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
tts_client_not_use_callback(client);
SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
}
}
if (TTS_STATE_CREATED == client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Current state is 'CREATED'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Current state is 'CREATED'.");
return TTS_ERROR_INVALID_STATE;
}
if (NULL != client->state_changed_cb) {
tts_client_use_callback(client);
- client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
+ client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
tts_client_not_use_callback(client);
SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
}
}
if (TTS_STATE_PLAYING != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[Error] The Current state is NOT 'playing'. So this request should be not running.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[Error] The Current state is NOT 'playing'. So this request should be not running.");
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return TTS_ERROR_INVALID_STATE;
}
}
}
-
+
client->before_state = client->current_state;
client->current_state = TTS_STATE_PAUSED;
if (NULL != client->state_changed_cb) {
tts_client_use_callback(client);
- client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
+ client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
tts_client_not_use_callback(client);
SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
}
if (NULL != client->error_cb) {
SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of error");
tts_client_use_callback(client);
- client->error_cb(client->tts, client->utt_id, client->reason, client->error_user_data );
+ client->error_cb(client->tts, client->utt_id, client->reason, client->error_user_data);
tts_client_not_use_callback(client);
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
} else {
SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
}
-
+
return 0;
}
if (NULL != client->state_changed_cb) {
tts_client_use_callback(client);
- client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
+ client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data);
tts_client_not_use_callback(client);
SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called : pre(%d) cur(%d)", client->before_state, client->current_state);
} else {
int __tts_cb_set_state(int uid, int state)
{
tts_client_s* client = tts_client_get_by_uid(uid);
- if( NULL == client ) {
+ if (NULL == client) {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] The handle is not valid");
return -1;
}
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Fail to notify utt started : A handle is not valid");
return EINA_FALSE;
}
-
+
if (NULL != client->utt_started_cb) {
SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance started ");
tts_client_use_callback(client);
}
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
}
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
}
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
client->utt_started_user_data = user_data;
SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set utt started cb");
-
+
return 0;
}
}
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt started cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt started cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
client->utt_started_user_data = NULL;
SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset utt started cb");
-
+
return 0;
}
}
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt completed cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt completed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
client->utt_completed_user_data = user_data;
SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set utt completed cb");
-
+
return 0;
}
}
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt completed cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt completed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
}
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set error cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set error cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
client->error_user_data = user_data;
SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set error cb");
-
+
return 0;
}
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset error cb : A handle is not valid");
return TTS_ERROR_INVALID_PARAMETER;
}
-
+
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset error cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset error cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
}
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set default voice changed cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set default voice changed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
}
if (TTS_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset default voice changed cb : Current state is not 'Created'.");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset default voice changed cb : Current state is not 'Created'.");
return TTS_ERROR_INVALID_STATE;
}
if (tts->handle == data->tts->handle) {
g_client_list = g_list_remove_link(g_client_list, iter);
- while (0 != data->cb_ref_count)
- {
+ while (0 != data->cb_ref_count) {
/* wait for release callback function */
}
free(data);
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
}
/* loop again if we haven't read a message */
- if (NULL == msg) {
+ if (NULL == msg) {
return ECORE_CALLBACK_RENEW;
}
DBusError err;
dbus_error_init(&err);
-
+
char if_name[64] = {0, };
snprintf(if_name, 64, "%s", TTS_CLIENT_SERVICE_INTERFACE);
SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error message - Get arguments error (%s)", err.message);
dbus_error_free(&err);
}
-
+
if (0 == __tts_cb_error(uid, reason, uttid)) {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error message : uid(%d), error(%d), uttid(%d)", uid, reason, uttid);
}
/* connect to the DBUS system bus, and check for errors */
g_conn_sender = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Dbus Connection Error (%s)", err.message);
- dbus_error_free(&err);
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Dbus Connection Error (%s)", err.message);
+ dbus_error_free(&err);
}
if (NULL == g_conn_sender) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] fail to get dbus connection");
- return TTS_ERROR_OPERATION_FAILED;
+ return TTS_ERROR_OPERATION_FAILED;
}
dbus_connection_set_exit_on_disconnect(g_conn_sender, false);
}
g_dbus_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, NULL, NULL, NULL);
- if (NULL == g_dbus_fd_handler) {
+ if (NULL == g_dbus_fd_handler) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get fd handler from ecore");
return TTS_ERROR_OPERATION_FAILED;
}
{
bool sender_connected = dbus_connection_get_is_connected(g_conn_sender);
bool listener_connected = dbus_connection_get_is_connected(g_conn_listener);
- SLOG(LOG_DEBUG, TAG_TTSC, "[DBUS] Sender(%s) Listener(%s)",
- sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected");
+ SLOG(LOG_DEBUG, TAG_TTSC, "[DBUS] Sender(%s) Listener(%s)",
+ sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected");
if (false == sender_connected || false == listener_connected) {
tts_dbus_close_connection();
- if(0 != tts_dbus_open_connection()) {
+ if (0 != tts_dbus_open_connection()) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to reconnect");
return -1;
- }
+ }
SLOG(LOG_DEBUG, TAG_TTSC, "[DBUS] Reconnect");
}
-
+
return 0;
}
DBusMessage* __tts_dbus_make_message(int uid, const char* method)
{
if (NULL == method) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input method is NULL");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input method is NULL");
return NULL;
}
TTS_SR_SERVER_SERVICE_INTERFACE,
method);
} else {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input mode is not available");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input mode is not available");
return NULL;
}
DBusMessage* msg;
msg = __tts_dbus_make_message(uid, TTS_METHOD_HELLO);
-
+
if (dbus_error_is_set(&err)) {
SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts dbus log : %s", err);
dbus_error_free(&err);
}
- if (NULL == msg) {
+ if (NULL == msg) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts hello : Fail to make message");
return TTS_ERROR_OPERATION_FAILED;
- }
+ }
DBusMessage* result_msg = NULL;
int result = 0;
msg = __tts_dbus_make_message(uid, TTS_METHOD_INITIALIZE);
- if (NULL == msg) {
+ if (NULL == msg) {
SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to make message");
return TTS_ERROR_OPERATION_FAILED;
} else {
int pid = getpid();
if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
dbus_message_unref(msg);
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
return TTS_ERROR_OPERATION_FAILED;
}
DBUS_TYPE_INT32, &result,
DBUS_TYPE_INVALID);
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
result = TTS_ERROR_OPERATION_FAILED;
}
msg = __tts_dbus_make_message(uid, TTS_METHOD_FINALIZE);
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts finalize : Fail to make message");
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts finalize : Fail to make message");
return TTS_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts finalize : uid(%d)", uid);
if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
dbus_message_unref(msg);
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
return TTS_ERROR_OPERATION_FAILED;
}
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
result = TTS_ERROR_OPERATION_FAILED;
}
msg = __tts_dbus_make_message(uid, TTS_METHOD_ADD_QUEUE);
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts add text : Fail to make message");
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts add text : Fail to make message");
return TTS_ERROR_OPERATION_FAILED;
} else {
- SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), id(%d)",
- uid, text, lang, vctype, speed, uttid);
+ SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), id(%d)",
+ uid, text, lang, vctype, speed, uttid);
}
- if (true != dbus_message_append_args( msg,
+ if (true != dbus_message_append_args(msg,
DBUS_TYPE_INT32, &uid,
DBUS_TYPE_STRING, &text,
DBUS_TYPE_STRING, &lang,
DBUS_TYPE_INT32, &uttid,
DBUS_TYPE_INVALID)) {
dbus_message_unref(msg);
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
return TTS_ERROR_OPERATION_FAILED;
}
DBUS_TYPE_INT32, &result,
DBUS_TYPE_INVALID);
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts add text : Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
result = TTS_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
-
+
if (0 == result) {
SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts add text : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts add text : result(%d)", result);
- }
+ }
} else {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
tts_dbus_reconnect();
return result;
}
-int tts_dbus_request_play(int uid)
+int tts_dbus_request_play(int uid)
{
DBusMessage* msg;
DBusError err;
msg = __tts_dbus_make_message(uid, TTS_METHOD_PLAY);
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts play : Fail to make message");
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts play : Fail to make message");
return TTS_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts play : uid(%d)", uid);
}
-
+
if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
dbus_message_unref(msg);
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
return TTS_ERROR_OPERATION_FAILED;
}
DBUS_TYPE_INT32, &result,
DBUS_TYPE_INVALID);
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts play : Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
result = TTS_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
msg = __tts_dbus_make_message(uid, TTS_METHOD_STOP);
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts stop : Fail to make message");
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts stop : Fail to make message");
return TTS_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts stop : uid(%d)", uid);
if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
dbus_message_unref(msg);
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
return TTS_ERROR_OPERATION_FAILED;
}
DBUS_TYPE_INT32, &result,
DBUS_TYPE_INVALID);
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts stop : Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
result = TTS_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
msg = __tts_dbus_make_message(uid, TTS_METHOD_PAUSE);
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts pause : Fail to make message");
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts pause : Fail to make message");
return TTS_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts pause : uid(%d)", uid);
if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
dbus_message_unref(msg);
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
return TTS_ERROR_OPERATION_FAILED;
}
DBUS_TYPE_INT32, &result,
DBUS_TYPE_INVALID);
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts pause : Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
result = TTS_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
#include "tts_main.h"
#include "tts_setting.h"
-/**
+/**
* @brief Enumerations of setting state.
*/
typedef enum {
TTS_SETTING_STATE_NONE = 0,
TTS_SETTING_STATE_READY
-}tts_setting_state_e;
+} tts_setting_state_e;
static tts_setting_state_e g_state = TTS_SETTING_STATE_NONE;
void __setting_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, void* user_data)
{
- SLOG(LOG_DEBUG, TAG_TTSC, "Engine chagned : engine(%s) setting(%s) lang(%s) type(%d)",
- engine_id, setting, language, language, voice_type);
+ SLOG(LOG_DEBUG, TAG_TTSC, "Engine chagned : engine(%s) setting(%s) lang(%s) type(%d)",
+ engine_id, setting, language, language, voice_type);
if (NULL != g_engine_changed_cb)
g_engine_changed_cb(engine_id, g_engine_changed_user_data);
}
int tts_setting_foreach_supported_engines(tts_setting_supported_engine_cb callback, void* user_data)
-{
+{
SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach supported engines");
if (TTS_SETTING_STATE_NONE == g_state) {
} else {
SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set current engine : %s", engine_id);
}
-
+
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
-
+
return __setting_convert_config_error_code(ret);
}
if (0 != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
} else {
- SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set default voice : lang(%s) type(%d)",language, voice_type);
+ SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set default voice : lang(%s) type(%d)", language, voice_type);
}
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
-
+
return __setting_convert_config_error_code(ret);
}
} else {
SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set default speed, %d", speed);
}
-
+
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
tts_config_screen_reader_changed_cb screen_cb;
tts_config_pitch_changed_cb pitch_cb;
void* user_data;
-}tts_config_client_s;
+} tts_config_client_s;
extern char* tts_tag();
/* Change default engine */
iter = g_slist_nth(g_engine_list, 0);
engine_info = iter->data;
-
+
if (NULL != g_config_info->engine_id) free(g_config_info->engine_id);
if (NULL != g_config_info->setting) free(g_config_info->setting);
while (NULL != iter_voice) {
/*Get handle data from list*/
voice = iter_voice->data;
-
+
if (NULL != voice && NULL != g_config_info) {
if (NULL != voice->language && NULL != g_config_info->language) {
if (0 == strcmp(voice->language, g_config_info->language)) {
}
}
- if ( 0 != tts_parser_set_engine(g_config_info->engine_id, g_config_info->setting,
+ if (0 != tts_parser_set_engine(g_config_info->engine_id, g_config_info->setting,
g_config_info->language, g_config_info->type)) {
SLOG(LOG_ERROR, tts_tag(), " Fail to save config");
return TTS_CONFIG_ERROR_OPERATION_FAILED;
iter = g_slist_next(iter);
return false;
}
-
+
/* Get a first item */
iter_voice = g_slist_nth(engine_info->voices, 0);
}
}
}
-
+
/*Get next item*/
iter_voice = g_slist_next(iter_voice);
i++;
SLOG(LOG_ERROR, tts_tag(), "There is no engine!!");
return false;
}
-
+
/* Get a first item */
iter = g_slist_nth(g_engine_list, 0);
SLOG(LOG_ERROR, tts_tag(), "engine info is NULL");
return false;
}
-
+
if (0 != strcmp(engine_id, engine_info->uuid)) {
iter = g_slist_next(iter);
continue;
iter = g_slist_next(iter);
}
-
+
if (NULL != before_lang) {
free(before_lang);
}
wd = inotify_add_watch(fd, TTS_CONFIG, IN_CLOSE_WRITE);
g_config_wd_noti = wd;
- g_config_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ,
- (Ecore_Fd_Cb)tts_config_mgr_inotify_event_cb, NULL, NULL, NULL);
+ g_config_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ,
+ (Ecore_Fd_Cb)tts_config_mgr_inotify_event_cb, NULL, NULL, NULL);
if (NULL == g_config_fd_handler_noti) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get handler_noti");
return -1;
int value;
value = fcntl(fd, F_GETFL, 0);
value |= O_NONBLOCK;
-
+
if (0 > fcntl(fd, F_SETFL, value)) {
SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to set non-block mode");
}
if (0 != ret) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get voice");
}
-
+
ret = tts_config_mgr_set_voice(temp_lang, temp_type);
if (0 != ret) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set voice");
int value;
value = fcntl(g_dir_fd, F_GETFL, 0);
value |= O_NONBLOCK;
-
+
if (0 > fcntl(g_dir_fd, F_SETFL, value)) {
SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to set non-block mode");
}
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse configure information");
__tts_config_release_client(uid);
__tts_config_release_engine();
- return TTS_CONFIG_ERROR_OPERATION_FAILED;
+ return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
-
+
/* Check whether engine id is valid */
if (0 != __tts_config_mgr_check_engine_is_valid(g_config_info->engine_id)) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get default engine");
tts_parser_unload_config(g_config_info);
return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
}
-
+
if (true == g_config_info->auto_voice) {
/* Check language with display language */
__tts_config_set_auto_language();
}
iter = g_slist_next(iter);
}
-
+
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Current engine id is not valid");
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Engine id is NULL");
return TTS_CONFIG_ERROR_INVALID_PARAMETER;
/* Check current engine id with new engine id */
- if (0 == strcmp(g_config_info->engine_id, engine))
+ if (0 == strcmp(g_config_info->engine_id, engine))
return 0;
if (0 >= g_slist_length(g_engine_list)) {
while (NULL != iter_voice) {
/*Get handle data from list*/
voice = iter_voice->data;
-
+
if (NULL != voice) {
if (NULL == voice->language)
continue;
SECURE_SLOG(LOG_DEBUG, tts_tag(), " Setting : %s", g_config_info->setting);
SECURE_SLOG(LOG_DEBUG, tts_tag(), " Language : %s", g_config_info->language);
SECURE_SLOG(LOG_DEBUG, tts_tag(), " Type : %d", g_config_info->type);
-
- if ( 0 != tts_parser_set_engine(g_config_info->engine_id, g_config_info->setting,
+
+ if (0 != tts_parser_set_engine(g_config_info->engine_id, g_config_info->setting,
g_config_info->language, g_config_info->type)) {
SLOG(LOG_ERROR, tts_tag(), " Fail to save config");
return TTS_CONFIG_ERROR_OPERATION_FAILED;
GSList *iter_voice = NULL;
tts_config_voice_s* voice = NULL;
-
+
/* Get a first item */
iter_voice = g_slist_nth(engine_info->voices, 0);
if (false == callback(engine_info->uuid, voice->language, voice->type, user_data))
break;
}
-
+
/*Get next item*/
iter_voice = g_slist_next(iter_voice);
}
SLOG(LOG_ERROR, tts_tag(), "Not initialized");
return TTS_CONFIG_ERROR_INVALID_PARAMETER;
}
-
+
if (NULL == value) {
return TTS_CONFIG_ERROR_INVALID_PARAMETER;
}
} else {
SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Speech rate is invalid : %d", value);
}
-
+
return 0;
}
SLOG(LOG_ERROR, tts_tag(), "engine info is NULL");
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
-
+
if (0 != strcmp(g_config_info->engine_id, engine_info->uuid)) {
iter = g_slist_next(iter);
continue;
SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine!!");
return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
}
-
+
/* Get a first item */
iter = g_slist_nth(g_engine_list, 0);
SLOG(LOG_ERROR, tts_tag(), "engine info is NULL");
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
-
+
if (0 != strcmp(g_config_info->engine_id, engine_info->uuid)) {
iter = g_slist_next(iter);
continue;
SLOG(LOG_ERROR, tts_tag(), "Fail to save speech rate");
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
-
+
g_config_info->pitch = value;
return 0;
if (NULL == engine)
return false;
- if (0 >= g_slist_length(g_engine_list))
+ if (0 >= g_slist_length(g_engine_list))
return false;
GSList *iter = NULL;
return false;
}
- if (0 >= g_slist_length(g_engine_list))
+ if (0 >= g_slist_length(g_engine_list))
return false;
GSList *iter = NULL;
while (NULL != iter_voice) {
voice = iter_voice->data;
-
+
if (0 == strcmp(language, voice->language) && voice->type == type)
return true;
SLOG(LOG_DEBUG, tts_tag(), "--------------- engine list -----------------");
- int i = 1;
+ int i = 1;
while (NULL != iter) {
engine_info = iter->data;
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
const char* __ttsd_get_error_code(ttsd_error_e err)
{
- switch(err) {
+ switch (err) {
case TTSD_ERROR_NONE: return "TTS_ERROR_NONE";
case TTSD_ERROR_OUT_OF_MEMORY: return "TTS_ERROR_OUT_OF_MEMORY";
case TTSD_ERROR_IO_ERROR: return "TTS_ERROR_IO_ERROR";
{
#if 0
if (NULL == g_conn_sender) {
- SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available" );
+ SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available");
return -1;
}
char service_name[64];
memset(service_name, 0, 64);
- //snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
+ /*snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid); */
snprintf(service_name, 64, "%s", TTS_CLIENT_SERVICE_NAME);
char target_if_name[64];
- //snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
+ /*snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid); */
snprintf(target_if_name, sizeof(target_if_name), "%s", TTS_CLIENT_SERVICE_INTERFACE);
DBusMessage* msg;
return ttsdc_send_message(pid, uid, uttid, TTSD_METHOD_UTTERANCE_STARTED);
}
-int ttsdc_send_utt_finish_message(int pid, int uid, int uttid)
+int ttsdc_send_utt_finish_message(int pid, int uid, int uttid)
{
return ttsdc_send_message(pid, uid, uttid, TTSD_METHOD_UTTERANCE_COMPLETED);
}
int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
{
if (NULL == g_conn_sender) {
- SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available" );
+ SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available");
return -1;
}
return -1;
}
- dbus_message_append_args( msg,
+ dbus_message_append_args(msg,
DBUS_TYPE_INT32, &uid,
DBUS_TYPE_INT32, &uttid,
DBUS_TYPE_INT32, &reason,
if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] <<<< error message : Out Of Memory !");
} else {
- SLOG(LOG_DEBUG, get_tag(), "<<<< Send error message : uid(%d), reason(%s), uttid(%d)",
- uid, __ttsd_get_error_code(reason), uttid);
+ SLOG(LOG_DEBUG, get_tag(), "<<<< Send error message : uid(%d), reason(%s), uttid(%d)",
+ uid, __ttsd_get_error_code(reason), uttid);
dbus_connection_flush(g_conn_sender);
}
} else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_INITIALIZE)) {
ttsd_dbus_server_initialize(g_conn_listener, msg);
-
+
} else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_FINALIZE)) {
ttsd_dbus_server_finalize(g_conn_listener, msg);
-
+
} else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_SUPPORT_VOICES)) {
ttsd_dbus_server_get_support_voices(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PLAY)) {
ttsd_dbus_server_play(g_conn_listener, msg);
-
+
} else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_STOP)) {
ttsd_dbus_server_stop(g_conn_listener, msg);
snprintf(g_service_name, strlen(TTS_SERVER_SERVICE_NAME) + 1, "%s", TTS_SERVER_SERVICE_NAME);
snprintf(g_service_object, strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_SERVER_SERVICE_OBJECT_PATH);
- snprintf(g_service_interface, strlen(TTS_SERVER_SERVICE_INTERFACE)+ 1, "%s", TTS_SERVER_SERVICE_INTERFACE);
+ snprintf(g_service_interface, strlen(TTS_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_SERVER_SERVICE_INTERFACE);
}
/* request our name on the bus and check for errors */
g_dbus_fd_handler = NULL;
}
- dbus_bus_release_name (g_conn_listener, g_service_name, &err);
+ 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);
dbus_error_free(&err);
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
dbus_connection_flush(conn);
dbus_message_unref(reply);
} else {
- SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to create reply message!!");
+ SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to create reply message!!");
}
return 0;
dbus_error_init(&err);
int pid, uid;
- int ret = 0;
+ int ret = 0;
dbus_message_get_args(msg, &err,
DBUS_TYPE_INT32, &pid,
SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS INITIALIZE");
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts initialize : get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ 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, get_tag(), "[IN] tts initialize : pid(%d), uid(%d)", pid , uid);
ret = ttsd_server_initialize(pid, uid);
}
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)", ret);
+ SLOG(LOG_DEBUG, get_tag(), "[OUT] tts initialize : result(%d)", ret);
} else {
- SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : result(%d)", ret);
+ SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : result(%d)", ret);
}
if (!dbus_connection_send(conn, reply, NULL)) {
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, get_tag(), "[OUT ERROR] tts initialize : Fail to create reply message!!");
}
return 0;
dbus_error_init(&err);
int uid;
- int ret = 0;
+ int ret = 0;
dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS FINALIZE");
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts finalize : get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ 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, get_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, get_tag(), "[OUT] tts finalize : result(%d)", ret);
} else {
- SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : result(%d)", ret);
+ SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : result(%d)", ret);
}
if (!dbus_connection_send(conn, reply, NULL)) {
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, get_tag(), "[OUT ERROR] tts finalize : Fail to create reply message!!");
}
return 0;
SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS GET VOICES");
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts get supported voices : get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ 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, get_tag(), "[IN] get supported voices : uid(%d)", uid);
ret = ttsd_server_get_support_voices(uid, &voice_list);
}
if (0 == ret) {
/* Append voice size */
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, get_tag(), "[OUT ERROR] tts supported voices : Fail to append type");
ret = TTSD_ERROR_OPERATION_FAILED;
} else {
voice = iter->data;
if (NULL != voice) {
- dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language) );
- dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type) );
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language));
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type));
if (NULL != voice->language)
g_free(voice->language);
-
+
g_free(voice);
}
-
+
voice_list = g_list_remove_link(voice_list, iter);
iter = g_list_first(voice_list);
- }
+ }
}
- SLOG(LOG_DEBUG, get_tag(), "[OUT] tts supported voices : result(%d)", ret);
+ SLOG(LOG_DEBUG, get_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, get_tag(), "[OUT ERROR] tts supported voices : result(%d)", ret);
}
if (!dbus_connection_send(conn, reply, NULL)) {
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, get_tag(), "[OUT ERROR] tts supported voices : Fail to create reply message!!");
}
return 0;
SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS GET DEFAULT VOICE");
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, get_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, get_tag(), "[IN] tts get default voice : uid(%d)", uid);
ret = ttsd_server_get_current_voice(uid, &lang, &voice_type);
}
reply = dbus_message_new_method_return(msg);
if (NULL != reply) {
- if (0 == ret) {
+ if (0 == ret) {
/* Append result and voice */
- dbus_message_append_args( reply,
+ dbus_message_append_args(reply,
DBUS_TYPE_INT32, &ret,
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, get_tag(), "[OUT] tts default voice : lang(%s), vctype(%d)", lang, voice_type);
} else {
- dbus_message_append_args( reply,
+ 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);
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, get_tag(), "[OUT ERROR] tts default voice : Fail to create reply message!!");
}
if (NULL != lang) free(lang);
SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS ADD TEXT");
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts add text : Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
ret = TTSD_ERROR_OPERATION_FAILED;
} else {
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, get_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, get_tag(), "[OUT ERROR] tts add text : result(%d)", ret);
}
if (!dbus_connection_send(conn, reply, NULL)) {
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, get_tag(), "[OUT ERROR] tts add text : Fail to create reply message!!");
}
-
+
SLOG(LOG_DEBUG, get_tag(), "<<<<<");
SLOG(LOG_DEBUG, get_tag(), " ");
SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS PLAY");
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts play : Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
ret = TTSD_ERROR_OPERATION_FAILED;
} else {
- SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts play : uid(%d)", uid );
+ SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts play : uid(%d)", uid);
ret = ttsd_server_play(uid);
}
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, get_tag(), "[OUT] tts play : result(%d)", ret);
} else {
- SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : result(%d)", ret);
+ SLOG(LOG_ERROR, get_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!");
}
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, get_tag(), "[OUT ERROR] tts play : Fail to create reply message!!");
}
SLOG(LOG_DEBUG, get_tag(), "<<<<<");
SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS STOP");
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts stop : Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
ret = TTSD_ERROR_OPERATION_FAILED;
} else {
SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts stop : uid(%d)", uid);
DBUS_TYPE_INVALID);
if (0 == ret) {
- SLOG(LOG_DEBUG, get_tag(), "[OUT] tts stop : result(%d)", ret);
+ SLOG(LOG_DEBUG, get_tag(), "[OUT] tts stop : result(%d)", ret);
} else {
- SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : result(%d)", ret);
+ SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : result(%d)", ret);
}
if (!dbus_connection_send(conn, reply, NULL)) {
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, get_tag(), "[OUT ERROR] tts stop : Fail to create reply message!!");
}
SLOG(LOG_DEBUG, get_tag(), "<<<<<");
SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS PAUSE");
- if (dbus_error_is_set(&err)) {
+ if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts pause : Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
ret = TTSD_ERROR_OPERATION_FAILED;
} else {
SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts pause : uid(%d)", uid);
DBUS_TYPE_INVALID);
if (0 == ret) {
- SLOG(LOG_DEBUG, get_tag(), "[OUT] tts pause : result(%d)", ret);
+ SLOG(LOG_DEBUG, get_tag(), "[OUT] tts pause : result(%d)", ret);
} else {
- SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : result(%d)", ret);
+ SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : result(%d)", ret);
}
if (!dbus_connection_send(conn, reply, NULL)) {
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, get_tag(), "[OUT ERROR] tts pause : Fail to create reply message!!");
}
SLOG(LOG_DEBUG, get_tag(), "<<<<<");
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
typedef struct {
/* base info */
char* engine_uuid;
- char* engine_name;
+ char* engine_name;
char* engine_path;
/* info for using engine load */
bool is_set;
- bool is_loaded;
+ bool is_loaded;
bool need_network;
void *handle;
int (*ttsp_load_engine)(const ttspd_funcs_s* pdfuncs, ttspe_funcs_s* pefuncs);
int (*ttsp_unload_engine)();
-}ttsengine_s;
+} ttsengine_s;
typedef struct {
char* engine_uuid;
char* engine_name;
char* setting_ug_path;
bool use_network;
-}ttsengine_info_s;
+} ttsengine_info_s;
-typedef struct
-{
+typedef struct {
bool is_default;
bool is_loaded;
int client_ref_count;
char* lang;
int type;
-}ttsvoice_s;
+} ttsvoice_s;
/** Init flag */
static const char* __ttsd_get_engine_error_code(ttsp_error_e err)
{
- switch(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";
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");
+ 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");
+ 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");
+ SLOG(LOG_WARN, get_tag(), "[Server WARNING] There is No default pitch in config");
g_cur_engine.default_pitch = TTS_PITCH_NORMAL;
}
int ttsd_engine_agent_initialize_current_engine()
{
if (false == g_agent_init) {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
}
} else {
SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Fail to set a engine of engine list");
- return TTSD_ERROR_OPERATION_FAILED;
+ 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;
+ 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. */
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)
+
+ 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);
- return TTSD_ERROR_OPERATION_FAILED;
+ return TTSD_ERROR_OPERATION_FAILED;
}
if (cur_engine_uuid != NULL) free(cur_engine_uuid);
is_get_engineid_from_config = false;
}
- if (NULL != cur_engine_uuid)
+ if (NULL != cur_engine_uuid)
SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Current Engine Id : %s", cur_engine_uuid);
- else
+ else
return TTSD_ERROR_OPERATION_FAILED;
/* set current engine */
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)) {
if (NULL != cur_engine_uuid) free(cur_engine_uuid);
- SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set current engine");
+ SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set current engine");
return 0;
}
while (NULL != iter) {
data = iter->data;
- if (0 == strncmp(engine_uuid, data->engine_uuid, strlen(data->engine_uuid)))
+ if (0 == strncmp(engine_uuid, data->engine_uuid, strlen(data->engine_uuid)))
return 0;
-
+
iter = g_list_next(iter);
}
}
void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name,
bool use_network, void* user_data)
{
- ttsengine_info_s* temp = (ttsengine_info_s*)user_data;
+ 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);
handle = dlopen(filepath, RTLD_LAZY);
if (!handle) {
- SECURE_SLOG(LOG_WARN, get_tag(), "[Engine Agent] Invalid engine : %s", filepath);
+ SECURE_SLOG(LOG_WARN, get_tag(), "[Engine Agent] Invalid engine : %s", filepath);
return TTSD_ERROR_OPERATION_FAILED;
}
}
temp->engine_path = strdup(filepath);
-
+
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");
+ SECURE_SLOG(LOG_DEBUG, get_tag(), "Use network : %s", temp->use_network ? "true" : "false");
SLOG(LOG_DEBUG, get_tag(), "-----");
SLOG(LOG_DEBUG, get_tag(), " ");
file_size = strlen(TTS_DEFAULT_ENGINE) + strlen(dirp->d_name) + 5;
filepath = (char*)calloc(file_size, sizeof(char));
- if (NULL != filepath) {
+ 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;
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not enough memory!!");
+ continue;
}
/* get its info and update engine list */
if (NULL != filepath) {
snprintf(filepath, file_size, "%s/%s", TTS_DOWNLOAD_ENGINE, dirp->d_name);
} else {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not enough memory!!" );
- continue;
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not enough memory!!");
+ continue;
}
/* get its info and update engine list */
if (g_list_length(g_engine_list) <= 0) {
SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No Engine");
- return TTSD_ERROR_OPERATION_FAILED;
+ return TTSD_ERROR_OPERATION_FAILED;
}
#ifdef ENGINE_AGENT_DEBUG
int ttsd_engine_agent_load_current_engine()
{
if (false == g_agent_init) {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
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 " );
+ if (true == g_cur_engine.is_loaded) {
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent] Engine has already been loaded ");
return 0;
}
return -3;
}
- g_cur_engine.ttsp_load_engine = (int (*)(const ttspd_funcs_s* , ttspe_funcs_s*) )dlsym(g_cur_engine.handle, "ttsp_load_engine");
+ 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;
g_cur_engine.pdfuncs->size = sizeof(ttspd_funcs_s);
int ret = 0;
- ret = g_cur_engine.ttsp_load_engine(g_cur_engine.pdfuncs, g_cur_engine.pefuncs);
+ 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));
+ 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;
}
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;
+ return TTSD_ERROR_OPERATION_FAILED;
}
ret = g_cur_engine.pefuncs->initialize(__result_cb);
/* 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);
+ 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);
+ g_cur_engine.default_lang, g_cur_engine.default_vctype);
return TTSD_ERROR_OPERATION_FAILED;
}
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);
+ 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));
+ g_cur_engine.default_lang, g_cur_engine.default_vctype, __ttsd_get_engine_error_code(ret));
return TTSD_ERROR_OPERATION_FAILED;
}
if (0 == ret && 0 < g_list_length(voice_list)) {
GList *iter = NULL;
voice_s* voice = NULL;
-
+
iter = g_list_first(voice_list);
/* check english */
voice = iter->data;
if (NULL != voice) {
- if (0 == strcmp("en_US", voice->language))
+ if (0 == strcmp("en_US", voice->language))
break;
}
SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail to find voice in list");
return TTSD_ERROR_OPERATION_FAILED;
}
-
+
/* Set selected language and type */
if (true != g_cur_engine.pefuncs->is_valid_voice(voice->language, voice->type)) {
SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail voice is NOT valid");
}
ttsd_config_set_default_voice(voice->language, (int)voice->type);
-
+
g_cur_engine.default_lang = strdup(voice->language);
g_cur_engine.default_vctype = voice->type;
- SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Select default voice : lang(%s), type(%d)",
- voice->language, voice->type);
+ SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Select default voice : lang(%s), type(%d)",
+ voice->language, voice->type);
__free_voice_list(voice_list);
} else {
int ttsd_engine_agent_unload_current_engine()
{
if (false == g_agent_init) {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
}
if (false == g_cur_engine.is_loaded) {
- SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Engine has already been unloaded " );
+ SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Engine has already been unloaded ");
return 0;
}
/* unload engine */
g_cur_engine.ttsp_unload_engine();
-
+
dlclose(g_cur_engine.handle);
/* reset current engine data */
bool ttsd_engine_agent_need_network()
{
if (false == g_agent_init) {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
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);
-
/* 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;
return true;
}
-
+
/* Get voice list */
GList* voice_list = NULL;
int ret = 0;
/* 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_cur_engine.default_lang, strlen(g_cur_engine.default_lang))) {
voice_selected = voice;
if (voice->type == type) {
voice_selected = voice;
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" );
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
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, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
return 0;
}
- bool is_engine_loaded = false;
+ bool is_engine_loaded = false;
char* tmp_uuid = NULL;
tmp_uuid = strdup(g_cur_engine.engine_uuid);
if (NULL == 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;
}
/* 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) {
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" );
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
}
break;
}
-
+
/*Get next item*/
iter = g_slist_next(iter);
}
}
break;
}
-
+
/*Get next item*/
iter = g_slist_next(iter);
}
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, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
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, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
int ret = g_cur_engine.pefuncs->set_pitch(pitch);
if (0 != ret) {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set pitch : pitch(%d), result(%s)",
- pitch, __ttsd_get_engine_error_code(ret));
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set pitch : pitch(%d), result(%s)",
+ pitch, __ttsd_get_engine_error_code(ret));
return TTSD_ERROR_OPERATION_FAILED;
}
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)",
- data->is_default, data->is_loaded, data->client_ref_count, data->lang, data->type);
+ SLOG(LOG_DEBUG, get_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;
}
}
-
+
/*Get next item*/
iter = g_slist_next(iter);
data = NULL;
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)",
- data->is_default, data->is_loaded, data->client_ref_count, data->lang, data->type);
+ SLOG(LOG_DEBUG, get_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;
}
}
-
+
/*Get next item*/
iter = g_slist_next(iter);
data = NULL;
int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, int speed, void* user_param)
{
if (false == g_agent_init) {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
int ttsd_engine_cancel_synthesis()
{
if (false == g_agent_init) {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
return TTSD_ERROR_OPERATION_FAILED;
}
-
+
if (NULL == g_cur_engine.pefuncs->cancel_synth) {
SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] cancel_synth() of engine is NULL!!");
return TTSD_ERROR_OPERATION_FAILED;
int ttsd_engine_get_voice_list(GList** voice_list)
{
if (false == g_agent_init) {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
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, get_tag(), "[Engine Agent ERROR] Not Initialized");
return TTSD_ERROR_OPERATION_FAILED;
}
}
if (NULL == lang || NULL == vctype) {
- SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] BAD Parameter");
+ SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] BAD Parameter");
return TTSD_ERROR_INVALID_PARAMETER;
}
SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Default voice is NULL");
return TTSD_ERROR_OPERATION_FAILED;
}
-
+
return 0;
}
while (NULL != iter) {
data = iter->data;
-
+
if (NULL != data) {
if (NULL != data->language) free(data->language);
free(data);
}
-
+
voice_list = g_list_remove_link(voice_list, iter);
-
+
iter = g_list_first(voice_list);
}
}
SLOG(LOG_DEBUG, get_tag(), "----- engine list -----");
- int i = 1;
+ int i = 1;
while (NULL != iter) {
data = iter->data;
/* Get a first item */
iter = g_slist_nth(g_cur_voices, 0);
- int i = 1;
+ int i = 1;
while (NULL != iter) {
/*Get handle data from list*/
data = iter->data;
return 0;
}
- SLOG(LOG_DEBUG, get_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);
-
+ SLOG(LOG_DEBUG, get_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*/
iter = g_slist_next(iter);
i++;
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
int network_status = 0;
vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status);
- if(network_status == VCONFKEY_NETWORK_OFF){
+ if (network_status == VCONFKEY_NETWORK_OFF) {
SLOG(LOG_WARN, get_tag(), "[Network] Current network connection is OFF.");
return false;
}
-
+
SLOG(LOG_DEBUG, get_tag(), "[Network] Network status is %d", network_status);
return true;
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
AUDIO_STATE_NONE = 0,
AUDIO_STATE_READY,
AUDIO_STATE_PLAY
-}audio_state_e;
+} audio_state_e;
typedef struct {
int uid; /** client id */
bool is_paused_data;
int idx;
sound_data_s paused_data;
-}player_s;
+} player_s;
#define SOUND_BUFFER_LENGTH 2048
static audio_out_h g_audio_h;
/*
-* Internal Interfaces
+* Internal Interfaces
*/
player_s* __player_get_item(int uid)
int pid = ttsd_data_get_pid(g_playing_info->uid);
/* send message to client about changing state */
- ttsdc_send_set_state_message (pid, g_playing_info->uid, APP_STATE_PAUSED);
+ ttsdc_send_set_state_message(pid, g_playing_info->uid, APP_STATE_PAUSED);
}
SLOG(LOG_DEBUG, get_tag(), "=====");
} else {
SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Destroy audio");
}
-
+
g_audio_type = 0;
g_sampling_rate = 0;
return;
}
- /* If wdata's event is 'start', current wdata is first data of engine for synthesis.
+ /* If wdata's event is 'start', current wdata is first data of engine for synthesis.
* If wdata's event is 'finish', player should check previous event to know whether this wdata is first or not.
- * When previous wdata's event is 'finish' and current wdata's event is 'finish',
- * the player should send utt started event.
+ * 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 == wdata.event ||
(TTSP_RESULT_EVENT_FINISH == player->event && TTSP_RESULT_EVENT_FINISH == wdata.event)) {
}
/*
-* Player Interfaces
+* Player Interfaces
*/
int ttsd_player_init()
{
g_playing_info = NULL;
g_audio_state = AUDIO_STATE_NONE;
g_audio_h = NULL;
-
+
int ret;
if (TTSD_MODE_DEFAULT == ttsd_get_mode()) {
if (0 != ret) {
SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to set session type");
}
-
+
ret = sound_manager_set_media_session_option(SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START, SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY);
if (0 != ret) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail set media session option");
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail set media session option");
} else {
- SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] set media session option");
+ SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] set media session option");
}
}
ecore_thread_max_set(1);
-
+
ret = __create_audio_out(TTSP_AUDIO_TYPE_RAW_S16, 16000);
if (0 != ret)
return -1;
int ttsd_player_create_instance(int uid)
{
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
-
+
/* Check uid is duplicated */
if (NULL != __player_get_item(uid)) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is already registered", uid);
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is already registered", uid);
return -1;
}
new_client->is_paused_data = false;
new_client->idx = 0;
new_client->paused_data.data = NULL;
-
+
SLOG(LOG_DEBUG, get_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, get_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, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
return -1;
}
if (NULL != data) {
/* compare uid */
if (uid == data->uid) {
- g_player_list = g_list_remove_link(g_player_list, iter);
+ g_player_list = g_list_remove_link(g_player_list, iter);
free(data);
break;
}
}
-
+
/* Get next item */
iter = g_list_next(iter);
}
int ttsd_player_play(int uid)
{
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
}
}
- SLOG(LOG_DEBUG, get_tag(), "[Player] start play : uid(%d)", uid );
+ SLOG(LOG_DEBUG, get_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, get_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, get_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 DEBUG] Active thread count : %d", ecore_thread_active_get());
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, get_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, get_tag(), "[Player] No current playing");
}
if (true == current->is_paused_data) {
int ttsd_player_pause(int uid)
{
- SLOG(LOG_DEBUG, get_tag(), "[Player] pause player : uid(%d)", uid );
+ SLOG(LOG_DEBUG, get_tag(), "[Player] pause player : uid(%d)", uid);
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
player_s* current;
current = __player_get_item(uid);
if (NULL == current) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid);
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid);
return -1;
}
int ttsd_player_resume(int uid)
{
- SLOG(LOG_DEBUG, get_tag(), "[Player] Resume player : uid(%d)", uid );
+ SLOG(LOG_DEBUG, get_tag(), "[Player] Resume player : uid(%d)", uid);
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
player_s* current;
current = __player_get_item(uid);
if (NULL == current) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
return -1;
}
int ttsd_player_all_stop()
{
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
data->paused_data.data = NULL;
}
}
-
+
data->is_paused_data = false;
data->idx = 0;
}
-
+
/* Get next item */
iter = g_list_next(iter);
}
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
TTSD_SYNTHESIS_CONTROL_DOING = 0,
TTSD_SYNTHESIS_CONTROL_DONE = 1,
TTSD_SYNTHESIS_CONTROL_EXPIRED = 2
-}ttsd_synthesis_control_e;
+} ttsd_synthesis_control_e;
typedef struct {
int uid;
int uttid;
-}utterance_t;
+} utterance_t;
/* If current engine exist */
static bool g_is_engine;
/* Start next synthesis */
__synthesis(uid);
}
- }
+ }
} else {
g_wait_timer = NULL;
}
if (NULL == sdata.lang || NULL == sdata.text) {
SLOG(LOG_ERROR, get_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 != sdata.lang) free(sdata.lang);
-
+
return 0;
}
}
/*
-* TTS Server Callback Functions
+* 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)
/* 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");
if (TTSP_RESULT_EVENT_CONTINUE == event) SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_CONTINUE");
if (TTSP_RESULT_EVENT_FINISH == event) SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_FINISH");
return 0;
}
- SLOG(LOG_DEBUG, get_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);
+ SLOG(LOG_DEBUG, get_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);
if (rate <= 0 || audio_type < 0 || audio_type > TTSP_AUDIO_TYPE_MAX) {
__server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
temp_data.event = event;
temp_data.audio_type = audio_type;
temp_data.rate = rate;
-
+
if (0 != ttsd_data_add_sound_data(uid, temp_data)) {
SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] Fail to add sound data : uid(%d)", uid);
}
} else {
SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_ERROR");
__server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
- }
+ }
SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS RESULT CALLBACK END");
bool __get_client_cb(int pid, int uid, app_state_e state, void* user_data)
{
/* clear client data */
- ttsd_data_clear_data(uid);
+ ttsd_data_clear_data(uid);
ttsd_data_set_client_state(uid, APP_STATE_READY);
/* send message */
- if ( 0 != ttsdc_send_set_state_message(pid, uid, APP_STATE_READY)) {
+ if (0 != ttsdc_send_set_state_message(pid, uid, APP_STATE_READY)) {
/* remove client */
ttsd_data_delete_client(uid);
- }
+ }
return true;
}
void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_param)
{
- switch(type) {
+ switch (type) {
case TTS_CONFIG_TYPE_ENGINE:
{
if (NULL == str_param) {
/* set current engine */
if (0 != ttsd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_WARN, get_tag(), "[Server WARNING] No Engine !!!" );
+ SLOG(LOG_WARN, get_tag(), "[Server WARNING] No Engine !!!");
g_is_engine = false;
- } else
+ } else
g_is_engine = true;
-
+
__server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) {
int ttsd_finalize()
{
ttsd_config_finalize();
-
+
ttsd_player_release();
ttsd_engine_agent_release();
result = ttsdc_send_hello(pid, uid);
if (0 == result) {
- SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) should be removed.", uid);
+ SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) should be removed.", uid);
ttsd_server_finalize(uid);
} else if (-1 == result) {
- SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Hello result has error");
+ SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Hello result has error");
}
}
return true;
}
ttsd_server_stop(uid);
-
+
ttsd_player_destroy_instance(uid);
/* Need to unload voice when used voice is unregistered */
SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to select valid voice : result lang is NULL");
return TTSD_ERROR_INVALID_VOICE;
}
-
+
speak_data_s data;
data.lang = strdup(lang);
Eina_Bool __send_interrupt_client(void *data)
{
int uid = (int)data;
-
+
int pid = ttsd_data_get_pid(uid);
if (TTSD_MODE_DEFAULT != ttsd_get_mode()) {
/* send message to client about changing state */
- ttsdc_send_set_state_message (pid, uid, APP_STATE_READY);
+ ttsdc_send_set_state_message(pid, uid, APP_STATE_READY);
} else {
- ttsdc_send_set_state_message (pid, uid, APP_STATE_PAUSED);
+ ttsdc_send_set_state_message(pid, uid, APP_STATE_PAUSED);
}
return EINA_FALSE;
SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid(%d) is NOT valid ", uid);
return TTSD_ERROR_INVALID_PARAMETER;
}
-
+
if (APP_STATE_PLAYING == state) {
SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state(%d) is 'play' ", uid);
return TTSD_ERROR_NONE;
/* pause player */
if (0 != ttsd_server_stop(current_uid)) {
SLOG(LOG_WARN, get_tag(), "[Server ERROR] Fail to stop : uid (%d)", current_uid);
- }
-
+ }
+
ecore_timer_add(0, __send_interrupt_client, (void*)current_uid);
} else {
/* Default mode policy of interrupt is "Pause" */
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");
return TTSD_ERROR_INVALID_PARAMETER;
- }
+ }
/* get current voice */
int ret = ttsd_engine_get_default_voice(language, voice_type);
return ret;
}
- SLOG(LOG_DEBUG, get_tag(), "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type);
+ SLOG(LOG_DEBUG, get_tag(), "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type);
return TTSD_ERROR_NONE;
}
/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 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
#include <tts.h>
#include <dlog.h>
-#define TTS_STRDUP(src) ((src != NULL) ? strdup(src) : NULL )
+#define TTS_STRDUP(src) ((src != NULL) ? strdup(src) : NULL)
static tts_h g_tts;
static char* g_text = NULL;
static bool __tts_test_get_text_from_file(const char* path, char** text)
{
- if(!path) return 0;
- if(!text) return 0;
+ if (!path) return 0;
+ if (!text) return 0;
FILE *fp = NULL;
- if((fp = fopen(path, "rb")) == NULL ) {
+ if ((fp = fopen(path, "rb")) == NULL) {
SLOG(LOG_ERROR, tts_tag(), "Fail to open file (%s)", path);
return 0;
}
- fseek(fp , 0 , SEEK_END);
-
+ fseek(fp , 0 , SEEK_END);
+
int text_len = ftell(fp);
if (0 >= text_len) {
SLOG(LOG_ERROR, tts_tag(), "File has no contents\n");
fclose(fp);
return 0;
}
-
+
int result_len = 1;
while (!feof(fp)) {
result_len = fread(*text, sizeof(char), text_len, fp);
char* lang = NULL;
lang = (char*)data;
-
+
ret = tts_add_text(g_tts, g_text, lang, TTS_VOICE_TYPE_AUTO, TTS_SPEED_AUTO, &utt_id);
if (TTS_ERROR_NONE != ret) {
SLOG(LOG_ERROR, tts_tag(), "Fail to add text\n");
return;
}
-int main (int argc, char *argv[])
+int main(int argc, char *argv[])
{
if (1 == argc || 5 < argc) {
SLOG(LOG_DEBUG, tts_tag(), "Please check parameter\n");
int n = 0;
- while(NULL != argv[n]) {
+ while (NULL != argv[n]) {
- if(!strcmp("-h", argv[n])) {
+ if (!strcmp("-h", argv[n])) {
SLOG(LOG_DEBUG, tts_tag(), "\n");
SLOG(LOG_DEBUG, tts_tag(), " ==========================================\n");
SLOG(LOG_DEBUG, tts_tag(), " TTS test usage\n");
SLOG(LOG_DEBUG, tts_tag(), "\n");
return 0;
}
-
- // check langage option
- if(!strcmp("-l", argv[n])) {
+
+ /* check langage option */
+ if (!strcmp("-l", argv[n])) {
lang = TTS_STRDUP(argv[n+1]);
SLOG(LOG_ERROR, tts_tag(), "Language : %s\n", lang);
}
- // check text to synthesize
+ /* check text to synthesize */
else if (!strcmp("-t", argv[n])) {
g_text = TTS_STRDUP(argv[n+1]);
SLOG(LOG_ERROR, tts_tag(), "Text : %s\n", g_text);
}
- // check file path to synthesize
+ /* check file path to synthesize */
else if (!strcmp("-f", argv[n])) {
src_path = TTS_STRDUP(argv[n+1]);
SLOG(LOG_ERROR, tts_tag(), "File path : %s\n", src_path);
- if(!__tts_test_get_text_from_file(src_path, &g_text)) {
+ if (!__tts_test_get_text_from_file(src_path, &g_text)) {
return 0;
}
}
n++;
}
-
- if(!g_text && !src_path) {
+
+ if (!g_text && !src_path) {
SLOG(LOG_ERROR, tts_tag(), "Invalid parameter, check help with command tts-test -h");
return 0;
}
-//===================================
+ /*=================================== */
tts_mode_e mode = TTS_MODE_DEFAULT;
ecore_shutdown();
- if(src_path) free(src_path);
- if(lang) free(lang);
- if(g_text) free(g_text);
+ if (src_path) free(src_path);
+ if (lang) free(lang);
+ if (g_text) free(g_text);
SLOG(LOG_DEBUG, tts_tag(), "===== TTS END =====\n\n\n");