Add logic to check that list is empty 60/110460/1
authorWonnam Jang <wn.jang@samsung.com>
Mon, 16 Jan 2017 13:09:04 +0000 (22:09 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Mon, 16 Jan 2017 13:09:53 +0000 (22:09 +0900)
Change-Id: If7e679e11d4d7d08d2bb0194117c0362bab60459
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
server/ttsd_data.cpp

index 186565a..5ba44aa 100644 (file)
@@ -345,7 +345,8 @@ int ttsd_data_get_speak_data(int uid, speak_data_s** data)
 
        std::list<speak_data_s*>::iterator iter = g_app_list[index].m_speak_data.begin();
        *data = *iter;
-       g_app_list[index].m_speak_data.pop_front();
+       if (!g_app_list[index].m_speak_data.empty())
+               g_app_list[index].m_speak_data.pop_front();
 
 #ifdef DATA_DEBUG
        __data_show_text_list(index);
@@ -408,7 +409,8 @@ int ttsd_data_get_sound_data(int uid, sound_data_s** data)
 
        std::list<sound_data_s*>::iterator iter = g_app_list[index].m_wav_data.begin();
        *data = *iter;
-       g_app_list[index].m_wav_data.pop_front();
+       if (!g_app_list[index].m_wav_data.empty())
+               g_app_list[index].m_wav_data.pop_front();
 
 #ifdef DATA_DEBUG
        __data_show_sound_list(index);
@@ -503,13 +505,12 @@ int ttsd_data_clear_data(int uid)
                }
        }
 
-       /* mutex is locked */
-       pthread_mutex_lock(&g_sound_data_mutex);
-
+       pthread_mutex_lock(&g_speak_data_mutex);
        g_app_list[index].m_speak_data.clear();
-       g_app_list[index].m_wav_data.clear();
+       pthread_mutex_unlock(&g_speak_data_mutex);
 
-       /* mutex is unlocked */
+       pthread_mutex_lock(&g_sound_data_mutex);
+       g_app_list[index].m_wav_data.clear();
        pthread_mutex_unlock(&g_sound_data_mutex);
 
        return TTSD_ERROR_NONE;