if (NULL != language) SLOG(LOG_DEBUG, TAG_TTSC, "Language(%s)", language);
SLOG(LOG_DEBUG, TAG_TTSC, "Voice type(%d), Auto voice(%s), Credential(%s)", voice_type, auto_voice ? "on" : "off", need_credential ? "need" : "no need");
+ /* When the default engine is changed, please unload the old engine and load the new one. */
+ int ret = -1;
+
+ if (TTS_STATE_PLAYING == client->current_state || TTS_STATE_PAUSED == client->current_state) {
+ ret = tts_stop(tts);
+ if (0 != ret) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] TTS client stopping...");
+ }
+ ret = tts_unprepare(tts);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to unprepare for setting a new engine... (%d)", ret);
+ }
+ ret = tts_prepare(tts);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+ }
+ } else if (TTS_STATE_READY == client->current_state) {
+ ret = tts_unprepare(tts);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to unprepare for setting a new engine... (%d)", ret);
+ }
+ ret = tts_prepare(tts);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+ }
+ }
+
/* call callback function */
if (NULL != client->engine_changed_cb) {
client->engine_changed_cb(tts, engine_id, language, voice_type, need_credential, client->engine_changed_user_data);
return -1;
}
+ /* Save in /etc/skel/share/ */
+ g_dir_config_base = strdup(TTS_GLOBAL_CONFIG_BASE);
+ g_dir_home = strdup(TTS_GLOBAL_HOME);
+ g_dir_engine_base = strdup(TTS_GLOBAL_ENGINE_BASE);
+ g_dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO);
+
+ 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;
+ }
+ xmlFreeDoc(g_doc);
+ g_free(g_user_type);
+ return -1;
+ }
+
+ if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid)) {
+ LOGE("[ERROR] Fail to make engine info file");
+ xmlFreeDoc(g_doc);
+ g_free(g_user_type);
+ return -1;
+ }
+
/* Get user data by using libgum */
GumUserService *gus = NULL;
/* global directory */
LOGD("[DEBUG] usertype: %s", g_user_type);
+ /* Remove files in /etc/skel/share/ */
+ 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);
+ return -1;
+ }
+
+ if (0 != __remove_engine_info_xml(pkgid, g_user_type, g_uid)) {
+ LOGE("[ERROR] Fail to remove engine info file");
+ }
+
/* Get user data by using libgum */
GumUserService *gus = NULL;