summaryrefslogtreecommitdiffstats
path: root/camera/CameraHal.cpp
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2011-09-07 17:13:32 -0500
committerIliyan Malchev <malchev@google.com>2011-09-07 17:13:15 -0700
commit342adfa1cc708708ddfc167d06b2345fcaa8b0e5 (patch)
tree677f4b096e6083c668b67d7a7ba89dec235cae81 /camera/CameraHal.cpp
parentf5f41aa7943adde4e7bfb3fc181de154c4b0b9b0 (diff)
downloadhardware_ti_omap4xxx-342adfa1cc708708ddfc167d06b2345fcaa8b0e5.zip
hardware_ti_omap4xxx-342adfa1cc708708ddfc167d06b2345fcaa8b0e5.tar.gz
hardware_ti_omap4xxx-342adfa1cc708708ddfc167d06b2345fcaa8b0e5.tar.bz2
CameraHal: Handle stopPreview properly for preview in progress
During some cases like when phone orientation changes after startPreview call but before setPreviewDisplay, stopPreview is called by application. Before we were seeing some error messages from camera adapter state machine because we were trying to make some improper state transitions. This patch guards against that. This patch also resets the mPreviewStateInProgress flag in stopPreview Change-Id: If5e4c235b0937b37f567d9b1ed9bd4478ace69d4 Signed-off-by: Tyler Luu <tluu@ti.com>
Diffstat (limited to 'camera/CameraHal.cpp')
-rw-r--r--camera/CameraHal.cpp51
1 files changed, 30 insertions, 21 deletions
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp
index dde2145..4db34d8 100644
--- a/camera/CameraHal.cpp
+++ b/camera/CameraHal.cpp
@@ -1087,12 +1087,6 @@ status_t CameraHal::freePreviewDataBufs()
mPreviewDataBufs = NULL;
}
- else
- {
- CAMHAL_LOGEA("Couldn't free PreviewDataBufs allocated by memory manager");
- ret = -EINVAL;
- }
-
}
LOG_FUNCTION_NAME_EXIT;
@@ -3136,24 +3130,38 @@ void CameraHal::forceStopPreview()
mAppCallbackNotifier->stopPreviewCallbacks();
}
- // since prerequisite for capturing is for camera system
- // to be previewing...cancel all captures before stopping
- // preview
- if ( mCameraAdapter->getState() == CameraAdapter::CAPTURE_STATE &&
- mCameraAdapter->getNextState() != CameraAdapter::PREVIEW_STATE) {
- mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_IMAGE_CAPTURE);
- }
-
if ( NULL != mCameraAdapter ) {
- // according to javadoc...FD should be stopped in stopPreview
- // and application needs to call startFaceDection again
- // to restart FD
- mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_FD);
+ CameraAdapter::AdapterState currentState;
+ CameraAdapter::AdapterState nextState;
- cancelAutoFocus();
+ currentState = mCameraAdapter->getState();
+ nextState = mCameraAdapter->getNextState();
- //Stop the source of frames
- mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_PREVIEW);
+ // since prerequisite for capturing is for camera system
+ // to be previewing...cancel all captures before stopping
+ // preview
+ if ( (currentState == CameraAdapter::CAPTURE_STATE) &&
+ (nextState != CameraAdapter::PREVIEW_STATE)) {
+ mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_IMAGE_CAPTURE);
+ }
+
+ // only need to send these control commands to state machine if we are
+ // passed the LOADED_PREVIEW_STATE
+ if (currentState > CameraAdapter::LOADED_PREVIEW_STATE) {
+ // according to javadoc...FD should be stopped in stopPreview
+ // and application needs to call startFaceDection again
+ // to restart FD
+ mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_FD);
+
+ cancelAutoFocus();
+ }
+
+ // only need to send these control commands to state machine if we are
+ // passed the INITIALIZED_STATE
+ if (currentState > CameraAdapter::INTIALIZED_STATE) {
+ //Stop the source of frames
+ mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_PREVIEW);
+ }
}
freePreviewBufs();
@@ -3161,6 +3169,7 @@ void CameraHal::forceStopPreview()
mPreviewEnabled = false;
mDisplayPaused = false;
+ mPreviewStartInProgress = false;
LOG_FUNCTION_NAME_EXIT;
}