Camera: Sync request thread exit with request clear flag
'mRequestClearing' will be set before the request thread is
able to exit. Depending on timing, the request thread can clear
the flag and wait for the request signal one extra
iteration before it is able to quit.
Avoid the extra wait by requesting exit and enabling the request
clear flag synchronously.
Bug: 297497171
Test: Camera CTS
Change-Id: I7856e633f897e245ca2df7155c6b18c1e6efd81f
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 456d1be..c0d246b 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -295,13 +295,6 @@
}
}
}
- // Signal to request thread that we're not expecting any
- // more requests. This will be true since once we're in
- // disconnect and we've cleared off the request queue, the
- // request thread can't receive any new requests through
- // binder calls - since disconnect holds
- // mBinderSerialization lock.
- mRequestThread->setRequestClearing();
}
if (mStatus == STATUS_ERROR) {
@@ -3299,8 +3292,12 @@
}
void Camera3Device::RequestThread::requestExit() {
- // Call parent to set up shutdown
- Thread::requestExit();
+ {
+ Mutex::Autolock l(mRequestLock);
+ mRequestClearing = true;
+ // Call parent to set up shutdown
+ Thread::requestExit();
+ }
// The exit from any possible waits
mDoPauseSignal.signal();
mRequestSignal.signal();
@@ -4432,11 +4429,6 @@
return;
}
-void Camera3Device::RequestThread::setRequestClearing() {
- Mutex::Autolock l(mRequestLock);
- mRequestClearing = true;
-}
-
sp<Camera3Device::CaptureRequest>
Camera3Device::RequestThread::waitForNextRequestLocked() {
status_t res;