int ret = -1;
int count = 0;
+ int screen_reader = -1;
/* check state */
switch (client->current_state) {
case TTS_STATE_PAUSED:
case TTS_STATE_PLAYING:
case TTS_STATE_READY:
+ ret = vconf_get_bool(TTS_ACCESSIBILITY_KEY, &screen_reader);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get screen reader");
+ } else {
+ SLOG(LOG_INFO, tts_tag(), "[INFO] Success to get screen reader(%d), g_screen_reader(%s), client->mode(%d)", screen_reader, (true == g_screen_reader) ? "True" : "False", client->mode);
+ g_screen_reader = (bool)screen_reader;
+ }
if (!(false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode)) {
- while (0 != ret) {
+ do {
ret = tts_dbus_request_finalize(client->uid);
if (0 != ret) {
if (TTS_ERROR_TIMED_OUT != ret) {
}
}
}
- }
+ } while (0 != ret);
} else {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize : g_sr(%d) mode(%d)", g_screen_reader, client->mode);
}
int ret = -1;
int count = 0;
+ int screen_reader = -1;
+
+ ret = vconf_get_bool(TTS_ACCESSIBILITY_KEY, &screen_reader);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get screen reader");
+ } else {
+ SLOG(LOG_INFO, tts_tag(), "[INFO] Success to get screen reader(%d), g_screen_reader(%s), client->mode(%d)", screen_reader, (true == g_screen_reader) ? "True" : "False", client->mode);
+ g_screen_reader = (bool)screen_reader;
+ }
+
if (!(false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode)) {
- while (0 != ret) {
+ do {
ret = tts_dbus_request_finalize(client->uid);
if (0 != ret) {
if (TTS_ERROR_TIMED_OUT != ret) {
}
}
}
- }
+ } while (0 != ret);
} else {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize : g_sr(%d) mode(%d)", g_screen_reader, client->mode);
}
ret = tts_config_mgr_get_voice_list(current_engine, __tts_supported_voice_cb, client->tts);
- if (NULL != current_engine)
+ if (NULL != current_engine) {
free(current_engine);
+ current_engine = NULL;
+ }
client->supported_voice_cb = NULL;
client->supported_voice_user_data = NULL;
*err_msg = strdup(client->err_msg);
SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Error msg (%s)", *err_msg);
} else {
+ *err_msg = NULL;
SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Error msg (NULL)");
}
}
}
- if (NULL != temp) free(temp);
+ if (NULL != temp) {
+ free(temp);
+ temp = NULL;
+ }
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, " ");
return ECORE_CALLBACK_PASS_ON;
}
+static void __tts_dbus_connection_free()
+{
+ if (NULL != g_conn_listener) {
+ dbus_connection_close(g_conn_listener);
+ dbus_connection_unref(g_conn_listener);
+ g_conn_listener = NULL;
+ }
+ if (NULL != g_conn_sender) {
+ dbus_connection_close(g_conn_sender);
+ dbus_connection_unref(g_conn_sender);
+ g_conn_sender = NULL;
+ }
+}
+
int tts_dbus_open_connection()
{
if (NULL != g_conn_sender && NULL != g_conn_listener) {
if (NULL == g_conn_listener) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] fail to get dbus connection for listener");
+ __tts_dbus_connection_free();
return TTS_ERROR_OPERATION_FAILED;
}
int fd = 0;
if (true != dbus_connection_get_unix_fd(g_conn_listener, &fd)) {
SLOG(LOG_ERROR, TAG_TTSC, "Fail to get fd from dbus");
+ __tts_dbus_connection_free();
return TTS_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_TTSC, "Get fd from dbus : %d", fd);
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) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get fd handler from ecore");
+ __tts_dbus_connection_free();
return TTS_ERROR_OPERATION_FAILED;
}
g_dbus_fd_handler = NULL;
}
- dbus_connection_close(g_conn_sender);
- dbus_connection_close(g_conn_listener);
-
- dbus_connection_unref(g_conn_sender);
- dbus_connection_unref(g_conn_listener);
-
- g_conn_sender = NULL;
- g_conn_listener = NULL;
+ __tts_dbus_connection_free();
return 0;
}
int tts_dbus_reconnect()
{
+ if (!g_conn_sender || !g_conn_listener) {
+ tts_dbus_close_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;
+ }
+
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)",
static GSList* g_config_client_list = NULL;
static tts_config_s* g_config_info = NULL;
+extern char g_engine_id[128];
+extern char g_setting[128];
+extern char g_language[128];
static Ecore_Fd_Handler* g_config_fd_handler_noti = NULL;
static int g_config_fd_noti;
return -1;
}
- if (0 == strcmp(engine_id, engine_info->uuid)) {
+ if (NULL != engine_info->uuid && 0 == strcmp(engine_id, engine_info->uuid)) {
SLOG(LOG_DEBUG, tts_tag(), "Default engine is valid : %s", engine_id);
return 0;
}
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
- if (NULL != g_config_info->engine_id) free(g_config_info->engine_id);
- if (NULL != g_config_info->setting) free(g_config_info->setting);
-
- g_config_info->engine_id = strdup(engine_info->uuid);
- g_config_info->setting = strdup(engine_info->setting);
+ if (NULL != engine_info->uuid) {
+ memset(g_engine_id, '\0', sizeof(g_engine_id));
+ g_config_info->engine_id = g_engine_id;
+ strncpy(g_config_info->engine_id, engine_info->uuid, sizeof(g_engine_id) - 1);
+ }
+ if (NULL != engine_info->setting) {
+ memset(g_setting, '\0', sizeof(g_setting));
+ g_config_info->setting = g_setting;
+ strncpy(g_config_info->setting, engine_info->setting, sizeof(g_setting) - 1);
+ }
SLOG(LOG_DEBUG, tts_tag(), "Default engine is changed : %s", g_config_info->engine_id);
voice = iter_voice->data;
if (NULL != voice) {
- if (NULL != voice->language && NULL != g_config_info->language) {
+ if (NULL != voice->language) {
if (0 == strcmp(voice->language, g_config_info->language)) {
if (voice->type == g_config_info->type) {
/* language is valid */
is_valid_voice = true;
- free(g_config_info->language);
- g_config_info->language = strdup(voice->language);
+ memset(g_language, '\0', sizeof(g_language));
+ g_config_info->language = g_language;
+ strncpy(g_config_info->language, voice->language, sizeof(g_language) - 1);
+
g_config_info->type = voice->type;
SLOG(LOG_DEBUG, tts_tag(), "Default voice is changed : lang(%s) type(%d)", voice->language, voice->type);
if (false == is_valid_voice) {
/* Select first voice as default */
- if (NULL != g_config_info->language) {
- free(g_config_info->language);
-
- iter_voice = g_slist_nth(engine_info->voices, 0);
- if (NULL == iter_voice) {
- SLOG(LOG_ERROR, tts_tag(), "Fail to get voice list");
- return TTS_CONFIG_ERROR_OPERATION_FAILED;
- }
- voice = iter_voice->data;
+ memset(g_language, '\0', sizeof(g_language));
+ g_config_info->language = g_language;
- if (NULL == voice || NULL == voice->language) {
- SLOG(LOG_ERROR, tts_tag(), "Fail to get voice info from list");
- return TTS_CONFIG_ERROR_OPERATION_FAILED;
- }
+ iter_voice = g_slist_nth(engine_info->voices, 0);
+ if (NULL == iter_voice) {
+ SLOG(LOG_ERROR, tts_tag(), "Fail to get voice list");
+ return TTS_CONFIG_ERROR_OPERATION_FAILED;
+ }
+ voice = iter_voice->data;
- g_config_info->language = strdup(voice->language);
- g_config_info->type = voice->type;
- SLOG(LOG_DEBUG, tts_tag(), "Default voice is changed : lang(%s) type(%d)", voice->language, voice->type);
+ if (NULL == voice || NULL == voice->language) {
+ SLOG(LOG_ERROR, tts_tag(), "Fail to get voice info from list");
+ return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
+ strncpy(g_config_info->language, voice->language, sizeof(g_language) - 1);
+
+ g_config_info->type = voice->type;
+ SLOG(LOG_DEBUG, tts_tag(), "Default voice is changed : lang(%s) type(%d)", voice->language, voice->type);
}
if (0 != tts_parser_set_engine(g_config_info->engine_id, g_config_info->setting,
/* engine changed */
if (NULL != engine || NULL != setting) {
if (NULL != engine) {
- if (NULL != g_config_info->engine_id)
- free(g_config_info->engine_id);
-
- g_config_info->engine_id = strdup(engine);
+ memset(g_engine_id, '\0', sizeof(g_engine_id));
+ g_config_info->engine_id = g_engine_id;
+ strncpy(g_config_info->engine_id, engine, sizeof(g_engine_id) - 1);
}
if (NULL != setting) {
- if (NULL != g_config_info->setting)
- free(g_config_info->setting);
-
- g_config_info->setting = strdup(setting);
+ memset(g_setting, '\0', sizeof(g_setting));
+ g_config_info->setting = g_setting;
+ strncpy(g_config_info->setting, setting, sizeof(g_setting) - 1);
}
SECURE_SLOG(LOG_DEBUG, tts_tag(), "Engine change(%s)", g_config_info->engine_id);
before_type = g_config_info->type;
if (NULL != lang) {
- if (NULL != g_config_info->language)
- free(g_config_info->language);
-
- g_config_info->language = strdup(lang);
+ memset(g_language, '\0', sizeof(g_language));
+ g_config_info->language = g_language;
+ strncpy(g_config_info->language, lang, sizeof(g_language) - 1);
}
if (-1 != voice_type) {
g_config_info->type = voice_type;
if (NULL != before_lang) {
free(before_lang);
+ before_lang = NULL;
}
}
}
}
- if (NULL != engine) free(engine);
- if (NULL != setting) free(setting);
- if (NULL != lang) free(lang);
+ if (NULL != engine) {
+ free(engine);
+ engine = NULL;
+ }
+ if (NULL != setting) {
+ free(setting);
+ setting = NULL;
+ }
+ if (NULL != lang) {
+ free(lang);
+ lang = NULL;
+ }
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Undefined event");
}
char temp_lang[6] = {'\0', };
strncpy(temp_lang, value, 5);
free(value);
+ value = NULL;
if (true == __tts_config_mgr_check_lang_is_valid(g_config_info->engine_id, temp_lang, g_config_info->type)) {
/* tts default voice change */
before_lang = strdup(g_config_info->language);
before_type = g_config_info->type;
- free(g_config_info->language);
- g_config_info->language = strdup(temp_lang);
+ memset(g_language, '\0', sizeof(g_language));
+ g_config_info->language = g_language;
+ strncpy(g_config_info->language, temp_lang, sizeof(g_language) - 1);
SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Config] Default voice : lang(%s) type(%d)",
g_config_info->language, g_config_info->type);
if (NULL != before_lang) {
free(before_lang);
+ before_lang = NULL;
}
} else {
/* Display language is not valid */
iter = g_slist_next(iter);
}
- if (NULL != g_config_info->language) {
- free(g_config_info->language);
- g_config_info->language = strdup(tmp_language);
- }
+
+ memset(g_language, '\0', sizeof(g_language));
+ g_config_info->language = g_language;
+ strncpy(g_config_info->language, tmp_language, sizeof(g_language) - 1);
g_config_info->type = tmp_type;
free(tmp_language);
+ tmp_language = NULL;
}
return 0;
} else {
SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Saved default voice : lang(%s), type(%d)", g_config_info->language, g_config_info->type);
}
- if (NULL != temp_lang) free(temp_lang);
+ if (NULL != temp_lang) {
+ free(temp_lang);
+ temp_lang = NULL;
+ }
}
GSList *iter = NULL;
close(tmp->dir_fd);
free(tmp);
+ tmp = NULL;
}
g_ino_list = g_list_remove_link(g_ino_list, iter);
}
if (NULL != tmp_language) {
- if (NULL != g_config_info->language) {
- free(g_config_info->language);
- g_config_info->language = strdup(tmp_language);
- }
+ memset(g_language, '\0', sizeof(g_language));
+ g_config_info->language = g_language;
+ strncpy(g_config_info->language, tmp_language, sizeof(g_language) - 1);
g_config_info->type = tmp_type;
free(tmp_language);
+ tmp_language = NULL;
if (0 != tts_parser_set_voice(g_config_info->language, g_config_info->type)) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to save config");
return TTS_CONFIG_ERROR_INVALID_PARAMETER;
/* Check current engine id with new engine id */
- if (NULL != g_config_info->engine_id) {
- if (0 == strcmp(g_config_info->engine_id, engine))
- return 0;
- }
+ if (0 == strcmp(g_config_info->engine_id, engine))
+ return 0;
if (0 >= g_slist_length(g_engine_list)) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine!!");
continue;
}
- if (NULL != g_config_info->engine_id)
- free(g_config_info->engine_id);
-
- g_config_info->engine_id = strdup(engine);
+ memset(g_engine_id, '\0', sizeof(g_engine_id));
+ g_config_info->engine_id = g_engine_id;
+ strncpy(g_config_info->engine_id, engine, sizeof(g_engine_id) - 1);
if (NULL != engine_info->setting) {
- if (NULL != g_config_info->setting) {
- free(g_config_info->setting);
- g_config_info->setting = NULL;
- }
- g_config_info->setting = strdup(engine_info->setting);
+ memset(g_setting, '\0', sizeof(g_setting));
+ g_config_info->setting = g_setting;
+ strncpy(g_config_info->setting, engine_info->setting, sizeof(g_setting) - 1);
}
/* Engine is valid*/
}
if (false == is_valid_voice) {
- if (NULL != g_config_info->language) {
- free(g_config_info->language);
-
- iter_voice = g_slist_nth(engine_info->voices, 0);
- if (NULL != iter_voice) {
- voice = iter_voice->data;
- if (NULL != voice) {
- if (NULL != voice->language)
- g_config_info->language = strdup(voice->language);
- g_config_info->type = voice->type;
- }
+ memset(g_language, '\0', sizeof(g_language));
+ g_config_info->language = g_language;
+
+ iter_voice = g_slist_nth(engine_info->voices, 0);
+ if (NULL != iter_voice) {
+ voice = iter_voice->data;
+ if (NULL != voice) {
+ if (NULL != voice->language)
+ strncpy(g_config_info->language, voice->language, sizeof(g_language) - 1);
+
+ g_config_info->type = voice->type;
}
}
}
if (NULL == language || NULL == type)
return TTS_CONFIG_ERROR_INVALID_PARAMETER;
- if (NULL != g_config_info->language) {
+ if (0 != strlen(g_config_info->language)) {
*language = strdup(g_config_info->language);
*type = g_config_info->type;
} else {
}
/* Check language is valid */
- if (NULL != g_config_info->language) {
- if (0 != tts_parser_set_voice(language, type)) {
- SLOG(LOG_ERROR, tts_tag(), "Fail to save default voice");
- return TTS_CONFIG_ERROR_OPERATION_FAILED;
- }
- free(g_config_info->language);
- g_config_info->language = strdup(language);
- g_config_info->type = type;
-
- } else {
- SLOG(LOG_ERROR, tts_tag(), "language is NULL");
+ if (0 != tts_parser_set_voice(language, type)) {
+ SLOG(LOG_ERROR, tts_tag(), "Fail to save default voice");
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
+ memset(g_language, '\0', sizeof(g_language));
+ g_config_info->language = g_language;
+ strncpy(g_config_info->language, language, sizeof(g_language) - 1);
+
+ g_config_info->type = type;
return 0;
}
if (NULL == language)
return false;
- if (NULL == g_config_info->engine_id) {
+ if (0 == strlen(g_config_info->engine_id)) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Default engine id is NULL");
return false;
}
extern char* tts_tag();
static xmlDocPtr g_config_doc = NULL;
+char g_engine_id[128] = {0,};
+char g_setting[128] = {0,};
+char g_language[128] = {0,};
int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info)
{
if (NULL == temp) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Out of memory");
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_NAME)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- if (NULL != temp->name) free(temp->name);
+ if (NULL != temp->name) {
+ free(temp->name);
+ temp->name = NULL;
+ }
temp->name = strdup((char*)key);
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_NAME);
}
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_ID)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- if (NULL != temp->uuid) free(temp->uuid);
+ if (NULL != temp->uuid) {
+ free(temp->uuid);
+ temp->uuid = NULL;
+ }
temp->uuid = strdup((char*)key);
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_ID);
}
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_SETTING)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- if (NULL != temp->setting) free(temp->setting);
+ if (NULL != temp->setting) {
+ free(temp->setting);
+ temp->setting = NULL;
+ }
temp->setting = strdup((char*)key);
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_SETTING);
}
temp_voice->type = (int)TTS_CONFIG_VOICE_TYPE_USER_DEFINED;
}
xmlFree(attr);
+ attr = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE_TYPE);
free(temp_voice);
key = xmlNodeGetContent(voice_node);
if (NULL != key) {
- if (NULL != temp_voice->language) free(temp_voice->language);
+ if (NULL != temp_voice->language) {
+ free(temp_voice->language);
+ temp_voice->language = NULL;
+ }
temp_voice->language = strdup((char*)key);
xmlFree(key);
+ key = NULL;
temp->voices = g_slist_append(temp->voices, temp_voice);
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE);
return -1;
}
- if (NULL != engine_info->name) free(engine_info->name);
- if (NULL != engine_info->uuid) free(engine_info->uuid);
- if (NULL != engine_info->setting) free(engine_info->setting);
+ if (NULL != engine_info->name) {
+ free(engine_info->name);
+ engine_info->name = NULL;
+ }
+ if (NULL != engine_info->uuid) {
+ free(engine_info->uuid);
+ engine_info->uuid = NULL;
+ }
+ if (NULL != engine_info->setting) {
+ free(engine_info->setting);
+ engine_info->setting = NULL;
+ }
tts_config_voice_s *temp_voice;
temp_voice = g_slist_nth_data(engine_info->voices, 0);
while (NULL != temp_voice) {
if (NULL != temp_voice) {
- if (NULL != temp_voice->language) free(temp_voice->language);
+ if (NULL != temp_voice->language) {
+ free(temp_voice->language);
+ temp_voice->language = NULL;
+ }
engine_info->voices = g_slist_remove(engine_info->voices, temp_voice);
free(temp_voice);
+ temp_voice = NULL;
}
temp_voice = g_slist_nth_data(engine_info->voices, 0);
}
- if (NULL != engine_info) free(engine_info);
+ if (NULL != engine_info) {
+ free(engine_info);
+ engine_info = NULL;
+ }
- return 0;
+ return 0;
}
int tts_parser_print_engine_info(tts_engine_info_s* engine_info)
/* Get a first item */
iter = g_slist_nth(engine_info->voices, 0);
- int i = 1;
+ int i = 1;
while (NULL != iter) {
/*Get handle data from list*/
temp_voice = iter->data;
doc = xmlParseFile(TTS_DEFAULT_CONFIG);
if (doc == NULL) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", TTS_DEFAULT_CONFIG);
+ xmlCleanupParser();
return -1;
}
is_default_open = true;
if (TTS_RETRY_COUNT == retry_count) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", TTS_CONFIG);
+ xmlCleanupParser();
return -1;
}
}
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
xmlFreeDoc(doc);
doc = NULL;
+ xmlCleanupParser();
return -1;
}
SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
xmlFreeDoc(doc);
doc = NULL;
+ xmlCleanupParser();
return -1;
}
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
xmlFreeDoc(doc);
doc = NULL;
+ xmlCleanupParser();
return -1;
}
if (NULL == temp) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Out of memory");
xmlFreeDoc(doc);
+ doc = NULL;
+ xmlCleanupParser();
return -1;
}
- temp->engine_id = NULL;
- temp->setting = NULL;
- temp->language = NULL;
+ memset(g_engine_id, '\0', sizeof(g_engine_id));
+ memset(g_setting, '\0', sizeof(g_setting));
+ memset(g_language, '\0', sizeof(g_language));
+
+ temp->engine_id = g_engine_id;
+ temp->setting = g_setting;
+ temp->language = g_language;
while (cur != NULL) {
if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_ENGINE_ID)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- if (NULL != temp->engine_id) free(temp->engine_id);
- temp->engine_id = strdup((char*)key);
+ strncpy(temp->engine_id, (char*)key, sizeof(g_engine_id) - 1);
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] engine id is NULL");
}
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_ENGINE_SETTING)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- if (NULL != temp->setting) free(temp->setting);
- temp->setting = strdup((char*)key);
+ strncpy(temp->setting, (char*)key, sizeof(g_setting) - 1);
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] setting path is NULL");
}
-
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_AUTO_VOICE)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
}
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] voice type is NULL");
}
}
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] voice type is NULL");
}
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_LANGUAGE)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- if (NULL != temp->language) free(temp->language);
- temp->language = strdup((char*)key);
+ strncpy(temp->language, (char*)key, sizeof(g_language) - 1);
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] engine uuid is NULL");
}
if (NULL != key) {
temp->pitch = atoi((char*)key);
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Pitch is NULL");
}
g_config_doc = NULL;
}
if (NULL != config_info) {
- if (NULL != config_info->engine_id) {
- free(config_info->engine_id);
- config_info->engine_id = NULL;
- }
- if (NULL != config_info->setting) {
- free(config_info->setting);
- config_info->setting = NULL;
- }
- if (NULL != config_info->language) {
- free(config_info->language);
- config_info->language = NULL;
- }
free(config_info);
config_info = NULL;
}
+ xmlCleanupParser();
+
return 0;
}
}
xmlFreeDoc(doc);
+ doc = NULL;
SLOG(LOG_DEBUG, tts_tag(), "[SUCCESS] Copying xml");
return 0;
default: xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_FEMALE); break;
}
}
-
+
cur = cur->next;
}
if (0 != xmlStrcmp(key_old, key_new)) {
SLOG(LOG_DEBUG, tts_tag(), "Old engine id(%s), New engine(%s)",
(char*)key_old, (char*)key_new);
- if (NULL != *engine) free(*engine);
+ if (NULL != *engine) {
+ free(*engine);
+ *engine = NULL;
+ }
*engine = strdup((char*)key_new);
}
xmlFree(key_new);
+ key_new = NULL;
}
xmlFree(key_old);
+ key_old = NULL;
}
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
if (0 != xmlStrcmp(key_old, key_new)) {
SLOG(LOG_DEBUG, tts_tag(), "Old engine setting(%s), New engine setting(%s)",
(char*)key_old, (char*)key_new);
- if (NULL != *setting) free(*setting);
+ if (NULL != *setting) {
+ free(*setting);
+ *setting = NULL;
+ }
*setting = strdup((char*)key_new);
}
xmlFree(key_new);
+ key_new = NULL;
}
xmlFree(key_old);
+ key_old = NULL;
}
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
}
}
xmlFree(key_new);
+ key_new = NULL;
}
xmlFree(key_old);
+ key_old = NULL;
}
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
if (0 != xmlStrcmp(key_old, key_new)) {
SLOG(LOG_DEBUG, tts_tag(), "Old language(%s), New language(%s)",
(char*)key_old, (char*)key_new);
- if (NULL != *language) free(*language);
+ if (NULL != *language) {
+ free(*language);
+ *language = NULL;
+ }
*language = strdup((char*)key_new);
}
xmlFree(key_new);
+ key_new = NULL;
}
xmlFree(key_old);
+ key_old = NULL;
}
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
}
}
xmlFree(key_new);
+ key_new = NULL;
}
xmlFree(key_old);
+ key_old = NULL;
}
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
*speech_rate = atoi((char*)key_new);
}
xmlFree(key_new);
+ key_new = NULL;
}
xmlFree(key_old);
+ key_old = NULL;
}
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
*pitch = atoi((char*)key_new);
}
xmlFree(key_new);
+ key_new = NULL;
}
xmlFree(key_old);
+ key_old = NULL;
}
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
#ifndef __TIZEN_UIX_TTS_DOC_H__
#define __TIZEN_UIX_TTS_DOC_H__
+
/**
- * @defgroup CAPI_UIX_TTS_MODULE TTS
* @ingroup CAPI_UIX_FRAMEWORK
+ * @defgroup CAPI_UIX_TTS_MODULE TTS
* @brief The @ref CAPI_UIX_TTS_MODULE API provides functions for synthesizing voice from text and playing synthesized sound data.
- *
* @section CAPI_UIX_TTS_MODULE_HEADER Required Header
- * \#include <tts.h>
+ * \#include <tts.h>
*
* @section CAPI_UIX_TTS_MODULE_OVERVIEW Overview
* You can use Text-To-Speech (TTS) API to read sound data transformed by the engine from input texts.
* Applications can add input-text to queue for reading continuously and control the player that can play, pause, and stop sound data synthesized from text.
- *
* To use TTS, follow these steps:<br>
* 1. Create a handle <br>
* 2. Register callback functions for notifications <br>
* 7. Resume the player <br>
* 8. Stop the player <br>
* 9. Destroy a handle <br>
- *
* The TTS API also notifies you (by callback mechanism) when the state of TTS is changed,
* utterance is started and completed, default voice is changed or an error occured.
* An application should register callback functions: tts_state_changed_cb(), tts_utterance_started_cb(),
* Please check both previous state and post state from the table carefully.
* In case of tts_prepare() function, state doesn't be changed at once, but acynchronously.
* From the above state diagram, you can see dotted line as asynchronous api.
- * In this case, the state changed callback is only way to know state transition as ready.
- *
+ * In this case, the state changed callback is only way to know state transition as ready.
* <table>
* <tr>
* <th>FUNCTION</th>
* The following table shows state-dependent function calls.
* It is forbidden to call functions listed below in wrong states.
* Violation of this rule may result in an unpredictable behavior.
- *
* <table>
* <tr>
* <th>FUNCTION</th>
*
* @section CAPI_UIX_TTS_MODULE_FEATURE Related Features
* This API is related with the following features:<br>
- * - http://tizen.org/feature/speech.synthesis<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_DOC_H__ */
#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>
- *
+ * \#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>
* <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>
+ * 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>
* <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>
* </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>
- *
+ * - 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__ */
#define TTS_METADATA_CREDENTIAL_REQUIRED "http://tizen.org/metadata/tts-engine/credential-required"
#define TTS_METADATA_SETTING "http://tizen.org/metadata/tts-engine/setting"
+/* Define Macro */
+#define FREE(x) { if (NULL != x) { free(x); x = NULL; } }
+#define G_FREE(x) { if (NULL != x) { g_free(x); x = NULL; } }
+
typedef struct metadata {
const char *key;
const char *value;
if (NULL == dir_config_base || NULL == dir_home || NULL == dir_engine_base || NULL == dir_engine_info) {
LOGE("[ERROR] Fail to allocate memory");
- if (NULL != dir_config_base) {
- free(dir_config_base);
- dir_config_base = NULL;
- }
- if (NULL != dir_home) {
- free(dir_home);
- dir_home = NULL;
- }
- if (NULL != dir_engine_base) {
- free(dir_engine_base);
- dir_engine_base = NULL;
- }
- if (NULL != dir_engine_info) {
- free(dir_engine_info);
- dir_engine_info = NULL;
- }
+ FREE(dir_config_base)
+ FREE(dir_home)
+ FREE(dir_engine_base)
+ FREE(dir_engine_info)
+
return -1;
}
/* Make directories */
+ int fd = -1;
// if (0 != access(dir_config_base, F_OK)) {
- if (-1 == open(dir_config_base, O_DIRECTORY)) {
+ fd = open(dir_config_base, O_DIRECTORY);
+ if (-1 == fd) {
LOGE("[INFO] No directory : %s, errno : %d", dir_config_base, errno);
if (0 != mkdir(dir_config_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_config_base, errno);
- free(dir_config_base);
- dir_config_base = NULL;
- free(dir_home);
- dir_home = NULL;
- free(dir_engine_base);
- dir_engine_base = NULL;
- free(dir_engine_info);
- dir_engine_info = NULL;
+ FREE(dir_config_base)
+ FREE(dir_home)
+ FREE(dir_engine_base)
+ FREE(dir_engine_info)
return -1;
} else {
LOGD("Success to make directory : %s", dir_config_base);
LOGD("[DEBUG] Success to change user and group");
}
}
+ } else {
+ close(fd);
}
// if (0 != access(dir_home, F_OK)) {
- if (-1 == open(dir_home, O_DIRECTORY)) {
+ fd = open(dir_home, O_DIRECTORY);
+ if (-1 == fd) {
LOGE("[INFO] No directory : %s, errno : %d", dir_home, errno);
if (0 != mkdir(dir_home, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_home, errno);
- free(dir_config_base);
- dir_config_base = NULL;
- free(dir_home);
- dir_home = NULL;
- free(dir_engine_base);
- dir_engine_base = NULL;
- free(dir_engine_info);
- dir_engine_info = NULL;
+ FREE(dir_config_base)
+ FREE(dir_home)
+ FREE(dir_engine_base)
+ FREE(dir_engine_info)
return -1;
} else {
LOGD("Success to make directory : %s", dir_home);
LOGD("[DEBUG] Success to change user and group");
}
}
+ } else {
+ close(fd);
}
// if (0 != access(dir_engine_base, F_OK)) {
- if (-1 == open(dir_engine_base, O_DIRECTORY)) {
+ fd = open(dir_engine_base, O_DIRECTORY);
+ if (-1 == fd) {
LOGE("[INFO] No directory : %s, errno : %d", dir_engine_base, errno);
if (0 != mkdir(dir_engine_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_base, errno);
- free(dir_config_base);
- dir_config_base = NULL;
- free(dir_home);
- dir_home = NULL;
- free(dir_engine_base);
- dir_engine_base = NULL;
- free(dir_engine_info);
- dir_engine_info = NULL;
+ FREE(dir_config_base)
+ FREE(dir_home)
+ FREE(dir_engine_base)
+ FREE(dir_engine_info)
return -1;
} else {
LOGD("Success to make directory : %s", dir_engine_base);
LOGD("[DEBUG] Success to change user and group");
}
}
+ } else {
+ close(fd);
}
// if (0 != access(dir_engine_info, F_OK)) {
- if (-1 == open(dir_engine_info, O_DIRECTORY)) {
+ fd = open(dir_engine_info, O_DIRECTORY);
+ if (-1 == fd) {
LOGE("[INFO] No directory : %s, errno : %d", dir_engine_info, errno);
if (0 != mkdir(dir_engine_info, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_info, errno);
- free(dir_config_base);
- dir_config_base = NULL;
- free(dir_home);
- dir_home = NULL;
- free(dir_engine_base);
- dir_engine_base = NULL;
- free(dir_engine_info);
- dir_engine_info = NULL;
+ FREE(dir_config_base)
+ FREE(dir_home)
+ FREE(dir_engine_base)
+ FREE(dir_engine_info)
return -1;
} else {
LOGD("Success to make directory : %s", dir_engine_info);
LOGD("[DEBUG] Success to change user and group");
}
}
+ } else {
+ close(fd);
}
}
}
- free(dir_config_base);
- dir_config_base = NULL;
- free(dir_home);
- dir_home = NULL;
- free(dir_engine_base);
- dir_engine_base = NULL;
- free(dir_engine_info);
- dir_engine_info = NULL;
+ FREE(dir_config_base)
+ FREE(dir_home)
+ FREE(dir_engine_base)
+ FREE(dir_engine_info)
LOGD("===");
return 0;
}
}
- free(dir_engine_info);
- dir_engine_info = NULL;
+ FREE(dir_engine_info)
LOGD("===");
return 0;
char* voice = NULL;
char* lang = NULL;
char* type = NULL;
+ if (NULL == root || NULL == language) {
+ LOGE("Invalid parameter, root(%p), language(%s)", root, language);
+ return;
+ }
char *tmp_lang = NULL;
char *tmp_free = NULL;
}
xmlAddChild(root, voices_node);
- free(tmp_free);
- tmp_free = NULL;
+ FREE(tmp_free)
}
static int __write_metadata_inxml(const char *pkgid, const char *appid, GList *list)
LOGE("[ERROR] Fail to get target uid");
g_object_unref(g_guser);
g_guser = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
LOGD("[DEBUG] usertype: %s", g_user_type);
if (0 >= g_list_length(list)) {
LOGE("[ERROR] No Engine Metadata");
- g_free(g_user_type);
+ G_FREE(g_user_type)
return 0;
}
if (0 != __write_metadata_inxml(pkgid, appid, list)) {
LOGE("[ERROR] Fail to write metadata in the xml");
xmlFreeDoc(g_doc);
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) {
LOGE("[ERROR] Fail to allocate memory");
- if (NULL != g_dir_config_base) {
- free(g_dir_config_base);
- g_dir_config_base = NULL;
- }
- if (NULL != g_dir_home) {
- free(g_dir_home);
- g_dir_home = NULL;
- }
- if (NULL != g_dir_engine_base) {
- free(g_dir_engine_base);
- g_dir_engine_base = NULL;
- }
- if (NULL != g_dir_engine_info) {
- free(g_dir_engine_info);
- g_dir_engine_info = NULL;
- }
+ FREE(g_dir_config_base)
+ FREE(g_dir_home)
+ FREE(g_dir_engine_base)
+ FREE(g_dir_engine_info)
+
xmlFreeDoc(g_doc);
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) {
LOGE("[ERROR] Fail to make engine info file");
xmlFreeDoc(g_doc);
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
gus = gum_user_service_create_sync(TRUE);
if (!gus) {
LOGE("Failed to create gum user service");
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
LOGE("Failed to get gum user list");
g_object_unref(gus);
gus = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
while (iter != NULL) {
user = (GumUser*) iter->data;
g_object_get(G_OBJECT(user), "uid", &uid, NULL);
- if (NULL != home_dir) {
- free(home_dir);
- home_dir = NULL;
- }
+ G_FREE(home_dir)
+
g_object_get(G_OBJECT(user), "gid", &gid, NULL);
g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL);
g_object_get(G_OBJECT(user), "usertype", &gumut, NULL);
user_type = g_strdup(gum_user_type_to_string(gumut));
if (NULL == user_type) {
gum_user_service_list_free(users);
+ G_FREE(home_dir)
g_object_unref(gus);
gus = NULL;
return -1;
if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) {
LOGE("[ERROR] Fail to allocate memory");
- if (NULL != g_dir_config_base) {
- free(g_dir_config_base);
- g_dir_config_base = NULL;
- }
- if (NULL != g_dir_home) {
- free(g_dir_home);
- g_dir_home = NULL;
- }
- if (NULL != g_dir_engine_base) {
- free(g_dir_engine_base);
- g_dir_engine_base = NULL;
- }
- if (NULL != g_dir_engine_info) {
- free(g_dir_engine_info);
- g_dir_engine_info = NULL;
- }
+ FREE(g_dir_config_base)
+ FREE(g_dir_home)
+ FREE(g_dir_engine_base)
+ FREE(g_dir_engine_info)
gum_user_service_list_free(users);
g_object_unref(gus);
gus = NULL;
+ G_FREE(user_type)
+ G_FREE(home_dir)
return -1;
}
snprintf(g_dir_config_base, strlen(home_dir) + 14, "%s/share/.voice", home_dir);
LOGE("[ERROR] Fail to make engine info file");
}
- free(g_dir_config_base);
- g_dir_config_base = NULL;
- free(g_dir_home);
- g_dir_home = NULL;
- free(g_dir_engine_base);
- g_dir_engine_base = NULL;
- free(g_dir_engine_info);
- g_dir_engine_info = NULL;
-
- g_free(user_type);
- user_type = NULL;
- free(home_dir);
- home_dir = NULL;
-
- iter = g_list_next(iter);
- } else {
- iter = g_list_next(iter);
- }
+ FREE(g_dir_config_base)
+ FREE(g_dir_home)
+ FREE(g_dir_engine_base)
+ FREE(g_dir_engine_info)
- if (NULL != user_type) {
- g_free(user_type);
- user_type = NULL;
+ G_FREE(home_dir)
}
+
+ G_FREE(user_type)
+ iter = g_list_next(iter);
}
gum_user_service_list_free(users);
LOGE("[ERROR] Invalid uid");
g_object_unref(g_guser);
g_guser = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return 0;
} else {
LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
LOGE("[ERROR] No Engine Metadata");
g_object_unref(g_guser);
g_guser = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return 0;
}
xmlFreeDoc(g_doc);
g_object_unref(g_guser);
g_guser = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) {
LOGE("[ERROR] Fail to allocate memory");
- if (NULL != g_dir_config_base) {
- free(g_dir_config_base);
- g_dir_config_base = NULL;
- }
- if (NULL != g_dir_home) {
- free(g_dir_home);
- g_dir_home = NULL;
- }
- if (NULL != g_dir_engine_base) {
- free(g_dir_engine_base);
- g_dir_engine_base = NULL;
- }
- if (NULL != g_dir_engine_info) {
- free(g_dir_engine_info);
- g_dir_engine_info = NULL;
- }
+ FREE(g_dir_config_base)
+ FREE(g_dir_home)
+ FREE(g_dir_engine_base)
+ FREE(g_dir_engine_info)
xmlFreeDoc(g_doc);
g_object_unref(g_guser);
g_guser = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
g_object_unref(g_guser);
g_guser = NULL;
}
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
}
g_object_unref(g_guser);
g_guser = NULL;
}
- g_free(g_user_type);
+ G_FREE(g_user_type)
- if (NULL != g_dir_config_base) {
- free(g_dir_config_base);
- g_dir_config_base = NULL;
- }
- if (NULL != g_dir_home) {
- free(g_dir_home);
- g_dir_home = NULL;
- }
- if (NULL != g_dir_engine_base) {
- free(g_dir_engine_base);
- g_dir_engine_base = NULL;
- }
- if (NULL != g_dir_engine_info) {
- free(g_dir_engine_info);
- g_dir_engine_info = NULL;
- }
+ FREE(g_dir_config_base)
+ FREE(g_dir_home)
+ FREE(g_dir_engine_base)
+ FREE(g_dir_engine_info)
return 0;
}
LOGE("[ERROR] Fail to get target uid");
g_object_unref(g_guser);
g_guser = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
g_dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO);
if (NULL == g_dir_engine_info) {
LOGE("[ERROR] Fail to allocate memory");
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
gus = gum_user_service_create_sync(TRUE);
if (!gus) {
LOGE("Failed to create gum user service");
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
LOGE("Failed to get gum user list");
g_object_unref(gus);
gus = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
while (iter != NULL) {
user = (GumUser*) iter->data;
g_object_get(G_OBJECT(user), "uid", &uid, NULL);
- if (NULL != home_dir) {
- free(home_dir);
- home_dir = NULL;
- }
+ G_FREE(home_dir)
g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL);
g_object_get(G_OBJECT(user), "usertype", &gumut, NULL);
user_type = g_strdup(gum_user_type_to_string(gumut));
if (NULL == user_type) {
gum_user_service_list_free(users);
+ G_FREE(home_dir)
g_object_unref(gus);
gus = NULL;
return -1;
g_dir_engine_info = (char*)calloc(strlen(home_dir) + 34, sizeof(char));
if (NULL == g_dir_engine_info) {
gum_user_service_list_free(users);
+ G_FREE(home_dir)
g_object_unref(gus);
gus = NULL;
+ G_FREE(user_type)
return -1;
}
LOGE("[ERROR] Fail to remove engine info file");
}
- free(home_dir);
- home_dir = NULL;
-
- free(g_dir_engine_info);
- g_dir_engine_info = NULL;
-
- g_free(user_type);
-
- LOGD("Finish release memory");
- iter = g_list_next(iter);
- LOGD("Finish next iter");
- } else {
- iter = g_list_next(iter);
+ G_FREE(home_dir)
+ FREE(g_dir_engine_info)
}
+ G_FREE(user_type)
+
+ LOGD("Finish release memory");
+ iter = g_list_next(iter);
+ LOGD("Finish next iter");
}
gum_user_service_list_free(users);
LOGE("[ERROR] Invalid uid");
g_object_unref(g_guser);
g_guser = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
} else {
LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
LOGE("[ERROR] Fail to allocate memory");
g_object_unref(g_guser);
g_guser = NULL;
- g_free(g_user_type);
+ G_FREE(g_user_type)
return -1;
}
g_object_unref(g_guser);
g_guser = NULL;
}
- g_free(g_user_type);
+ G_FREE(g_user_type)
- if (NULL != g_dir_engine_info) {
- free(g_dir_engine_info);
- g_dir_engine_info = NULL;
- }
+ FREE(g_dir_engine_info)
LOGD("");
return 0;
#ifndef __TTS_H__
#define __TTS_H__
+
#include <tizen.h>
+
/**
* @file tts.h
*/
+
/**
* @addtogroup CAPI_UIX_TTS_MODULE
* @{
*/
+
#ifdef __cplusplus
extern "C" {
#endif
+
/**
* @brief Enumeration for error code.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum {
- TTS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- TTS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */
- TTS_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
- TTS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
- TTS_ERROR_OUT_OF_NETWORK = TIZEN_ERROR_NETWORK_DOWN, /**< Network is down */
- TTS_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from the daemon */
- TTS_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
- TTS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< TTS NOT supported */
- TTS_ERROR_INVALID_STATE = TIZEN_ERROR_TTS | 0x01, /**< Invalid state */
- TTS_ERROR_INVALID_VOICE = TIZEN_ERROR_TTS | 0x02, /**< Invalid voice */
- TTS_ERROR_ENGINE_NOT_FOUND = TIZEN_ERROR_TTS | 0x03, /**< No available engine */
- TTS_ERROR_OPERATION_FAILED = TIZEN_ERROR_TTS | 0x04, /**< Operation failed */
- TTS_ERROR_AUDIO_POLICY_BLOCKED = TIZEN_ERROR_TTS | 0x05, /**< Audio policy blocked */
- TTS_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_TTS | 0x06, /**< Not supported feature of current engine @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */
- TTS_ERROR_SERVICE_RESET = TIZEN_ERROR_TTS | 0x07 /**< Service reset @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */
+ TTS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ TTS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */
+ TTS_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
+ TTS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ TTS_ERROR_OUT_OF_NETWORK = TIZEN_ERROR_NETWORK_DOWN, /**< Network is down */
+ TTS_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from the daemon */
+ TTS_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ TTS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< TTS NOT supported */
+ TTS_ERROR_INVALID_STATE = TIZEN_ERROR_TTS | 0x01, /**< Invalid state */
+ TTS_ERROR_INVALID_VOICE = TIZEN_ERROR_TTS | 0x02, /**< Invalid voice */
+ TTS_ERROR_ENGINE_NOT_FOUND = TIZEN_ERROR_TTS | 0x03, /**< No available engine */
+ TTS_ERROR_OPERATION_FAILED = TIZEN_ERROR_TTS | 0x04, /**< Operation failed */
+ TTS_ERROR_AUDIO_POLICY_BLOCKED = TIZEN_ERROR_TTS | 0x05, /**< Audio policy blocked */
+ TTS_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_TTS | 0x06, /**< Not supported feature of current engine @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */
+ TTS_ERROR_SERVICE_RESET = TIZEN_ERROR_TTS | 0x07 /**< Service reset @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */
} tts_error_e;
+
/**
* @brief Enumeration for TTS mode.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum {
- TTS_MODE_DEFAULT = 0, /**< Default mode for normal application */
- TTS_MODE_NOTIFICATION = 1, /**< Notification mode */
- TTS_MODE_SCREEN_READER = 2 /**< Accessibiliity mode */
+ TTS_MODE_DEFAULT = 0, /**< Default mode for normal application */
+ TTS_MODE_NOTIFICATION = 1, /**< Notification mode */
+ TTS_MODE_SCREEN_READER = 2 /**< Accessibiliity mode */
} tts_mode_e;
+
/**
- * @brief Enumerations for state.
+ * @brief Enumeration for state.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum {
- TTS_STATE_CREATED = 0, /**< 'CREATED' state */
- TTS_STATE_READY = 1, /**< 'READY' state */
- TTS_STATE_PLAYING = 2, /**< 'PLAYING' state */
- TTS_STATE_PAUSED = 3 /**< 'PAUSED' state*/
+ TTS_STATE_CREATED = 0, /**< 'CREATED' state */
+ TTS_STATE_READY = 1, /**< 'READY' state */
+ TTS_STATE_PLAYING = 2, /**< 'PLAYING' state */
+ TTS_STATE_PAUSED = 3 /**< 'PAUSED' state*/
} tts_state_e;
+
/**
- * @brief Definitions for automatic speaking speed.
+ * @brief Definition for automatic speaking speed.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
#define TTS_SPEED_AUTO 0
+
/**
- * @brief Definitions for automatic voice type.
+ * @brief Definition for automatic voice type.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
#define TTS_VOICE_TYPE_AUTO 0
+
/**
- * @brief Definitions for male voice type.
+ * @brief Definition for male voice type.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
#define TTS_VOICE_TYPE_MALE 1
+
/**
- * @brief Definitions for female voice type.
+ * @brief Definition for female voice type.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
#define TTS_VOICE_TYPE_FEMALE 2
+
/**
- * @brief Definitions for child voice type.
+ * @brief Definition for child voice type.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
#define TTS_VOICE_TYPE_CHILD 3
+
/**
* @brief The TTS handle.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
/**
* @brief Called when the state of TTS is changed.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @details If the daemon must stop player because of changing engine and
- * the daemon must pause player because of other requests, this callback function is called.
- *
+ * the daemon must pause player because of other requests, this callback function is called.
* @param[in] tts The TTS handle
* @param[in] previous The previous state
* @param[in] current The current state
* @param[in] user_data The user data passed from the callback registration function
- *
* @pre An application registers this callback using tts_set_state_changed_cb() to detect changing state.
- *
* @see tts_set_state_changed_cb()
* @see tts_unset_state_changed_cb()
*/
typedef void (*tts_state_changed_cb)(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
+
/**
* @brief Called when utterance has started.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] utt_id The utterance ID passed from the add text function
* @param[in] user_data The user data passed from the callback registration function
- *
* @pre An application registers this callback using tts_set_utterance_started_cb() to detect utterance started.
- *
* @see tts_add_text()
* @see tts_set_utterance_started_cb()
* @see tts_unset_utterance_started_cb()
*/
typedef void (*tts_utterance_started_cb)(tts_h tts, int utt_id, void* user_data);
+
/**
* @brief Called when utterance is finished.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] utt_id The utterance ID passed from the add text function
* @param[in] user_data The user data passed from the callback registration function
- *
* @pre An application registers this callback using tts_set_utterance_completed_cb() to detect utterance completed.
- *
* @see tts_add_text()
* @see tts_set_utterance_completed_cb()
* @see tts_unset_utterance_completed_cb()
*/
typedef void (*tts_utterance_completed_cb)(tts_h tts, int utt_id, void *user_data);
+
/**
* @brief Called when an error occurs.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] utt_id The utterance ID passed from the add text function
* @param[in] reason The error code
* @param[in] user_data The user data passed from the callback registration function
- *
* @pre An application registers this callback using tts_set_error_cb() to detect error.
- *
* @see tts_play()
* @see tts_pause()
* @see tts_stop()
*/
typedef void (*tts_error_cb)(tts_h tts, int utt_id, tts_error_e reason, void* user_data);
+
/**
* @brief Called to retrieve the supported voice.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] language Language specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code (for example, "ko_KR" for Korean, "en_US" for American English)
* @param[in] voice_type A voice type (e.g. #TTS_VOICE_TYPE_MALE, #TTS_VOICE_TYPE_FEMALE)
* @param[in] user_data The user data passed from the foreach function
- *
- * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @return @c true to continue with the next iteration of the loop,
+ * @c false to break out of the loop
* @pre tts_foreach_supported_voices() will invoke this callback function.
- *
* @see tts_foreach_supported_voices()
*/
typedef bool(*tts_supported_voice_cb)(tts_h tts, const char* language, int voice_type, void* user_data);
+
/**
* @brief Called when the default voice is changed.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] previous_language The previous language
* @param[in] previous_voice_type The previous voice type
* @param[in] current_language The current language
* @param[in] current_voice_type The current voice type
* @param[in] user_data The user data passed from the callback registration function
- *
* @see tts_set_default_voice_changed_cb()
*/
typedef void (*tts_default_voice_changed_cb)(tts_h tts, const char* previous_language, int previous_voice_type,
const char* current_language, int current_voice_type, void* user_data);
+
+
/**
* @brief Called when the engine is changed.
* @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
- *
* @param[in] tts The TTS handle
- * @param[in] engine_id Engine id
+ * @param[in] engine_id Engine ID
* @param[in] language The default language specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code (for example, "ko_KR" for Korean, "en_US" for American English)
* @param[in] voice_type The default voice type
* @param[in] need_credential The necessity of credential
* @param[in] user_data The user data passed from the callback registration function
- *
* @see tts_set_engine_changed_cb()
*/
typedef void (*tts_engine_changed_cb)(tts_h tts, const char* engine_id, const char* language, int voice_type, bool need_credential, void* user_data);
/**
* @brief Creates a handle for TTS.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @remarks If the function succeeds, @a tts handle must be released with tts_destroy().
- *
* @param[out] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
- *
* @see tts_destroy()
*/
int tts_create(tts_h* tts);
+
/**
* @brief Destroys the handle and disconnects the daemon.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @see tts_create()
*/
int tts_destroy(tts_h tts);
+
/**
* @brief Sets the TTS mode.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] mode The mode
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_get_mode()
*/
int tts_set_mode(tts_h tts, tts_mode_e mode);
+
/**
* @brief Gets the TTS mode.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[out] mode The mode
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_set_mode()
*/
int tts_get_mode(tts_h tts, tts_mode_e* mode);
+
/**
* @brief Sets the app credential.
* @details Using this API, the application can set a credential.
- * The credential is a key to verify the authorization about using the engine.
- * If the application sets the credential, it will be able to use functions of the engine entirely.
+ * The credential is a key to verify the authorization about using the engine.
+ * If the application sets the credential, it will be able to use functions of the engine entirely.
* @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
- *
* @remarks The necessity of the credential depends on the engine. In case of the engine which is basically embedded in Tizen, the credential is not necessary so far.
- * However, if the user wants to apply the 3rd party's engine, the credential may be necessary. In that case, please follow the policy provided by the corresponding engine.
- *
+ * However, if the user wants to apply the 3rd party's engine, the credential may be necessary. In that case, please follow the policy provided by the corresponding engine.
* @param[in] tts The TTS handle
* @param[in] credential The app credential
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Success
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED or #TTS_STATE_READY.
- *
* @see tts_play()
*/
int tts_set_credential(tts_h tts, const char* credential);
+
/**
* @brief Connects the daemon asynchronously.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- * @post If this function is successful, the TTS state will be #TTS_STATE_READY. \n
- * If this function is failed, the error callback is called. (e.g. #TTS_ERROR_ENGINE_NOT_FOUND)
- *
+ * @post If this function is successful, the TTS state will be #TTS_STATE_READY.
+ * If this function is failed, the error callback is called. (e.g. #TTS_ERROR_ENGINE_NOT_FOUND)
* @see tts_unprepare()
*/
int tts_prepare(tts_h tts);
+
/**
* @brief Disconnects the daemon.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_READY.
* @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
- *
* @see tts_prepare()
*/
int tts_unprepare(tts_h tts);
+
/**
* @brief Retrieves all supported voices of the current engine using callback function.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] callback The callback function to invoke
* @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @post This function invokes tts_supported_voice_cb() repeatedly for getting voices.
- *
* @see tts_get_default_voice()
*/
int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, void* user_data);
+
/**
* @brief Gets the default voice set by the user.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @remarks If the function succeeds, @a language must be released with free().
- *
* @param[in] tts The TTS handle
* @param[out] language Language specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code (for example, "ko_KR" for Korean, "en_US" for American English)
* @param[out] voice_type The voice type
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @see tts_foreach_supported_voices()
*/
int tts_get_default_voice(tts_h tts, char** language, int* voice_type);
+
/**
* @brief Sets the private data to tts engine.
* @details The private data is the setting parameter for applying keys provided by the engine.
- * Using this API, the application can set the private data and use the corresponding key of the engine.
- * For example, if the engine provides 'girl's voice' as a voice type, the application can set the private data as the following. \n
- * int ret = tts_set_private_data(tts_h, "voice_type", "GIRL");
- *
+ * Using this API, the application can set the private data and use the corresponding key of the engine.
+ * For example, if the engine provides 'girl's voice' as a voice type, the application can set the private data as the following.
+ * int ret = tts_set_private_data(tts_h, "voice_type", "GIRL");
* @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
- *
* @remarks If the engine is replaced with the other engine, the key may be ignored.
- *
* @param[in] tts The TTS handle
* @param[in] key The field name of private data
* @param[in] data The data for set
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_READY.
- *
* @see tts_get_private_data()
*/
int tts_set_private_data(tts_h tts, const char* key, const char* data);
+
/**
* @brief Gets the private data from tts engine.
* @details The private data is the information provided by the engine.
- * Using this API, the application can get the private data which corresponds to the key from the engine.
+ * Using this API, the application can get the private data which corresponds to the key from the engine.
* @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
- *
* @remarks The @a data must be released using free() when it is no longer required.
- * If the engine is replaced with the other engine, the key may be ignored.
- *
+ * If the engine is replaced with the other engine, the key may be ignored.
* @param[in] tts The TTS handle
* @param[in] key The field name of private data
* @param[out] data The data field of private data
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_READY.
- *
* @see tts_set_private_data()
*/
int tts_get_private_data(tts_h tts, const char* key, char** data);
+
/**
* @brief Gets the maximum byte size for text.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[out] size The maximum byte size for text
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_READY.
- *
* @see tts_add_text()
*/
int tts_get_max_text_size(tts_h tts, unsigned int* size);
+
/**
* @brief Gets the current state of TTS.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[out] state The current state of TTS
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @see tts_play()
* @see tts_stop()
* @see tts_pause()
*/
int tts_get_state(tts_h tts, tts_state_e* state);
+
/**
* @brief Gets the speed range.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- * @param[out] min The minimun speed value
+ * @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
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_add_text()
*/
int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max);
+
/**
* @brief Gets the current error message.
* @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
- *
- * @remarks This function should be called from a tts error callback. Calling in any other context will result in an Operation failed error. \n
- * A successful call will allocate @a err_msg, which must be released by calling free() when it is no longer required.
- *
+ * @remarks This function should be called from a tts error callback. Calling in any other context will result in an Operation failed error.
+ * A successful call will allocate @a err_msg, which must be released by calling free() when it is no longer required.
* @param[in] tts The TTS handle
* @param[out] err_msg The current error message
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
- *
* @see tts_set_error_cb()
* @see tts_unset_error_cb()
*/
int tts_get_error_message(tts_h tts, char** err_msg);
+
/**
* @brief Adds a text to the queue.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @remarks Locale(e.g. setlocale()) MUST be set for utf8 text validation check.
- *
* @param[in] tts The TTS handle
* @param[in] text An input text based utf8
* @param[in] language The language selected from the tts_foreach_supported_voices() (e.g. 'NULL'(Automatic), 'en_US')
* @param[in] voice_type The voice type selected from the tts_foreach_supported_voices() (e.g. #TTS_VOICE_TYPE_AUTO, #TTS_VOICE_TYPE_FEMALE)
* @param[in] speed A speaking speed (e.g. #TTS_SPEED_AUTO or the value from tts_get_speed_range())
* @param[out] utt_id The utterance ID passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
* @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
- *
* @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
* @see tts_get_max_text_size()
* @see tts_set_credential()
*/
int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id);
+
/**
* @brief Starts synthesizing voice from the text and plays the synthesized audio data.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_OUT_OF_NETWORK Out of network
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
* @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
- *
* @pre The current state should be #TTS_STATE_READY or #TTS_STATE_PAUSED.
* @post If this function succeeds, the TTS state will be #TTS_STATE_PLAYING.
- *
* @see tts_add_text()
* @see tts_pause()
* @see tts_stop()
*/
int tts_play(tts_h tts);
+
/**
* @brief Stops playing the utterance and clears the queue.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The TTS state should be #TTS_STATE_READY or #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
* @post If this function succeeds, the TTS state will be #TTS_STATE_READY.
- * This function will remove all text via tts_add_text() and synthesized sound data.
- *
+ * This function will remove all text via tts_add_text() and synthesized sound data.
* @see tts_play()
* @see tts_pause()
*/
int tts_stop(tts_h tts);
+
/**
* @brief Pauses the currently playing utterance.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The TTS state should be #TTS_STATE_PLAYING.
* @post If this function succeeds, the TTS state will be #TTS_STATE_PAUSED.
- *
* @see tts_play()
* @see tts_stop()
* @see tts_error_cb()
*/
int tts_pause(tts_h tts);
+
/**
* @brief Registers a callback function to be called when the TTS state changes.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_state_changed_cb()
* @see tts_unset_state_changed_cb()
*/
int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data);
+
/**
* @brief Unregisters the callback function.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_set_state_changed_cb()
*/
int tts_unset_state_changed_cb(tts_h tts);
+
/**
* @brief Registers a callback function to detect utterance start.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_utterance_started_cb()
* @see tts_unset_utterance_started_cb()
*/
int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, void* user_data);
+
/**
* @brief Unregisters the callback function.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_set_utterance_started_cb()
*/
int tts_unset_utterance_started_cb(tts_h tts);
+
/**
* @brief Registers a callback function to detect utterance completion.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_utterance_completed_cb()
* @see tts_unset_utterance_completed_cb()
*/
int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callback, void* user_data);
+
/**
* @brief Unregisters the callback function.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_set_utterance_completed_cb()
*/
int tts_unset_utterance_completed_cb(tts_h tts);
+
/**
* @brief Registers a callback function to detect errors.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_error_cb()
* @see tts_unset_error_cb()
*/
int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data);
+
/**
* @brief Unregisters the callback function.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_set_error_cb()
*/
int tts_unset_error_cb(tts_h tts);
+
/**
* @brief Registers a callback function to detect default voice change.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_default_voice_changed_cb()
* @see tts_unset_default_voice_changed_cb()
*/
int tts_set_default_voice_changed_cb(tts_h tts, tts_default_voice_changed_cb callback, void* user_data);
+
/**
* @brief Unregisters the callback function.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_set_default_voice_changed_cb()
*/
int tts_unset_default_voice_changed_cb(tts_h tts);
+
/**
* @brief Registers a callback function to detect the engine change.
* @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
- *
* @param[in] tts The TTS handle
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_engine_changed_cb()
* @see tts_unset_engine_changed_cb()
*/
int tts_set_engine_changed_cb(tts_h tts, tts_engine_changed_cb callback, void* user_data);
+
/**
* @brief Unregisters the callback function.
* @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
- *
* @param[in] tts The TTS handle
- *
- * @return 0 on success, otherwise a negative error value
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #TTS_ERROR_NONE Successful
* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TTS_ERROR_INVALID_STATE Invalid state
* @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
- *
* @pre The state should be #TTS_STATE_CREATED.
- *
* @see tts_set_engine_changed_cb()
*/
int tts_unset_engine_changed_cb(tts_h tts);
}
#endif
+
/**
* @}@}
*/
+
#endif /* __TTS_H__ */
#ifndef __TTSE_H__
#define __TTSE_H__
+
#include <tizen.h>
+
/**
* @addtogroup CAPI_UIX_TTSE_MODULE
* @{
*/
+
#ifdef __cplusplus
extern "C" {
#endif
+
/**
-* @brief Enumerations for error codes.
+* @brief Enumeration 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_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.
+* @brief Enumeration 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_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.
+* @brief Enumeration 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_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.
+* @brief Definition for male voice type.
* @since_tizen 3.0
*/
#define TTSE_VOICE_TYPE_MALE 1
+
/**
-* @brief Definitions for female voice type.
+* @brief Definition for female voice type.
* @since_tizen 3.0
*/
#define TTSE_VOICE_TYPE_FEMALE 2
+
/**
-* @brief Definitions for child's voice type.
+* @brief Definition 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().
-*
+* @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.
+* followed by ISO 639-1 for the two-letter language code.
+* 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
-*
+* @return @c true to continue with the next iteration of the loop
+* @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
+* @return @c 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
+* NOTE that the engine may be terminated automatically.
+* When this callback function is invoked, the release of resources is necessary.
+* @return @c 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()'.
-*
-*
+* 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
+* @return @c 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.
+* followed by ISO 639-1 for the two-letter language code.
+* 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
+* @param[out] is_valid A variable for checking whether the corresponding voice is valid or not.
+* @c true to be valid,
+* @c false to be invalid
+* @return @c 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
+* @return @c 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
*/
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.
+* followed by ISO 639-1 for the two-letter language code.
+* 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
+* @return @c 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.
+* followed by ISO 639-1 for the two-letter language code.
+* 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
+* @return @c 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.
+* 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.
-*
+* 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. @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
+* @param[out] is_agreed A variable for checking whether the application agreed to use TTS engine or not.
+* @c true to agree,
+* @c false to disagree
+* @return @c 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
*/
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
+* @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.
-*
+* 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.
+* followed by ISO 639-1 for the two-letter language code.
+* 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
+* @return @c 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_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
+* @return @c 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.
-*
+* 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] 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
+* @return @c 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
+* @param[in] key The key field of private data
+* @param[in] data The data field of private data
+* @return @c 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
+* @param[out] key The key field of private data
+* @param[out] data The data field of private data
+* @return @c 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()
*/
* @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 */
+ 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_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_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_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_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_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
+* @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>
*/
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
+* @return @c 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
+* @return @c 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.
-*
+* 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
+* @return @c 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.
-*
+* 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
-*
+* @details The following error codes can be delivered.
+* #TTSE_ERROR_NONE,
+* #TTSE_ERROR_OUT_OF_MEMORY,
+* #TTSE_ERROR_IO_ERROR,
+* #TTSE_ERROR_INVALID_PARAMETER,
+* #TTSE_ERROR_NETWORK_DOWN,
+* #TTSE_ERROR_PERMISSION_DENIED,
+* #TTSE_ERROR_INVALID_STATE,
+* #TTSE_ERROR_INVALID_VOICE,
+* #TTSE_ERROR_OPERATION_FAILED,
+* #TTSE_ERROR_NOT_SUPPORTED_FEATURE,
+* #TTSE_ERROR_NOT_SUPPORTED.
* @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
+* @return @c 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
+* @return @c 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
+* @return @c 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__ */
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++) {
+ for (iter = g_app_list[index].m_wav_data.begin(); iter != g_app_list[index].m_wav_data.end(); ++iter) {
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++;
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++) {
+ for (iter = g_app_list[index].m_speak_data.begin(); iter != g_app_list[index].m_speak_data.end(); ++iter) {
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++;
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++) {
+ for (iter = g_app_list[index].m_used_voice.begin(); iter != g_app_list[index].m_used_voice.end(); ++iter) {
SLOG(LOG_DEBUG, tts_tag(), "[%dth] lang(%s), vctype(%d)", i + 1, iter->lang, iter->vctype);
i++;
}
/* Find voice */
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++) {
+ 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, tts_tag(), "[DATA] The voice is already registered (%s)(%d)", lang, type);
return 0;
used_voice.lang = strdup(lang);
used_voice.vctype = type;
- g_app_list[index].m_used_voice.insert(g_app_list[index].m_used_voice.end(), used_voice);
+ try {
+ iter = g_app_list[index].m_used_voice.insert(g_app_list[index].m_used_voice.end(), used_voice);
+ } catch (const std::bad_alloc&) {
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][ERROR] Fail to insert m_used_voice (bad_alloc)");
+ return -1;
+ }
+ SLOG(LOG_ERROR, tts_tag(), "[DATA] lang(%s), vctype(%d)", iter->lang, iter->vctype);
#ifdef DATA_DEBUG
__data_show_used_voice_list(index);
/* Find voice */
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++) {
+ for (iter = g_app_list[index].m_used_voice.begin(); iter != g_app_list[index].m_used_voice.end(); ++iter) {
if (NULL != callback) {
callback(iter->lang, iter->vctype);
}
if (NULL != iter->lang) {
free(iter->lang);
+ iter->lang = NULL;
}
}
/* mutex is locked */
pthread_mutex_lock(&g_speak_data_mutex);
- g_app_list[index].m_speak_data.insert(g_app_list[index].m_speak_data.end(), data);
+ std::list<speak_data_s*>::iterator iter;
+
+ try {
+ iter = g_app_list[index].m_speak_data.insert(g_app_list[index].m_speak_data.end(), data);
+ } catch (const std::bad_alloc&) {
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][ERROR] Fail to insert m_speak_data (bad_alloc)");
+ pthread_mutex_unlock(&g_speak_data_mutex);
+
+ return TTSD_ERROR_OUT_OF_MEMORY;
+ }
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), text(%s), lang(%s), vctype(%d), speed(%d)",
+ *iter, (*iter)->utt_id, (*iter)->text, (*iter)->lang, (*iter)->vctype, (*iter)->speed);
if (1 == data->utt_id)
g_app_list[index].utt_id_stopped = 0;
std::list<speak_data_s*>::iterator iter = g_app_list[index].m_speak_data.begin();
*data = *iter;
- g_app_list[index].m_speak_data.pop_front();
+ if (!g_app_list[index].m_speak_data.empty())
+ g_app_list[index].m_speak_data.pop_front();
#ifdef DATA_DEBUG
__data_show_text_list(index);
/* mutex is locked */
pthread_mutex_lock(&g_sound_data_mutex);
- g_app_list[index].m_wav_data.insert(g_app_list[index].m_wav_data.end(), data);
+ std::list<sound_data_s*>::iterator iter;
+
+ try {
+ iter = g_app_list[index].m_wav_data.insert(g_app_list[index].m_wav_data.end(), data);
+ } catch (const std::bad_alloc&) {
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][ERROR] Fail to insert m_sound_data (bad_alloc)");
+ pthread_mutex_unlock(&g_sound_data_mutex);
+
+ return TTSD_ERROR_OUT_OF_MEMORY;
+ }
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), data(%p)", *iter, (*iter)->utt_id, (*iter)->data);
#ifdef DATA_DEBUG
__data_show_sound_list(index);
std::list<sound_data_s*>::iterator iter = g_app_list[index].m_wav_data.begin();
*data = *iter;
- g_app_list[index].m_wav_data.pop_front();
+ if (!g_app_list[index].m_wav_data.empty())
+ g_app_list[index].m_wav_data.pop_front();
#ifdef DATA_DEBUG
__data_show_sound_list(index);
}
}
- /* mutex is locked */
- pthread_mutex_lock(&g_sound_data_mutex);
-
+ pthread_mutex_lock(&g_speak_data_mutex);
g_app_list[index].m_speak_data.clear();
- g_app_list[index].m_wav_data.clear();
+ pthread_mutex_unlock(&g_speak_data_mutex);
- /* mutex is unlocked */
+ pthread_mutex_lock(&g_sound_data_mutex);
+ g_app_list[index].m_wav_data.clear();
pthread_mutex_unlock(&g_sound_data_mutex);
return TTSD_ERROR_NONE;
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++) {
+ for (iter = g_app_list[index].m_wav_data.begin(); iter != g_app_list[index].m_wav_data.end(); ++iter) {
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++) {
+ 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, 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++;
int ttsd_dbus_open_connection()
{
+ SLOG(LOG_DEBUG, tts_tag(), "=== start dbus open connection");
DBusError err;
dbus_error_init(&err);
g_service_object = (char*)calloc(strlen(TTS_SR_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));
g_service_interface = (char*)calloc(strlen(TTS_SR_SERVER_SERVICE_INTERFACE) + 1, sizeof(char));
+ if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory");
+ __ttsd_dbus_service_free();
+ __ttsd_dbus_connection_free();
+ return -1;
+ }
+
snprintf(g_service_name, strlen(TTS_SR_SERVER_SERVICE_NAME) + 1, "%s", TTS_SR_SERVER_SERVICE_NAME);
snprintf(g_service_object, strlen(TTS_SR_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_SR_SERVER_SERVICE_OBJECT_PATH);
snprintf(g_service_interface, strlen(TTS_SR_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_SR_SERVER_SERVICE_INTERFACE);
g_service_object = (char*)calloc(strlen(TTS_NOTI_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));
g_service_interface = (char*)calloc(strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1, sizeof(char));
+ if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory");
+ __ttsd_dbus_service_free();
+ __ttsd_dbus_connection_free();
+ return -1;
+ }
+
snprintf(g_service_name, strlen(TTS_NOTI_SERVER_SERVICE_NAME) + 1, "%s", TTS_NOTI_SERVER_SERVICE_NAME);
snprintf(g_service_object, strlen(TTS_NOTI_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_NOTI_SERVER_SERVICE_OBJECT_PATH);
snprintf(g_service_interface, strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_NOTI_SERVER_SERVICE_INTERFACE);
g_service_object = (char*)calloc(strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));
g_service_interface = (char*)calloc(strlen(TTS_SERVER_SERVICE_INTERFACE) + 1, sizeof(char));
+ if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory");
+ __ttsd_dbus_service_free();
+ __ttsd_dbus_connection_free();
+ return -1;
+ }
+
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);
}
- if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) {
- SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory");
- __ttsd_dbus_service_free();
- __ttsd_dbus_connection_free();
- 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) {
return -1;
}
+ SLOG(LOG_DEBUG, tts_tag(), "===");
return 0;
}
int ttsd_dbus_close_connection()
{
+ SLOG(LOG_DEBUG, tts_tag(), "=== start dbus close connection");
DBusError err;
dbus_error_init(&err);
__ttsd_dbus_connection_free();
__ttsd_dbus_service_free();
+ SLOG(LOG_DEBUG, tts_tag(), "===");
+
return 0;
}
data = iter->data;
if (NULL != data) {
- if (NULL != data->lang) free(data->lang);
+ 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_next(iter);
}
- if (NULL != g_engine_info->default_lang) free(g_engine_info->default_lang);
+ if (NULL != g_engine_info->default_lang) {
+ free(g_engine_info->default_lang);
+ g_engine_info->default_lang = NULL;
+ }
g_engine_info->default_lang = strdup(language);
g_engine_info->default_vctype = vctype;
int temp_type;
if (true != ttsd_engine_select_valid_voice(lang, vctype, &temp_lang, &temp_type)) {
SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to select default voice");
- if (NULL != temp_lang) free(temp_lang);
+ if (NULL != temp_lang) {
+ free(temp_lang);
+ temp_lang = NULL;
+ }
return TTSD_ERROR_INVALID_VOICE;
} else {
SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Start synthesis : language(%s), type(%d), speed(%d), text(%s), credential(%s)",
data = iter->data;
if (NULL != data) {
- if (NULL != data->language) free(data->language);
+ if (NULL != data->language) {
+ free(data->language);
+ data->language = NULL;
+ }
free(data);
+ data = NULL;
}
voice_list = g_list_remove_link(voice_list, iter);
} player_s;
#define SOUND_BUFFER_LENGTH 2048
+#define FOCUS_SERVER_READY "/tmp/.sound_server_ready"
/** player init info */
static bool g_player_init = false;
usleep(10000);
if (NULL == g_playing_info) {
/* current playing uid is replaced */
- SLOG(LOG_DEBUG, tts_tag(), "[Player] Finish thread");
+ SLOG(LOG_INFO, tts_tag(), "[Player] Finish thread");
return;
} else if (0 < ttsd_data_get_sound_data_size(player->uid)) {
/* new audio data come */
- SLOG(LOG_DEBUG, tts_tag(), "[Player] Resume thread");
+ SLOG(LOG_INFO, tts_tag(), "[Player] Resume thread");
break;
}
}
+ SLOG(LOG_INFO, tts_tag(), "[Player] Finish to wait for new audio data come");
+
/* set volume policy as 40%, when resume play thread*/
__set_policy_for_playing(40);
SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
+
+ if (NULL != sound_data->data) {
+ free(sound_data->data);
+ sound_data->data = NULL;
+ }
+ free(sound_data);
+ sound_data = NULL;
return;
}
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, tts_tag(), "[Player] Start utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
+ SLOG(LOG_INFO, tts_tag(), "[Player] Start utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
}
/* Save last event to check utterance start */
SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
+ if (NULL != sound_data->data) {
+ free(sound_data->data);
+ sound_data->data = NULL;
+ }
+ free(sound_data);
+ sound_data = NULL;
return;
}
if (0 != ttsdc_send_utt_finish_message(pid, player->uid, sound_data->utt_id)) {
pid, player->uid, sound_data->utt_id);
}
}
- SLOG(LOG_DEBUG, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
+ SLOG(LOG_INFO, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
+ if (NULL != sound_data->data) {
+ free(sound_data->data);
+ sound_data->data = NULL;
+ }
+ free(sound_data);
+ sound_data = NULL;
continue;
}
}
SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to create audio out");
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
+
+ if (NULL != sound_data->data) {
+ free(sound_data->data);
+ sound_data->data = NULL;
+ }
+ free(sound_data);
+ sound_data = NULL;
+
return;
}
__set_policy_for_playing(40);
g_playing_info = NULL;
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
+
+ if (NULL != sound_data->data) {
+ free(sound_data->data);
+ sound_data->data = NULL;
+ }
+
+ free(sound_data);
+ sound_data = NULL;
+
return;
}
SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Prepare audio");
player->idx = idx;
g_audio_state = AUDIO_STATE_READY;
- SLOG(LOG_DEBUG, tts_tag(), "[Player] Stop player thread by pause");
+ SLOG(LOG_INFO, tts_tag(), "[Player] Stop player thread by pause");
/* Request prepare */
ret = audio_out_unprepare(g_audio_h);
SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
+ if (NULL != sound_data->data) {
+ free(sound_data->data);
+ sound_data->data = NULL;
+ }
+
+ free(sound_data);
+ sound_data = NULL;
return;
}
pid, player->uid, sound_data->utt_id);
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
+ if (NULL != sound_data->data) {
+ free(sound_data->data);
+ sound_data->data = NULL;
+ }
+
+ free(sound_data);
+ sound_data = NULL;
return;
}
- SLOG(LOG_DEBUG, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
+ SLOG(LOG_INFO, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
}
if (NULL != sound_data) {
ecore_thread_max_set(1);
+ int cnt = 0;
+ while (1) {
+ if (0 == access(FOCUS_SERVER_READY, F_OK)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Player SUCCESS] focus server is available");
+ break;
+ } else {
+ if (0 == cnt++ % 10)
+ SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] focus server is not available");
+ usleep(50000);
+ }
+ }
+
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, tts_tag(), "[Player ERROR] Fail to create stream info");
g_playing_info = current;
- SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] Active thread count : %d", ecore_thread_active_get());
+ SLOG(LOG_INFO, 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, tts_tag(), "[Player] Run thread");
+ SLOG(LOG_INFO, tts_tag(), "[Player] Run thread");
ecore_thread_run(__play_thread, __end_play_thread, NULL, NULL);
}
SLOG(LOG_DEBUG, tts_tag(), "[Player] ==========================");
}
- SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Stop player : uid(%d)", uid);
+ SLOG(LOG_INFO, tts_tag(), "[Player SUCCESS] Stop player : uid(%d)", uid);
return 0;
}
current->state = APP_STATE_PLAYING;
g_playing_info = current;
- SLOG(LOG_DEBUG, tts_tag(), "[Player] Run thread");
+ SLOG(LOG_INFO, tts_tag(), "[Player] Resume to run thread");
ecore_thread_run(__play_thread, __end_play_thread, NULL, NULL);
return 0;
/* Current language is not available */
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);
+ if (NULL != out_lang) {
+ free(out_lang);
+ out_lang = NULL;
+ }
break;
}
int temp_type;
if (true != ttsd_engine_select_valid_voice((const char*)lang, voice_type, &temp_lang, &temp_type)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to select valid voice");
- if (NULL != temp_lang) free(temp_lang);
+ if (NULL != temp_lang) {
+ free(temp_lang);
+ temp_lang = NULL;
+ }
return TTSD_ERROR_INVALID_VOICE;
}
speak_data = (speak_data_s*)calloc(1, sizeof(speak_data_s));
if (NULL == speak_data) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory");
- if (NULL != temp_lang) free(temp_lang);
+ if (NULL != temp_lang) {
+ free(temp_lang);
+ temp_lang = NULL;
+ }
return TTSD_ERROR_OPERATION_FAILED;
}
SLOG(LOG_INFO, tts_tag(), "[Server] Add queue, lang(%s), vctype(%d), speed(%d), uttid(%d), credential(%s)", lang, voice_type, speed, utt_id, credential);
/* 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)) {
+ int ret = -1;
+ ret = ttsd_data_add_speak_data(uid, speak_data);
+ if (0 != ret) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add speak data");
- if (NULL != temp_lang) free(temp_lang);
+ if (NULL != temp_lang) {
+ free(temp_lang);
+ temp_lang = NULL;
+ }
if (NULL != speak_data) {
if (NULL != speak_data->lang) free(speak_data->lang);
if (NULL != speak_data->text) free(speak_data->text);
speak_data = NULL;
}
- return TTSD_ERROR_OPERATION_FAILED;
+ return ret;
}
if (0 != ttsd_data_set_used_voice(uid, temp_lang, temp_type)) {
}
}
- if (NULL != temp_lang) free(temp_lang);
+ if (NULL != temp_lang) {
+ free(temp_lang);
+ temp_lang = NULL;
+ }
if (APP_STATE_PLAYING == state) {
/* check if engine use network */