From 4d61ad17cb75ed34a4a26786a71062bedc9dc2c7 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 16 Jan 2017 22:09:04 +0900 Subject: [PATCH] Add logic to check that list is empty Change-Id: If7e679e11d4d7d08d2bb0194117c0362bab60459 Signed-off-by: Wonnam Jang --- server/ttsd_data.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/ttsd_data.cpp b/server/ttsd_data.cpp index 186565a..5ba44aa 100644 --- a/server/ttsd_data.cpp +++ b/server/ttsd_data.cpp @@ -345,7 +345,8 @@ int ttsd_data_get_speak_data(int uid, speak_data_s** data) std::list::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::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; -- 2.7.4