Add logs to check list_insert 78/117578/5
authorsooyeon.kim <sooyeon.kim@samsung.com>
Mon, 6 Mar 2017 12:42:35 +0000 (21:42 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Mon, 6 Mar 2017 13:36:42 +0000 (22:36 +0900)
Change-Id: I389ce6418925e4fe089b111d26302d8de2e7643a
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
server/ttsd_data.cpp
server/ttsd_server.c

index 9432adc..3af4855 100644 (file)
@@ -251,7 +251,13 @@ int ttsd_data_set_used_voice(int uid, const char* lang, int type)
        used_voice.lang = strdup(lang);
        used_voice.vctype = type;
 
-       g_app_list[index].m_used_voice.insert(g_app_list[index].m_used_voice.end(), used_voice);
+       try {
+               iter = g_app_list[index].m_used_voice.insert(g_app_list[index].m_used_voice.end(), used_voice);
+       } catch (const std::bad_alloc&) {
+               SLOG(LOG_ERROR, tts_tag(), "[DATA][ERROR] Fail to insert m_used_voice (bad_alloc)");
+               return -1;
+       }
+       SLOG(LOG_ERROR, tts_tag(), "[DATA] lang(%s), vctype(%d)", iter->lang, iter->vctype);
 
 #ifdef DATA_DEBUG
        __data_show_used_voice_list(index);
@@ -310,7 +316,18 @@ int ttsd_data_add_speak_data(int uid, speak_data_s* data)
        /* mutex is locked */
        pthread_mutex_lock(&g_speak_data_mutex);
 
-       g_app_list[index].m_speak_data.insert(g_app_list[index].m_speak_data.end(), data);
+       std::list<speak_data_s*>::iterator iter;
+
+       try {
+               iter = g_app_list[index].m_speak_data.insert(g_app_list[index].m_speak_data.end(), data);
+       } catch (const std::bad_alloc&) {
+               SLOG(LOG_ERROR, tts_tag(), "[DATA][ERROR] Fail to insert m_speak_data (bad_alloc)");
+               pthread_mutex_unlock(&g_speak_data_mutex);
+
+               return TTSD_ERROR_OUT_OF_MEMORY;
+       }
+       SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), text(%s), lang(%s), vctype(%d), speed(%d)", 
+                       *iter, (*iter)->utt_id, (*iter)->text, (*iter)->lang, (*iter)->vctype, (*iter)->speed);
 
        if (1 == data->utt_id)
                g_app_list[index].utt_id_stopped = 0;
@@ -374,7 +391,17 @@ int ttsd_data_add_sound_data(int uid, sound_data_s* data)
        /* mutex is locked */
        pthread_mutex_lock(&g_sound_data_mutex);
 
-       g_app_list[index].m_wav_data.insert(g_app_list[index].m_wav_data.end(), data);
+       std::list<sound_data_s*>::iterator iter;
+
+       try {
+               iter = g_app_list[index].m_wav_data.insert(g_app_list[index].m_wav_data.end(), data);
+       } catch (const std::bad_alloc&) {
+               SLOG(LOG_ERROR, tts_tag(), "[DATA][ERROR] Fail to insert m_sound_data (bad_alloc)");
+               pthread_mutex_unlock(&g_sound_data_mutex);
+
+               return TTSD_ERROR_OUT_OF_MEMORY;
+       }
+       SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), data(%p)", *iter, (*iter)->utt_id, (*iter)->data);
 
 #ifdef DATA_DEBUG
        __data_show_sound_list(index);
index 4cbdd25..1e016e5 100644 (file)
@@ -746,7 +746,9 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
        SLOG(LOG_INFO, tts_tag(), "[Server] Add queue, lang(%s), vctype(%d), speed(%d), uttid(%d), credential(%s)", lang, voice_type, speed, utt_id, credential);
 
        /* if state is APP_STATE_READY , APP_STATE_PAUSED , only need to add speak data to queue*/
-       if (0 != ttsd_data_add_speak_data(uid, speak_data)) {
+       int ret = -1;
+       ret = ttsd_data_add_speak_data(uid, speak_data);
+       if (0 != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add speak data");
                if (NULL != temp_lang) {
                        free(temp_lang);
@@ -763,7 +765,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
                        speak_data = NULL;
                }
 
-               return TTSD_ERROR_OPERATION_FAILED;
+               return ret;
        }
 
        if (0 != ttsd_data_set_used_voice(uid, temp_lang, temp_type)) {