+ if (0 == access(TTS_CONFIG, F_OK)) {
+ int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+ if (0 > ret) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Save result : %d", ret);
+ } else {
+ static FILE* pFile;
+ pFile = fopen(TTS_CONFIG, "r");
+ int fd = -1;
+ if (NULL == pFile) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to open file %s", TTS_CONFIG);
+ } else {
+ fd = fileno(pFile);
+ fsync(fd);
+ fclose(pFile);
+ SLOG(LOG_INFO, TAG_TTSCONFIG, "[DEBUG] Success to fsync %s", TTS_CONFIG);
+ }
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[DEBUG] Success to save %s", TTS_CONFIG);
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to access to %s", TTS_CONFIG);
+ }
+
+ return 0;
+}
+
+int tts_parser_set_bg_volume_ratio(double value)
+{
+ xmlNodePtr cur = NULL;
+ cur = xmlDocGetRootElement(g_config_doc);
+ if (cur == NULL) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Empty document");
+ return -1;
+ }
+
+ if (xmlStrcmp(cur->name, (const xmlChar *) TTS_TAG_CONFIG_BASE_TAG)) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
+ return -1;
+ }
+
+ cur = cur->xmlChildrenNode;
+ if (cur == NULL) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Empty document");
+ return -1;
+ }
+
+ while (cur != NULL) {
+ if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_BACKGROUND_VOLUME_RATIO)) {
+ char temp[10];
+ memset(temp, '\0', 10);
+ snprintf(temp, 10, "%lf", value);
+ xmlNodeSetContent(cur, (const xmlChar *)temp);
+ break;
+ }
+
+ cur = cur->next;
+ }
+
+ if (0 == access(TTS_CONFIG, F_OK)) {
+ int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+ if (0 > ret) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Save result : %d", ret);
+ } else {
+ static FILE* pFile;
+ pFile = fopen(TTS_CONFIG, "r");
+ int fd = -1;
+ if (NULL == pFile) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to open file %s", TTS_CONFIG);
+ } else {
+ fd = fileno(pFile);
+ fsync(fd);
+ fclose(pFile);
+ SLOG(LOG_INFO, TAG_TTSCONFIG, "[DEBUG] Success to fsync %s", TTS_CONFIG);
+ }
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[DEBUG] Success to save %s", TTS_CONFIG);
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to access to %s", TTS_CONFIG);