Loading audio/aidl/default/EffectThread.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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); } } Loading audio/aidl/default/include/effect-impl/EffectThread.h +4 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ class EffectThread { // called by effect implementation. RetCode createThread(std::shared_ptr<EffectContext> context, const std::string& name, const int priority = ANDROID_PRIORITY_URGENT_AUDIO); int priority = ANDROID_PRIORITY_URGENT_AUDIO, int sleepUs = kSleepTimeUs); RetCode destroyThread(); RetCode startThread(); RetCode stopThread(); Loading Loading @@ -72,7 +72,8 @@ class EffectThread { virtual void process_l() REQUIRES(mThreadMutex); private: const int kMaxTaskNameLen = 15; static constexpr int kMaxTaskNameLen = 15; static constexpr int kSleepTimeUs = 2000; // in micro-second std::mutex mThreadMutex; std::condition_variable mCv; bool mExit GUARDED_BY(mThreadMutex) = false; Loading @@ -80,6 +81,7 @@ class EffectThread { std::shared_ptr<EffectContext> mThreadContext GUARDED_BY(mThreadMutex); std::thread mThread; int mPriority; int mSleepTimeUs = kSleepTimeUs; // sleep time in micro-second std::string mName; RetCode handleStartStop(bool stop); Loading Loading
audio/aidl/default/EffectThread.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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); } } Loading
audio/aidl/default/include/effect-impl/EffectThread.h +4 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ class EffectThread { // called by effect implementation. RetCode createThread(std::shared_ptr<EffectContext> context, const std::string& name, const int priority = ANDROID_PRIORITY_URGENT_AUDIO); int priority = ANDROID_PRIORITY_URGENT_AUDIO, int sleepUs = kSleepTimeUs); RetCode destroyThread(); RetCode startThread(); RetCode stopThread(); Loading Loading @@ -72,7 +72,8 @@ class EffectThread { virtual void process_l() REQUIRES(mThreadMutex); private: const int kMaxTaskNameLen = 15; static constexpr int kMaxTaskNameLen = 15; static constexpr int kSleepTimeUs = 2000; // in micro-second std::mutex mThreadMutex; std::condition_variable mCv; bool mExit GUARDED_BY(mThreadMutex) = false; Loading @@ -80,6 +81,7 @@ class EffectThread { std::shared_ptr<EffectContext> mThreadContext GUARDED_BY(mThreadMutex); std::thread mThread; int mPriority; int mSleepTimeUs = kSleepTimeUs; // sleep time in micro-second std::string mName; RetCode handleStartStop(bool stop); Loading