Camera: Fix deadlock due to mLock in pcb and takepicture
In non-zsl case of takepicture, we do streamoff for preview
stream which is waiting on preview callback thread to exit.
By that time the lock has already been acquired by takePicture.
So preivew callback will not exit until it acquires lock and
takePicture cannot continue until PCB call back is returned.
Fix: Avoid the mLock at services when both Preview cb &
Compressed cb are enabled.
Change-Id: I61ffa60af34a3fc19b8f45c119535243b53c7d3c
diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp
index 005a507..23e7785 100644
--- a/services/camera/libcameraservice/api1/CameraClient.cpp
+++ b/services/camera/libcameraservice/api1/CameraClient.cpp
@@ -716,6 +716,14 @@
bool CameraClient::lockIfMessageWanted(int32_t msgType) {
int sleepCount = 0;
while (mMsgEnabled & msgType) {
+#ifdef QCOM_HARDWARE
+ if ((msgType == CAMERA_MSG_PREVIEW_FRAME) &&
+ (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE)) {
+ LOG1("lockIfMessageWanted(%d): Don't try to acquire mlock if "
+ "both Preview and Compressed are enabled", msgType);
+ return false;
+ }
+#endif
if (mLock.tryLock() == NO_ERROR) {
if (sleepCount > 0) {
LOG1("lockIfMessageWanted(%d): waited for %d ms",