Apply audio stream policy and add null checker 16/84316/2 accepted/tizen/common/20160818.144554 accepted/tizen/ivi/20160818.232034 accepted/tizen/mobile/20160818.232027 accepted/tizen/tv/20160818.232030 accepted/tizen/wearable/20160818.232021 submit/tizen/20160818.064057
authorKwangyoun Kim <ky85.kim@samsung.com>
Thu, 18 Aug 2016 04:45:12 +0000 (13:45 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Thu, 18 Aug 2016 06:22:50 +0000 (15:22 +0900)
Change-Id: Id81b421df77fb57a24e6f8befea445acd12b4b1e
Signed-off-by: Kwangyoun Kim <ky85.kim@samsung.com>
client/tts.c
common/tts_config_parser.c
common/tts_defs.h
server/ttsd_player.c
server/ttse.c

index 4065997..21f9f89 100644 (file)
@@ -958,7 +958,7 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty
                                SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry add text : %s", __tts_get_error_code(ret));
                                usleep(10000);
                                count++;
-                               if (TTS_RETRY_COUNT == count) {
+                               if (TTS_RETRY_MIN_COUNT == count) {
                                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
                                        break;
                                }
index d74de97..9de67eb 100644 (file)
@@ -61,6 +61,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info
 
        doc = xmlParseFile(path);
        if (doc == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse xml file");
                return -1;
        }
 
@@ -68,12 +69,14 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info
        if (cur == NULL) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
                xmlFreeDoc(doc);
+               doc = NULL;
                return -1;
        }
 
        if (xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_BASE_TAG)) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT 'tts-engine'");
                xmlFreeDoc(doc);
+               doc = NULL;
                return -1;
        }
 
@@ -81,6 +84,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info
        if (cur == NULL) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
                xmlFreeDoc(doc);
+               doc = NULL;
                return -1;
        }
 
@@ -154,6 +158,9 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info
                                                xmlFree(attr);
                                        } else {
                                                SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE_TYPE);
+                                               free(temp_voice);
+                                               temp_voice = NULL;
+                                               continue;
                                        }
 
                                        key = xmlNodeGetContent(voice_node);
@@ -166,6 +173,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info
                                                SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE);
                                                if (NULL != temp_voice) {
                                                        free(temp_voice);
+                                                       temp_voice = NULL;
                                                }
                                        }
                                }
@@ -178,6 +186,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info
                                        temp->pitch_support = true;
                                }
                                xmlFree(key);
+                               key = NULL;
                        } else {
                                SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_PITCH_SUPPORT);
                        }
@@ -186,6 +195,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info
        }
 
        xmlFreeDoc(doc);
+       doc = NULL;
 
        if (NULL == temp->name || NULL == temp->uuid) {
                /* Invalid engine */
@@ -282,6 +292,9 @@ int tts_parser_load_config(tts_config_s** config_info)
        xmlChar *key;
        bool is_default_open = false;
 
+       /* For Thread safety */
+       xmlInitParser();
+
        if (0 != access(TTS_CONFIG, F_OK)) {
                doc = xmlParseFile(TTS_DEFAULT_CONFIG);
                if (doc == NULL) {
@@ -311,12 +324,14 @@ int tts_parser_load_config(tts_config_s** config_info)
        if (cur == NULL) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
                xmlFreeDoc(doc);
+               doc = NULL;
                return -1;
        }
 
        if (xmlStrcmp(cur->name, (const xmlChar *) TTS_TAG_CONFIG_BASE_TAG)) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
                xmlFreeDoc(doc);
+               doc = NULL;
                return -1;
        }
 
@@ -324,6 +339,7 @@ int tts_parser_load_config(tts_config_s** config_info)
        if (cur == NULL) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
                xmlFreeDoc(doc);
+               doc = NULL;
                return -1;
        }
 
@@ -453,7 +469,10 @@ int tts_parser_load_config(tts_config_s** config_info)
 
 int tts_parser_unload_config(tts_config_s* config_info)
 {
-       if (NULL != g_config_doc)       xmlFreeDoc(g_config_doc);
+       if (NULL != g_config_doc) {
+               xmlFreeDoc(g_config_doc);
+               g_config_doc = NULL;
+       }
        if (NULL != config_info) {
                if (NULL != config_info->engine_id)     free(config_info->engine_id);
                if (NULL != config_info->setting)       free(config_info->setting);
@@ -767,6 +786,7 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic
        if (cur_new == NULL || cur_old == NULL) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
                xmlFreeDoc(doc);
+               doc = NULL;
                return -1;
        }
 
@@ -774,6 +794,7 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic
        xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_BASE_TAG)) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
                xmlFreeDoc(doc);
+               doc = NULL;
                return -1;
        }
 
@@ -782,6 +803,7 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic
        if (cur_new == NULL || cur_old == NULL) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
                xmlFreeDoc(doc);
+               doc = NULL;
                return -1;
        }
 
@@ -934,8 +956,11 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic
                cur_new = cur_new->next;
                cur_old = cur_old->next;
        }
-       
-       xmlFreeDoc(g_config_doc);
+
+       if (NULL != g_config_doc) {
+               xmlFreeDoc(g_config_doc);
+               g_config_doc = NULL;
+       }
        g_config_doc = doc;
 
        return 0;
index c49a75a..7d7981f 100644 (file)
@@ -87,6 +87,7 @@ extern "C" {
 #define TTS_BASE_LANGUAGE              "en_US"
 
 #define TTS_RETRY_COUNT                5
+#define TTS_RETRY_MIN_COUNT    2
 
 #define TTS_SPEED_MIN          1
 #define TTS_SPEED_NORMAL       8
index 8a6dec4..6c21cbb 100644 (file)
@@ -211,10 +211,10 @@ static void __set_policy_for_playing(int volume)
                if (SOUND_MANAGER_ERROR_NONE != ret) {
                        SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to acquire focus");
                }
-               ret = audio_out_set_stream_info(g_audio_h, g_stream_info_h);
-               if (AUDIO_IO_ERROR_NONE != ret) {
-                       SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to set stream info");
-               }
+       }
+       ret = audio_out_set_stream_info(g_audio_h, g_stream_info_h);
+       if (AUDIO_IO_ERROR_NONE != ret) {
+               SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to set stream info");
        }
 
        return;
index f18c724..358d38a 100755 (executable)
@@ -180,6 +180,11 @@ int ttse_send_error(ttse_error_e error, const char* msg)
 
 int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func)
 {
+       if (NULL == callback_func) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
+               return TTSE_ERROR_INVALID_PARAMETER;
+       }
+
        int ret = ttsd_set_private_data_set_cb(callback_func);
 
        if (0 != ret) {
@@ -191,6 +196,11 @@ int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func)
 
 int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_func)
 {
+       if (NULL == callback_func) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
+               return TTSE_ERROR_INVALID_PARAMETER;
+       }
+
        int ret = ttsd_set_private_data_requested_cb(callback_func);
 
        if (0 != ret) {