From 74bc43bdc2d39b7369eaade445613920f288c3ab Mon Sep 17 00:00:00 2001 From: Hongguang Date: Thu, 4 Nov 2021 16:55:53 -0700 Subject: [PATCH] Notify FilterCallbackScheduler to wake up it while stopping. Bug: 183057734 Test: atest android.media.tv.tuner.cts Change-Id: I2b9d45fa7df3f2490893cc24d98c0e0baaaf0c2c --- tv/tuner/aidl/default/Filter.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tv/tuner/aidl/default/Filter.cpp b/tv/tuner/aidl/default/Filter.cpp index 345a984356..0a350571c2 100644 --- a/tv/tuner/aidl/default/Filter.cpp +++ b/tv/tuner/aidl/default/Filter.cpp @@ -88,7 +88,11 @@ void FilterCallbackScheduler::start() { } void FilterCallbackScheduler::stop() { - mIsRunning = false; + { + std::unique_lock lock(mLock); + mIsRunning = false; + mCv.notify_all(); + } if (mCallbackThread.joinable()) { mCallbackThread.join(); } @@ -113,6 +117,10 @@ void FilterCallbackScheduler::threadLoopOnce() { // okay to send data. mCv.wait(lock); } + if (!mIsRunning) { + lock.unlock(); + return; + } // condition_variable wait locks mutex on timeout / notify if (!mCallbackBuffer.empty()) {