Add logs to check list_insert
[platform/core/uifw/tts.git] / server / ttsd_data.cpp
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);