diff options
author | Tyler Luu <tluu@ti.com> | 2011-09-07 17:13:32 -0500 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2011-09-07 17:13:15 -0700 |
commit | fba8211ebbceadc0836bd646bcd94bb99f205fe8 (patch) | |
tree | c4514f04ba3c694e68e9c5c76394fce0b9088ec1 /camera/CameraHal.cpp | |
parent | eec9df1622b2125d221a5b0f5c39633a14648d5a (diff) | |
download | hardware_ti_omap4-fba8211ebbceadc0836bd646bcd94bb99f205fe8.zip hardware_ti_omap4-fba8211ebbceadc0836bd646bcd94bb99f205fe8.tar.gz hardware_ti_omap4-fba8211ebbceadc0836bd646bcd94bb99f205fe8.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.cpp | 51 |
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; } |