summaryrefslogtreecommitdiffstats
path: root/services/camera
diff options
context:
space:
mode:
authorZhijun He <zhijunhe@google.com>2014-03-23 18:44:49 -0700
committerZhijun He <zhijunhe@google.com>2014-03-23 18:44:49 -0700
commit69a374897392c8bd70f441b7284f6f578c651ec9 (patch)
treede179831b224e28e6693430e80e3299f35c874bf /services/camera
parent2f5d0b32a8c5fcb03e4b0d55c53ff540052b5374 (diff)
downloadframeworks_av-69a374897392c8bd70f441b7284f6f578c651ec9.zip
frameworks_av-69a374897392c8bd70f441b7284f6f578c651ec9.tar.gz
frameworks_av-69a374897392c8bd70f441b7284f6f578c651ec9.tar.bz2
Camera3: Fix flush call deadlock
Flush shouldn't call waitUntilDrained directly, as they are all API calls with mLock and mInterfaceLock held. Move the waitUntilDrained implementation into waitUntilDrainedLocked to solve this issue. Change-Id: Id7d931091d5c11e12204790841097433515446db
Diffstat (limited to 'services/camera')
-rw-r--r--services/camera/libcameraservice/device3/Camera3Device.cpp6
-rw-r--r--services/camera/libcameraservice/device3/Camera3Device.h7
2 files changed, 12 insertions, 1 deletions
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index e5ac037..efc1bc7 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -997,6 +997,10 @@ status_t Camera3Device::waitUntilDrained() {
Mutex::Autolock il(mInterfaceLock);
Mutex::Autolock l(mLock);
+ return waitUntilDrainedLocked();
+}
+
+status_t Camera3Device::waitUntilDrainedLocked() {
switch (mStatus) {
case STATUS_UNINITIALIZED:
case STATUS_UNCONFIGURED:
@@ -1207,7 +1211,7 @@ status_t Camera3Device::flush() {
if (mHal3Device->common.version >= CAMERA_DEVICE_API_VERSION_3_1) {
res = mHal3Device->ops->flush(mHal3Device);
} else {
- res = waitUntilDrained();
+ res = waitUntilDrainedLocked();
}
return res;
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index 44c6260..7ea8bcf 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -246,6 +246,13 @@ class Camera3Device :
status_t waitUntilStateThenRelock(bool active, nsecs_t timeout);
/**
+ * Implementation of waitUntilDrained. On success, will transition to IDLE state.
+ *
+ * Need to be called with mLock and mInterfaceLock held.
+ */
+ status_t waitUntilDrainedLocked();
+
+ /**
* Do common work for setting up a streaming or single capture request.
* On success, will transition to ACTIVE if in IDLE.
*/