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

Commit c12b0b6c authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

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)

Fixes BACON-173

Change-Id: I367bc45729ce2e858fea972f35e881a755c6021a
parent fb5176a4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -361,6 +361,7 @@ status_t CameraClient::setPreviewCallbackTarget(

// start preview mode
status_t CameraClient::startPreview() {
    Mutex::Autolock lock(mLock);
#ifdef CAMERA_MSG_MGMT
    enableMsgType(CAMERA_MSG_PREVIEW_METADATA);
#endif
@@ -370,6 +371,7 @@ status_t CameraClient::startPreview() {

// start recording mode
status_t CameraClient::startRecording() {
    Mutex::Autolock lock(mLock);
    LOG1("startRecording (pid %d)", getCallingPid());
    return startCameraMode(CAMERA_RECORDING_MODE);
}
@@ -377,7 +379,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;

@@ -455,10 +456,10 @@ status_t CameraClient::startRecordingMode() {
// stop preview mode
void CameraClient::stopPreview() {
    LOG1("stopPreview (pid %d)", getCallingPid());
    Mutex::Autolock lock(mLock);
#ifdef CAMERA_MSG_MGMT
    disableMsgType(CAMERA_MSG_PREVIEW_METADATA);
#endif
    Mutex::Autolock lock(mLock);
    if (checkPidAndHardware() != NO_ERROR) return;

#ifdef OMAP_ENHANCEMENT