Visualizer: Fix deadlock on close

Visualizer gets stuck in mCaptureThread::requestExitAndWait due to a
deadlock between mCaptureThread::mRunning and mCaptureLock.

Temporarily release mCaptureLock upon mCaptureThread::requestExitAndWait.

Test: Clarity -> Response, rapidly toggle visualizer enable, disable
Bug: 135326776
authored-by: Weiyin Jiang <wjiang@codeaurora.org>
Change-Id: If32431c4d7b271b7ea61168cb1a5a42f3a1cd66e
This commit is contained in:
Aniket Kumar Lata
2019-07-03 10:44:47 -07:00
committed by Marco Nelissen
parent 70694b005d
commit b2f11e6cc4

View File

@@ -78,10 +78,13 @@ status_t Visualizer::setEnabled(bool enabled)
if (t != 0) {
if (enabled) {
if (t->exitPending()) {
mCaptureLock.unlock();
if (t->requestExitAndWait() == WOULD_BLOCK) {
mCaptureLock.lock();
ALOGE("Visualizer::enable() called from thread");
return INVALID_OPERATION;
}
mCaptureLock.lock();
}
}
t->mLock.lock();