From b8d6efba8b87e6eeb049651cb67f9827198e658e Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Wed, 24 Oct 2012 17:30:30 -0700 Subject: [PATCH] Camera2: Don't hold locks while waiting to sync. Bug: 7409877 Change-Id: Ia3a0bc4f0ab4e19fca868ba04a870cf8e8ee7adb --- services/camera/libcameraservice/Camera2Client.cpp | 68 +++++++++++----------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp index 94630f9da8..e59a240938 100644 --- a/services/camera/libcameraservice/Camera2Client.cpp +++ b/services/camera/libcameraservice/Camera2Client.cpp @@ -1068,42 +1068,44 @@ status_t Camera2Client::takePicture(int msgType) { status_t res; if ( (res = checkPid(__FUNCTION__) ) != OK) return res; - SharedParameters::Lock l(mParameters); - switch (l.mParameters.state) { - case Parameters::DISCONNECTED: - case Parameters::STOPPED: - case Parameters::WAITING_FOR_PREVIEW_WINDOW: - ALOGE("%s: Camera %d: Cannot take picture without preview enabled", - __FUNCTION__, mCameraId); - return INVALID_OPERATION; - case Parameters::PREVIEW: - // Good to go for takePicture - res = commandStopFaceDetectionL(l.mParameters); - if (res != OK) { - ALOGE("%s: Camera %d: Unable to stop face detection for still capture", + { + SharedParameters::Lock l(mParameters); + switch (l.mParameters.state) { + case Parameters::DISCONNECTED: + case Parameters::STOPPED: + case Parameters::WAITING_FOR_PREVIEW_WINDOW: + ALOGE("%s: Camera %d: Cannot take picture without preview enabled", __FUNCTION__, mCameraId); - return res; - } - l.mParameters.state = Parameters::STILL_CAPTURE; - break; - case Parameters::RECORD: - // Good to go for video snapshot - l.mParameters.state = Parameters::VIDEO_SNAPSHOT; - break; - case Parameters::STILL_CAPTURE: - case Parameters::VIDEO_SNAPSHOT: - ALOGE("%s: Camera %d: Already taking a picture", - __FUNCTION__, mCameraId); - return INVALID_OPERATION; - } + return INVALID_OPERATION; + case Parameters::PREVIEW: + // Good to go for takePicture + res = commandStopFaceDetectionL(l.mParameters); + if (res != OK) { + ALOGE("%s: Camera %d: Unable to stop face detection for still capture", + __FUNCTION__, mCameraId); + return res; + } + l.mParameters.state = Parameters::STILL_CAPTURE; + break; + case Parameters::RECORD: + // Good to go for video snapshot + l.mParameters.state = Parameters::VIDEO_SNAPSHOT; + break; + case Parameters::STILL_CAPTURE: + case Parameters::VIDEO_SNAPSHOT: + ALOGE("%s: Camera %d: Already taking a picture", + __FUNCTION__, mCameraId); + return INVALID_OPERATION; + } - ALOGV("%s: Camera %d: Starting picture capture", __FUNCTION__, mCameraId); + ALOGV("%s: Camera %d: Starting picture capture", __FUNCTION__, mCameraId); - res = mJpegProcessor->updateStream(l.mParameters); - if (res != OK) { - ALOGE("%s: Camera %d: Can't set up still image stream: %s (%d)", - __FUNCTION__, mCameraId, strerror(-res), res); - return res; + res = mJpegProcessor->updateStream(l.mParameters); + if (res != OK) { + ALOGE("%s: Camera %d: Can't set up still image stream: %s (%d)", + __FUNCTION__, mCameraId, strerror(-res), res); + return res; + } } // Need HAL to have correct settings before (possibly) triggering precapture -- 2.11.0