SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] IN_DELETE_SELF event");
tts_parser_unload_config();
+ tts_parser_cleanup_xml();
tts_parser_reset();
- tts_parser_load_config();
+ tts_parser_initialize_xml();
+ if (0 != tts_parser_load_config()) {
+ tts_parser_cleanup_xml();
+ }
} else {
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Undefined event (0x%x)", event.mask);
}
SLOG(LOG_INFO, TAG_TTSCONFIG, "Client type : %d", client_type);
g_client_type |= client_type;
+ tts_parser_initialize_xml();
+
if (0 != __tts_config_mgr_get_engine_info()) {
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to get engine info");
release_config_client(uid);
__tts_config_release_engine();
+ tts_parser_cleanup_xml();
return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
}
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to parse configure information");
release_config_client(uid);
__tts_config_release_engine();
+ tts_parser_cleanup_xml();
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
tts_config_s config_info;
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to get configure information");
release_config_client(uid);
__tts_config_release_engine();
+ tts_parser_unload_config();
+ tts_parser_cleanup_xml();
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
release_config_client(uid);
__tts_config_release_engine();
tts_parser_unload_config();
+ tts_parser_cleanup_xml();
return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
}
release_config_client(uid);
__tts_config_release_engine();
tts_parser_unload_config();
+ tts_parser_cleanup_xml();
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
release_config_client(uid);
__tts_config_release_engine();
tts_parser_unload_config();
+ tts_parser_cleanup_xml();
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
} else {
release_config_client(uid);
__tts_config_release_engine();
tts_parser_unload_config();
+ tts_parser_cleanup_xml();
return TTS_CONFIG_ERROR_OPERATION_FAILED;
}
__tts_config_release_engine();
tts_parser_unload_config();
+ tts_parser_cleanup_xml();
__tts_config_mgr_unregister_engine_config_updated_event();
static tts_config_s* g_config_info = NULL;
static pthread_mutex_t g_config_info_mutex = PTHREAD_MUTEX_INITIALIZER;
+static bool is_libxml_initialized = false;
+
+void tts_parser_initialize_xml(void) {
+ if (!is_libxml_initialized) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[DEBUG] Initialize xmlParser");
+ xmlInitParser();
+ is_libxml_initialized = true;
+ }
+}
+
+void tts_parser_cleanup_xml(void) {
+ if (is_libxml_initialized) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[DEBUG] Cleanup xmlParser");
+ xmlCleanupParser();
+ is_libxml_initialized = false;
+ }
+}
int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info)
{
xmlNodePtr cur = NULL;
bool is_default_open = false;
- /* For Thread safety */
- xmlInitParser();
-
if (0 != access(TTS_CONFIG, F_OK)) {
doc = xmlParseFile(TTS_DEFAULT_CONFIG);
if (doc == NULL) {
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to parse file error : %s", TTS_DEFAULT_CONFIG);
- xmlCleanupParser();
return -1;
}
is_default_open = true;
doc = xmlParseFile(TTS_DEFAULT_CONFIG);
if (NULL == doc) {
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to parse file error : %s", TTS_DEFAULT_CONFIG);
- xmlCleanupParser();
return -1;
}
is_default_open = true;
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Empty document(%p)", doc);
xmlFreeDoc(doc);
doc = NULL;
- xmlCleanupParser();
return -1;
}
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] The wrong type, root node is NOT %s. doc(%p)", TTS_TAG_CONFIG_BASE_TAG, doc);
xmlFreeDoc(doc);
doc = NULL;
- xmlCleanupParser();
return -1;
}
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Empty document(%p)", doc);
xmlFreeDoc(doc);
doc = NULL;
- xmlCleanupParser();
return -1;
}
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Out of memory(%p)", doc);
xmlFreeDoc(doc);
doc = NULL;
- xmlCleanupParser();
return -1;
}
g_config_info = NULL;
}
pthread_mutex_unlock(&g_config_info_mutex);
-
- xmlCleanupParser();
return 0;
}