Merge "Fix to check whether it is possible to access to files" into tizen
authorsooyeon.kim <sooyeon.kim@samsung.com>
Tue, 23 Jan 2018 05:41:50 +0000 (05:41 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Tue, 23 Jan 2018 05:41:50 +0000 (05:41 +0000)
common/tts_config_mgr.c
common/tts_config_parser.c
common/tts_config_parser.h
server/ttsd_data.cpp
server/ttsd_main.h
server/ttsd_player.c

index 21ccd8a..1522950 100644 (file)
@@ -495,9 +495,11 @@ Eina_Bool tts_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handl
                        free(lang);
                        lang = NULL;
                }
-       } else if (IN_IGNORED == event.mask) {
-               SLOG(LOG_ERROR, tts_tag(), "[ERROR] IN_IGNORED event");
+       } else if (IN_DELETE_SELF == event.mask) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] IN_DELETE_SELF event");
+
                tts_parser_unload_config(g_config_info);
+               tts_parser_reset();
                tts_parser_load_config(&g_config_info);
        } else {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Undefined event (0x%x)", event.mask);
@@ -521,7 +523,7 @@ int __tts_config_mgr_register_config_event()
        }
        g_config_fd_noti = fd;
 
-       wd = inotify_add_watch(fd, TTS_CONFIG, IN_CLOSE_WRITE);
+       wd = inotify_add_watch(fd, TTS_CONFIG, IN_CLOSE_WRITE|IN_DELETE_SELF);
        g_config_wd_noti = wd;
 
        g_config_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ,
index ee9e5f0..443e2dd 100644 (file)
@@ -596,6 +596,8 @@ int tts_parser_copy_xml(const char* original, const char* destination)
        int ret = xmlSaveFile(destination, doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", destination);
        }
 
        /* Set mode */
@@ -663,6 +665,8 @@ int tts_parser_set_engine(const char* engine_id, const char* setting, const char
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -696,7 +700,7 @@ int tts_parser_set_voice(const char* language, int type)
        while (cur != NULL) {
                if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_LANGUAGE)) {
                        xmlNodeSetContent(cur, (const xmlChar *)language);
-               } 
+               }
 
                if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_VOICE_TYPE)) {
                        switch (type) {
@@ -716,6 +720,8 @@ int tts_parser_set_voice(const char* language, int type)
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -759,6 +765,8 @@ int tts_parser_set_auto_voice(bool value)
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -802,6 +810,8 @@ int tts_parser_set_speech_rate(int value)
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -834,7 +844,7 @@ int tts_parser_set_pitch(int value)
                        snprintf(temp, 10, "%d", value);
                        xmlNodeSetContent(cur, (const xmlChar *)temp);
                        break;
-               } 
+               }
 
                cur = cur->next;
        }
@@ -842,6 +852,8 @@ int tts_parser_set_pitch(int value)
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -1087,3 +1099,26 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic
 
        return 0;
 }
+
+int tts_parser_reset()
+{
+       SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Reset g_config_doc as %s", TTS_DEFAULT_CONFIG);
+
+       if (NULL != g_config_doc) {
+               xmlFreeDoc(g_config_doc);
+               g_config_doc = NULL;
+       }
+
+       g_config_doc = xmlParseFile(TTS_DEFAULT_CONFIG);
+       if (NULL == g_config_doc) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse %s", TTS_DEFAULT_CONFIG);
+               return -1;
+       }
+
+       int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+       if (0 > ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to save %s", TTS_CONFIG);
+       }
+
+       return 0;
+}
index 87ba839..ad736b8 100644 (file)
@@ -82,6 +82,8 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic
 
 int tts_parser_copy_xml(const char* original, const char* destination);
 
+int tts_parser_reset();
+
 #ifdef __cplusplus
 }
 #endif
index 5626e21..6c9e7f1 100644 (file)
@@ -411,7 +411,7 @@ int ttsd_data_add_sound_data(int uid, sound_data_s* data)
 
                return TTSD_ERROR_OUT_OF_MEMORY;
        }
-       SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), data(%p)", *iter, (*iter)->utt_id, (*iter)->data);
+       SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), data(%p) data size(%d), type(%d)", *iter, (*iter)->utt_id, (*iter)->data, (*iter)->data_size, (*iter)->audio_type);
 
 #ifdef DATA_DEBUG
        __data_show_sound_list(index);
index 41b7389..306e799 100644 (file)
@@ -33,7 +33,6 @@ extern "C" {
 #endif
 
 /* for debug message */
-#define DATA_DEBUG
 #define ENGINE_AGENT_DEBUG
 
 typedef enum {
index 54d1ef6..1b862e7 100644 (file)
@@ -351,7 +351,9 @@ int ttsd_player_check_current_playback_focus(bool *is_current_interrupt)
 
                ret = sound_manager_get_current_playback_focus(&reason, &sound_behavior, &extra_info);
 
-               if (SOUND_MANAGER_ERROR_NONE == ret && NULL != extra_info) {
+               SLOG(LOG_DEBUG, tts_tag(), "[Player] current playback focus: extra_info(%s), reason(%d), sound_behavior(%d)", extra_info, reason, sound_behavior, extra_info);
+
+               if (SOUND_MANAGER_ERROR_NONE == ret && NULL != extra_info && 0 < strlen(extra_info)) {
                        if (SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION == reason && 0 == strncmp(extra_info, "TTSD_MODE_INTERRUPT", strlen(extra_info))) {
                                SLOG(LOG_DEBUG, tts_tag(), "[Player] The current focus in Interrupt. Cannot play the requested sound data");
                                *is_current_interrupt = true;
@@ -767,6 +769,7 @@ int ttsd_player_init()
        ret = sound_manager_add_focus_state_watch_cb(SOUND_STREAM_FOCUS_FOR_PLAYBACK, __player_focus_state_watch_cb, NULL, &g_focus_watch_id);
        if (SOUND_MANAGER_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to add sound focus watch callback");
+               sound_manager_destroy_stream_information(g_stream_info_h);
                return -1;
        } else {
                SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Add sound focus watch callback");
@@ -775,8 +778,11 @@ int ttsd_player_init()
        ecore_thread_max_set(1);
 
        ret = __create_audio_out(TTSE_AUDIO_TYPE_RAW_S16, 16000);
-       if (0 != ret)
+       if (0 != ret) {
+               sound_manager_destroy_stream_information(g_stream_info_h);
+               sound_manager_remove_focus_state_watch_cb(g_focus_watch_id);
                return -1;
+       }
 
        g_player_init = true;