From: wn.jang Date: Fri, 29 Dec 2023 05:43:59 +0000 (+0900) Subject: Fix race condition when player thread is terminated X-Git-Tag: accepted/tizen/unified/20240207.171607~5^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=77edd68e56b106a29c4c07b509ca663930dd8abc;p=platform%2Fcore%2Fuifw%2Ftts.git Fix race condition when player thread is terminated Change-Id: I1db88e6f4f308e59eb1ff6122733e17361d36a7b --- diff --git a/server/PlayerThread.cpp b/server/PlayerThread.cpp index cbaa095..ce7ccda 100644 --- a/server/PlayerThread.cpp +++ b/server/PlayerThread.cpp @@ -48,10 +48,11 @@ PlayerThread::~PlayerThread() mPlayerAvailable = false; mPlayUtterance = nullptr; + mThreadCond.notify_all(); + tryToStopPlayer(); SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Thread is stopped or waiting"); - mThreadCond.notify_all(); mPlayerThread.join(); SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Finish thread"); } @@ -134,6 +135,7 @@ void PlayerThread::runPlayer() SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Wait playing"); if (isThreadStopped()) { mThreadCond.wait(lock); + usleep(10000); } while (false == isThreadStopped()) { @@ -142,6 +144,7 @@ void PlayerThread::runPlayer() mPlayUtterance(this, uid); } + SLOG(LOG_INFO, tts_tag(), "[PlayerThread] notify stopCheckCond"); mStopCheckCond.notify_all(); } }