Merge "camera: add a lock for the request tracker"
diff --git a/modules/camera/3_4/camera.cpp b/modules/camera/3_4/camera.cpp
index c1b7b64..7636cba 100644
--- a/modules/camera/3_4/camera.cpp
+++ b/modules/camera/3_4/camera.cpp
@@ -72,7 +72,7 @@
 {
     ALOGI("%s:%d: Opening camera device", __func__, mId);
     ATRACE_CALL();
-    android::Mutex::Autolock al(mDeviceLock);
+    android::Mutex::Autolock dl(mDeviceLock);
 
     if (mBusy) {
         ALOGE("%s:%d: Error! Camera device already opened", __func__, mId);
@@ -109,7 +109,7 @@
 int Camera::loadStaticInfo() {
   // Using a lock here ensures |mStaticInfo| will only ever be set once,
   // even in concurrent situations.
-  android::Mutex::Autolock al(mStaticInfoLock);
+  android::Mutex::Autolock sl(mStaticInfoLock);
 
   if (mStaticInfo) {
     return 0;
@@ -139,7 +139,7 @@
 {
     ALOGI("%s:%d: Closing camera device", __func__, mId);
     ATRACE_CALL();
-    android::Mutex::Autolock al(mDeviceLock);
+    android::Mutex::Autolock dl(mDeviceLock);
 
     if (!mBusy) {
         ALOGE("%s:%d: Error! Camera device not open", __func__, mId);
@@ -169,7 +169,8 @@
 
 int Camera::configureStreams(camera3_stream_configuration_t *stream_config)
 {
-    android::Mutex::Autolock al(mDeviceLock);
+    android::Mutex::Autolock dl(mDeviceLock);
+    android::Mutex::Autolock tl(mInFlightTrackerLock);
 
     ALOGV("%s:%d: stream_config=%p", __func__, mId, stream_config);
     ATRACE_CALL();
@@ -298,7 +299,7 @@
     int res;
     // TODO(b/32917568): A capture request submitted or ongoing during a flush
     // should be returned with an error; for now they are mutually exclusive.
-    android::Mutex::Autolock al(mFlushLock);
+    android::Mutex::Autolock tl(mInFlightTrackerLock);
 
     ATRACE_CALL();
 
@@ -372,6 +373,8 @@
 
 void Camera::completeRequest(std::shared_ptr<CaptureRequest> request, int err)
 {
+    android::Mutex::Autolock tl(mInFlightTrackerLock);
+
     if (!mInFlightTracker->Remove(request)) {
         ALOGE("%s:%d: Completed request %p is not being tracked. "
               "It may have been cleared out during a flush.",
@@ -420,7 +423,7 @@
     // is called concurrently with this (in either order).
     // Since the callback to completeRequest also may happen on a separate
     // thread, this function should behave nicely concurrently with that too.
-    android::Mutex::Autolock al(mFlushLock);
+    android::Mutex::Autolock tl(mInFlightTrackerLock);
 
     std::set<std::shared_ptr<CaptureRequest>> requests;
     mInFlightTracker->Clear(&requests);
@@ -513,7 +516,7 @@
 {
     ALOGV("%s:%d: Dumping to fd %d", __func__, mId, fd);
     ATRACE_CALL();
-    android::Mutex::Autolock al(mDeviceLock);
+    android::Mutex::Autolock dl(mDeviceLock);
 
     dprintf(fd, "Camera ID: %d (Busy: %d)\n", mId, mBusy);
 
diff --git a/modules/camera/3_4/camera.h b/modules/camera/3_4/camera.h
index 687c733..8c49c8d 100644
--- a/modules/camera/3_4/camera.h
+++ b/modules/camera/3_4/camera.h
@@ -134,11 +134,11 @@
         // Lock protecting only static camera characteristics, which may
         // be accessed without the camera device open
         android::Mutex mStaticInfoLock;
-        android::Mutex mFlushLock;
         // Standard camera settings templates
         std::unique_ptr<const android::CameraMetadata> mTemplates[CAMERA3_TEMPLATE_COUNT];
         // Track in flight requests.
         std::unique_ptr<RequestTracker> mInFlightTracker;
+        android::Mutex mInFlightTrackerLock;
 };
 }  // namespace default_camera_hal