Visualizer: Fix race condition in setCaptureCallBack

Visualizer:setCaptureCallBack needs to make a local
copy of the CaptureThread pointer before temporarily
releasing mCaptureLock. Otherwise, mCaptureThread
can be released in the meantime from Visualizer::release

Bug: 149375271
Test: use EffectsTest app with "Multithreaded Use"
      for the Visualizer test. Repeat releasing the effect
      while capture via callback is active.
Change-Id: Iaea62a0e2f7e7a996c1554b9ed89efb67fbdfc11
This commit is contained in:
Mikhail Naganov
2020-03-12 17:55:29 -07:00
parent 365caf6f04
commit 61c109cc7c

View File

@@ -120,8 +120,9 @@ status_t Visualizer::setCaptureCallBack(capture_cbk_t cbk, void* user, uint32_t
}
if (mCaptureThread != 0) {
sp<CaptureThread> t = mCaptureThread;
mCaptureLock.unlock();
mCaptureThread->requestExitAndWait();
t->requestExitAndWait();
mCaptureLock.lock();
}