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/7.0/unified/20240111.114549~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e03f403127bec584d2bc61d0ed519eacd80ad12;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 b7c385b5..2726418e 100644 --- a/server/PlayerThread.cpp +++ b/server/PlayerThread.cpp @@ -47,10 +47,11 @@ PlayerThread::~PlayerThread() __playerAvailable = false; __playUtterance = nullptr; + __threadCond.notify_all(); + tryToStopPlayer(); SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Thread is stopped or waiting"); - __threadCond.notify_all(); __playerThread.join(); SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Finish thread"); } @@ -133,6 +134,7 @@ void PlayerThread::runPlayer() SLOG(LOG_INFO, tts_tag(), "[PlayerThread] Wait playing"); if (isThreadStopped()) { __threadCond.wait(lock); + usleep(10000); } while (false == isThreadStopped()) { @@ -141,6 +143,7 @@ void PlayerThread::runPlayer() __playUtterance(this, uid); } + SLOG(LOG_INFO, tts_tag(), "[PlayerThread] notify stopCheckCond"); __stopCheckCond.notify_all(); } }