Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9b5ad61 authored by Alok Kediya's avatar Alok Kediya Committed by Ricardo Cerqueira
Browse files

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
parent c62d1579
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -716,6 +716,14 @@ void CameraClient::disableMsgType(int32_t msgType) {
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",