Add sleep in EffectThread to avoid busy wait

Bug: 261129656
Test: Enable AIDL and run YTM on pixel phone
Change-Id: If7ea5324b8a884e8f07b6855b70cb33b4c7868e4
This commit is contained in:
Shunkai Yao
2023-03-09 02:24:00 +00:00
parent b862e6e20b
commit eae5c56fb4
2 changed files with 7 additions and 4 deletions

View File

@@ -34,13 +34,14 @@ EffectThread::~EffectThread() {
};
RetCode EffectThread::createThread(std::shared_ptr<EffectContext> context, const std::string& name,
const int priority) {
int priority, int sleepUs /* kSleepTimeUs */) {
if (mThread.joinable()) {
LOG(WARNING) << __func__ << " thread already created, no-op";
return RetCode::SUCCESS;
}
mName = name;
mPriority = priority;
mSleepTimeUs = sleepUs;
{
std::lock_guard lg(mThreadMutex);
mThreadContext = std::move(context);
@@ -134,7 +135,7 @@ void EffectThread::process_l() {
LOG(DEBUG) << __func__ << " done processing, effect consumed " << status.fmqConsumed
<< " produced " << status.fmqProduced;
} else {
// TODO: maybe add some sleep here to avoid busy waiting
usleep(mSleepTimeUs);
}
}