From: Suyeon Hwang Date: Thu, 8 Jul 2021 09:59:46 +0000 (+0900) Subject: Clear player data after play thread is stopped X-Git-Tag: accepted/tizen/unified/20210716.131354~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fdf72f9b4165a39d2d1e2aaf5856aba1ce538bf;p=platform%2Fcore%2Fuifw%2Ftts.git Clear player data after play thread is stopped Previous code clears player data before reset the g_playing_info. If play thread still play some text, race condition of player data(ex. pasued_data) may occur. This patch changes the order of function call that 'ttsd_player_clear()' is invoked after play thread is stopped. By this change, player data is safe to access from other thread. Change-Id: Ia768cf76a876956a591974f9bc7871dcbdffe1c0 Signed-off-by: Suyeon Hwang --- diff --git a/server/ttsd_player.c b/server/ttsd_player.c index ebbb5ef..1872414 100644 --- a/server/ttsd_player.c +++ b/server/ttsd_player.c @@ -1370,12 +1370,6 @@ int ttsd_player_play(int uid) int ttsd_player_stop(int uid) { pthread_mutex_lock(&g_player_control_mutex); - int ret = ttsd_player_clear(uid); - if (0 != ret) { - SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to stop player, ret(%d)", ret); - pthread_mutex_unlock(&g_player_control_mutex); - return ret; - } /* check whether uid is current playing or not */ if (NULL != g_playing_info) { @@ -1393,6 +1387,14 @@ int ttsd_player_stop(int uid) SLOG(LOG_ERROR, tts_tag(), "[Player] Active thread count : %d", ecore_thread_active_get()); SLOG(LOG_DEBUG, tts_tag(), "[Player] @@@@@"); } + + int ret = ttsd_player_clear(uid); + if (0 != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to stop player, ret(%d)", ret); + pthread_mutex_unlock(&g_play_thread_mutex); + pthread_mutex_unlock(&g_player_control_mutex); + return ret; + } pthread_mutex_unlock(&g_play_thread_mutex); SLOG(LOG_INFO, tts_tag(), "[Player SUCCESS] Stop player : uid(%d)", uid);