/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
/* alloc engine info */
stt_engine_info_s* temp;
temp = (stt_engine_info_s*)calloc(1, sizeof(stt_engine_info_s));
+ if (NULL == temp) {
+ xmlFreeDoc(doc);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory");
+ return -1;
+ }
temp->name = NULL;
temp->uuid = NULL;
if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_NAME)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- // SLOG(LOG_DEBUG, stt_tag(), "Engine name : %s", (char *)key);
+ /* SLOG(LOG_DEBUG, stt_tag(), "Engine name : %s", (char *)key); */
if (NULL != temp->name) free(temp->name);
temp->name = strdup((char*)key);
xmlFree(key);
} else {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_NAME);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_NAME);
}
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_ID)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- // SLOG(LOG_DEBUG, stt_tag(), "Engine uuid : %s", (char *)key);
+ /* SLOG(LOG_DEBUG, stt_tag(), "Engine uuid : %s", (char *)key); */
if (NULL != temp->uuid) free(temp->uuid);
temp->uuid = strdup((char*)key);
xmlFree(key);
} else {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_ID);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_ID);
}
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_SETTING)) {
key = xmlNodeGetContent(cur);
lang_node = cur->xmlChildrenNode;
while (lang_node != NULL) {
- if (0 == xmlStrcmp(lang_node->name, (const xmlChar *)STT_TAG_ENGINE_LANGUAGE)){
+ if (0 == xmlStrcmp(lang_node->name, (const xmlChar *)STT_TAG_ENGINE_LANGUAGE)) {
key = xmlNodeGetContent(lang_node);
if (NULL != key) {
- // SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key);
+ /* SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key); */
temp_lang = strdup((char*)key);
temp->languages = g_slist_append(temp->languages, temp_lang);
xmlFree(key);
} else {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_LANGUAGE);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_LANGUAGE);
}
}
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_SILENCE_SUPPORT)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- //SLOG(LOG_DEBUG, stt_tag(), "silence-detection-support : %s", (char *)key);
+ /*SLOG(LOG_DEBUG, stt_tag(), "silence-detection-support : %s", (char *)key); */
if (0 == xmlStrcmp(key, (const xmlChar *)"true"))
temp->support_silence_detection = true;
else
temp->support_silence_detection = false;
-
+
xmlFree(key);
} else {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_SILENCE_SUPPORT);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_SILENCE_SUPPORT);
}
} else {
if (NULL == temp->name || NULL == temp->uuid) {
/* Invalid engine */
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Invalid engine : %s", path);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] Invalid engine : %s", path);
stt_parser_free_engine_info(temp);
return -1;
}
int i ;
char *temp_lang;
- for (i = 0;i < count ;i++) {
+ for (i = 0; i < count ; i++) {
temp_lang = g_slist_nth_data(engine_info->languages, 0);
if (NULL != temp_lang) {
if (NULL != temp_lang)
free(temp_lang);
- }
+ }
}
if (NULL != engine_info) free(engine_info);
- return 0;
+ return 0;
}
int stt_parser_print_engine_info(stt_engine_info_s* engine_info)
return -1;
SLOG(LOG_DEBUG, stt_tag(), "== get engine info ==");
- SECURE_SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name);
- SECURE_SLOG(LOG_DEBUG, stt_tag(), " id : %s", engine_info->uuid);
- if (NULL != engine_info->setting) SECURE_SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting);
+ SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name);
+ SLOG(LOG_DEBUG, stt_tag(), " id : %s", engine_info->uuid);
+ if (NULL != engine_info->setting) SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting);
SLOG(LOG_DEBUG, stt_tag(), " languages");
GSList *iter = NULL;
/* Get a first item */
iter = g_slist_nth(engine_info->languages, 0);
- int i = 1;
+ int i = 1;
while (NULL != iter) {
/*Get handle data from list*/
lang = iter->data;
- SECURE_SLOG(LOG_DEBUG, stt_tag(), " [%dth] %s", i, lang);
+ SLOG(LOG_DEBUG, stt_tag(), " [%dth] %s", i, lang);
/*Get next item*/
iter = g_slist_next(iter);
} else {
SLOG(LOG_ERROR, stt_tag(), " language is NONE");
}
- SECURE_SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", engine_info->support_silence_detection ? "true" : "false");
+ SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", engine_info->support_silence_detection ? "true" : "false");
SLOG(LOG_DEBUG, stt_tag(), "=====================");
return 0;
if (doc == NULL) {
doc = xmlParseFile(STT_DEFAULT_CONFIG);
if (doc == NULL) {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_DEFAULT_CONFIG);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_DEFAULT_CONFIG);
return -1;
}
is_default_open = true;
}
if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
xmlFreeDoc(doc);
return -1;
}
/* alloc engine info */
stt_config_s* temp;
temp = (stt_config_s*)calloc(1, sizeof(stt_config_s));
+ if (NULL == temp) {
+ xmlFreeDoc(doc);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory");
+ return -1;
+ }
temp->engine_id = NULL;
temp->setting = NULL;
if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_ID)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- //SLOG(LOG_DEBUG, stt_tag(), "Engine id : %s", (char *)key);
+ /*SLOG(LOG_DEBUG, stt_tag(), "Engine id : %s", (char *)key); */
if (NULL != temp->engine_id) free(temp->engine_id);
temp->engine_id = strdup((char*)key);
xmlFree(key);
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_SETTING)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- //SECURE_SLOG(LOG_DEBUG, stt_tag(), "Setting path : %s", (char *)key);
+ /*SLOG(LOG_DEBUG, stt_tag(), "Setting path : %s", (char *)key); */
if (NULL != temp->setting) free(temp->setting);
temp->setting = strdup((char*)key);
xmlFree(key);
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_AUTO_LANGUAGE)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- //SECURE_SLOG(LOG_DEBUG, stt_tag(), "Auto language : %s", (char *)key);
+ /*SLOG(LOG_DEBUG, stt_tag(), "Auto language : %s", (char *)key); */
if (0 == xmlStrcmp(key, (const xmlChar *)"on")) {
temp->auto_lang = true;
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_LANGUAGE)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- //SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key);
+ /*SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key); */
if (NULL != temp->language) free(temp->language);
temp->language = strdup((char*)key);
xmlFree(key);
} else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) {
key = xmlNodeGetContent(cur);
if (NULL != key) {
- //SLOG(LOG_DEBUG, stt_tag(), "silence-detection : %s", (char *)key);
+ /*SLOG(LOG_DEBUG, stt_tag(), "silence-detection : %s", (char *)key); */
if (0 == xmlStrcmp(key, (const xmlChar *)"on"))
temp->silence_detection = true;
}
if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
return -1;
}
if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) {
if (true == silence)
xmlNodeSetContent(cur, (const xmlChar *)"on");
- else
+ else
xmlNodeSetContent(cur, (const xmlChar *)"off");
}
}
if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
return -1;
}
while (cur != NULL) {
if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_LANGUAGE)) {
xmlNodeSetContent(cur, (const xmlChar *)language);
- }
+ }
cur = cur->next;
}
}
if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
return -1;
}
if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) {
if (true == value)
xmlNodeSetContent(cur, (const xmlChar *)"on");
- else
+ else
xmlNodeSetContent(cur, (const xmlChar *)"off");
- }
+ }
cur = cur->next;
}
doc = xmlParseFile(STT_CONFIG);
if (doc == NULL) {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_CONFIG);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_CONFIG);
return -1;
}
}
if (xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_BASE_TAG) || xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_BASE_TAG)) {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
xmlFreeDoc(doc);
return -1;
}
key_new = xmlNodeGetContent(cur_new);
if (NULL != key_new) {
if (0 != xmlStrcmp(key_old, key_new)) {
- SECURE_SLOG(LOG_DEBUG, stt_tag(), "Old engine id(%s), New engine(%s)", (char*)key_old, (char*)key_new);
+ SLOG(LOG_DEBUG, stt_tag(), "Old engine id(%s), New engine(%s)", (char*)key_old, (char*)key_new);
if (NULL != *engine) free(*engine);
*engine = strdup((char*)key_new);
}
key_new = xmlNodeGetContent(cur_new);
if (NULL != key_new) {
if (0 != xmlStrcmp(key_old, key_new)) {
- SECURE_SLOG(LOG_DEBUG, stt_tag(), "Old language(%s), New language(%s)", (char*)key_old, (char*)key_new);
+ SLOG(LOG_DEBUG, stt_tag(), "Old language(%s), New language(%s)", (char*)key_old, (char*)key_new);
if (NULL != *language) free(*language);
*language = strdup((char*)key_new);
}
key_new = xmlNodeGetContent(cur_new);
if (NULL != key_new) {
if (0 != xmlStrcmp(key_old, key_new)) {
- SECURE_SLOG(LOG_DEBUG, stt_tag(), "Old silence(%s), New silence(%s)", (char*)key_old, (char*)key_new);
+ SLOG(LOG_DEBUG, stt_tag(), "Old silence(%s), New silence(%s)", (char*)key_old, (char*)key_new);
if (0 == xmlStrcmp(key_new, (const xmlChar*)"on")) {
*silence = 1;
} else {
*silence = 0;
}
}
-
+
xmlFree(key_new);
}
xmlFree(key_old);
cur_new = cur_new->next;
cur_old = cur_old->next;
}
-
+
xmlFreeDoc(g_config_doc);
g_config_doc = doc;
}
if (-1 == remove(STT_TIME_INFO_PATH)) {
- SECURE_SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH);
+ SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH);
}
xmlDocPtr doc = NULL;
doc = xmlNewDoc((const xmlChar*)"1.0");
if (doc == NULL) {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make new doc");
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make new doc");
return -1;
}
iter = g_slist_nth(time_list, 0);
while (NULL != iter) {
data = iter->data;
-
+
+ if (NULL == data) {
+ SLOG(LOG_DEBUG, stt_tag(), "data is NULL");
+ continue;
+ }
+
xmlNodePtr temp_node = NULL;
- SLOG(LOG_DEBUG, stt_tag(), "[%d] i(%d) t(%s) s(%d) e(%d)",
+ SLOG(LOG_DEBUG, stt_tag(), "[%d] i(%d) t(%s) s(%d) e(%d)",
data->index, data->event, data->text, data->start_time, data->end_time);
-
+
temp_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_TEXT);
xmlNodeSetContent(temp_node, (const xmlChar*)data->text);
xmlAddChild(inode, temp_node);
-
+
temp_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_START);
snprintf(temp_str, 256, "%ld", data->start_time);
xmlNodeSetContent(temp_node, (const xmlChar*)temp_str);
SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_COUNT);
return -1;
}
-
+
SLOG(LOG_DEBUG, stt_tag(), "Count : %s", (char *)key);
/* Get time count */
time_node = cur->xmlChildrenNode;
int i = 0;
- for (i = 0;i < count;i++) {
+ for (i = 0; i < count; i++) {
/* text */
time_node = time_node->next;
temp_info->text = strdup((char*)key);
xmlFree(key);
} else {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_TEXT);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_TEXT);
free(temp_info);
break;
}
temp_info->start_time = atoi((char*)key);
xmlFree(key);
} else {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_START);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_START);
if (NULL != temp_info->text) free(temp_info->text);
free(temp_info);
break;
}
}
-
+
/* text */
time_node = time_node->next;
time_node = time_node->next;
temp_info->end_time = atoi((char*)key);
xmlFree(key);
} else {
- SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_END);
+ SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_END);
if (NULL != temp_info->text) free(temp_info->text);
free(temp_info);
break;
int stt_parser_clear_time_info()
{
if (-1 == remove(STT_TIME_INFO_PATH)) {
- SECURE_SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH);
+ /* SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH); */
}
return 0;