From 21d11a6c7dee30d4391eeee8bace8c4be26cffb8 Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Mon, 20 Jul 2015 10:03:25 -0700 Subject: cameraservice: Resolve message vs start/stop preview races Move the mutex in start/stopPreview to include the metadata message management. Fast start/stop sequences could (and would) eventually cause the messages to be enabled/disabled out of sequence (or while the camera wasn't ready for it) This is a port of I367bc45729ce2e858fea972f35e881a755c6021a from cm-11 Change-Id: I9a065f951f628d1c550acbac18493b9ad3853d03 --- services/camera/libcameraservice/api1/CameraClient.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'services') diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp index f3a7988..b64c48c 100644 --- a/services/camera/libcameraservice/api1/CameraClient.cpp +++ b/services/camera/libcameraservice/api1/CameraClient.cpp @@ -360,12 +360,14 @@ status_t CameraClient::setPreviewCallbackTarget( // start preview mode status_t CameraClient::startPreview() { + Mutex::Autolock lock(mLock); LOG1("startPreview (pid %d)", getCallingPid()); return startCameraMode(CAMERA_PREVIEW_MODE); } // start recording mode status_t CameraClient::startRecording() { + Mutex::Autolock lock(mLock); LOG1("startRecording (pid %d)", getCallingPid()); return startCameraMode(CAMERA_RECORDING_MODE); } @@ -373,7 +375,6 @@ status_t CameraClient::startRecording() { // start preview or recording status_t CameraClient::startCameraMode(camera_mode mode) { LOG1("startCameraMode(%d)", mode); - Mutex::Autolock lock(mLock); status_t result = checkPidAndHardware(); if (result != NO_ERROR) return result; -- cgit v1.1