if (IN_CLOSE_WRITE == event.mask) {
/* check config changed state */
- char* engine = NULL;
char* setting = NULL;
char* lang = NULL;
bool auto_voice = config_info.auto_voice;
int pitch = -1;
double bg_volume_ratio = -1;
- if (0 != tts_parser_find_config_changed(&engine, &setting, &auto_voice, &lang, &voice_type, &speech_rate, &pitch, &bg_volume_ratio))
+ if (0 != tts_parser_find_config_changed(&setting, &auto_voice, &lang, &voice_type, &speech_rate, &pitch, &bg_volume_ratio))
return ECORE_CALLBACK_PASS_ON;
- /* engine changed */
- if (NULL != engine || NULL != setting) {
- if (NULL != engine) {
- memset(g_engine_id, '\0', sizeof(g_engine_id));
- config_info.engine_id = g_engine_id;
- strncpy(config_info.engine_id, engine, sizeof(g_engine_id) - 1);
- free(engine);
- }
+ /* config of engine updating */
+ memset(g_engine_id, '\0', sizeof(g_engine_id));
+ config_info.engine_id = g_engine_id;
- if (NULL != setting) {
- memset(g_setting, '\0', sizeof(g_setting));
- config_info.setting = g_setting;
- strncpy(config_info.setting, setting, sizeof(g_setting) - 1);
- free(setting);
- }
+ char* engine_id = vconf_get_str(TTS_ENGINE_DB_DEFAULT);
+ if (engine_id) {
+ SLOG(LOG_DEBUG, TAG_TTSCONFIG, "Set default engine id(%s)", engine_id);
+ strncpy(config_info.engine_id, engine_id, sizeof(g_engine_id) - 1);
- SLOG(LOG_ERROR, TAG_TTSCONFIG, "[INFO] Engine change(%s)", config_info.engine_id);
+ free(engine_id);
+ engine_id = NULL;
+ }
- /* Call all callbacks of client*/
- invoke_engine_changed_event(config_info.engine_id, config_info.setting, config_info.language, config_info.type, config_info.auto_voice, config_info.credential);
+ /* engine setting changed */
+ if (NULL != setting) {
+ memset(g_setting, '\0', sizeof(g_setting));
+ config_info.setting = g_setting;
+ strncpy(config_info.setting, setting, sizeof(g_setting) - 1);
+ free(setting);
}
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[INFO] Engine setting change(%s)", config_info.engine_id);
+
+ /* Call all callbacks of client*/
+ invoke_engine_changed_event(config_info.engine_id, config_info.setting, config_info.language, config_info.type, config_info.auto_voice, config_info.credential);
+
if (auto_voice != config_info.auto_voice) {
config_info.auto_voice = auto_voice;
}
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[INFO] New engine id : %s", engine);
- ret = __tts_set_buxtonkey(engine);
- if (0 != ret) {
- close(fd);
- SLOG(LOG_ERROR, TAG_TTSCONFIG, "[DEBUG] set_buxtonkey Fail!!");
- return ret;
+
+ char* engine_id = vconf_get_str(TTS_ENGINE_DB_DEFAULT);
+ if (0 != strncmp(engine, engine_id, strlen(engine_id) + 1)) {
+ SLOG(LOG_INFO, TAG_TTSCONFIG, "vconf engine id(%s) is different from input engine id(%s)", engine, engine_id);
+ ret = __tts_set_buxtonkey(engine);
+ if (0 != ret) {
+ SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] set_buxtonkey Fail!!");
+ return ret;
+ }
}
tts_engine_info_s *engine_info = __get_engine_info(engine);
while (cur != NULL) {
if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_ENGINE_ID)) {
- if (is_default_open) {
- char* engine_id = vconf_get_str(TTS_ENGINE_DB_DEFAULT);
- if (engine_id) {
- SLOG(LOG_DEBUG, TAG_TTSCONFIG, "Set default engine id(%s)", engine_id);
- strncpy(temp->engine_id, engine_id, sizeof(engine_id) - 1);
- xmlNodeSetContent(cur, (const xmlChar *)engine_id);
-
- free(engine_id);
- engine_id = NULL;
-
- cur = cur->next;
- continue;
- }
- }
+ char* engine_id = vconf_get_str(TTS_ENGINE_DB_DEFAULT);
+ if (engine_id) {
+ SLOG(LOG_DEBUG, TAG_TTSCONFIG, "Set default engine id(%s)", engine_id);
+ strncpy(temp->engine_id, engine_id, sizeof(g_engine_id) - 1);
+ xmlNodeSetContent(cur, (const xmlChar *)engine_id);
- xmlChar *key = xmlNodeGetContent(cur);
- if (NULL != key) {
- strncpy(temp->engine_id, (char*)key, sizeof(g_engine_id) - 1);
- xmlFree(key);
- key = NULL;
+ free(engine_id);
+ engine_id = NULL;
+
+ cur = cur->next;
+ continue;
} else {
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] engine id is NULL");
}
return 0;
}
-int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voice, char** language, int* voice_type,
+int tts_parser_find_config_changed(char**setting, bool* auto_voice, char** language, int* voice_type,
int* speech_rate, int* pitch, double* bg_volume_ratio)
{
- if (NULL == engine || NULL == setting || NULL == language || NULL == voice_type || NULL == speech_rate) {
+ if (NULL == setting || NULL == language || NULL == voice_type || NULL == speech_rate) {
SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Input parameter is NULL");
return -1;
}
}
while (cur_new != NULL && cur_old != NULL) {
- if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_ENGINE_ID)) {
- if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_ENGINE_ID)) {
- xmlChar *key_old = xmlNodeGetContent(cur_old);
- if (NULL != key_old) {
- xmlChar *key_new = xmlNodeGetContent(cur_new);
- if (NULL != key_new) {
- if (0 != xmlStrcmp(key_old, key_new)) {
- SLOG(LOG_ERROR, TAG_TTSCONFIG, "Old engine id(%s), New engine(%s)",
- (char*)key_old, (char*)key_new);
- 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, TAG_TTSCONFIG, "[ERROR] old config and new config are different");
- }
- } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_ENGINE_SETTING)) {
+ if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_ENGINE_SETTING)) {
if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_ENGINE_SETTING)) {
xmlChar *key_old = xmlNodeGetContent(cur_old);
if (NULL != key_old) {
int tts_parser_set_bg_volume_ratio(double value);
-int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voice, char** language, int* voice_type,
+int tts_parser_find_config_changed(char**setting, bool* auto_voice, char** language, int* voice_type,
int* speech_rate, int* pitch, double* bg_volume_ratio);
int tts_parser_copy_xml(const char* original, const char* destination);
SLOG(LOG_ERROR, tts_tag(), "[Server WARNING] Fail to initialize config.");
}
+ char *engine_id_by_config;
+ int ret = ttsd_config_get_default_engine(&engine_id_by_config);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get default engine, ret(%d)", ret);
+ }
+
+ char* engine_id_by_vconf = vconf_get_str(TTS_ENGINE_DB_DEFAULT);
+ if (0 != strncmp(engine_id_by_config, engine_id_by_vconf, strlen(engine_id_by_vconf) + 1)) {
+ ret = ttsd_config_set_default_engine(engine_id_by_vconf);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set default engine, ret(%d)", ret);
+ }
+ }
+
if (TTSD_ERROR_NONE != ttsd_state_initialize(__state_changed_cb)) {
SLOG(LOG_ERROR, tts_tag(), "[Server WARNING] Fail to initialize state.");
}