diff options
author | Tyler Luu <tluu@ti.com> | 2011-10-18 01:52:25 -0500 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2011-10-18 00:25:49 -0700 |
commit | 312fa6b1a184b5e3aaedf66e6a348d17d9e38bd8 (patch) | |
tree | babb9277973550675b5fbc8577aa8c4578b41478 | |
parent | 4e635e537afaa9f1416fa5bdbfd1b03afd8b7e6a (diff) | |
download | hardware_ti_omap4xxx-312fa6b1a184b5e3aaedf66e6a348d17d9e38bd8.zip hardware_ti_omap4xxx-312fa6b1a184b5e3aaedf66e6a348d17d9e38bd8.tar.gz hardware_ti_omap4xxx-312fa6b1a184b5e3aaedf66e6a348d17d9e38bd8.tar.bz2 |
CameraHal: Share a lock for exec and loaded switch
Share a lock between switchToLoaded function and doSwitchToExecuting,
so the two don't try to switch state at the same time.
b/5472446
Change-Id: I425943b97b7f08d1f7812214e4a305eb86af1ff9
Signed-off-by: Tyler Luu <tluu@ti.com>
-rw-r--r-- | camera/OMXCameraAdapter/OMXCameraAdapter.cpp | 16 | ||||
-rw-r--r-- | camera/inc/OMXCameraAdapter/OMXCameraAdapter.h | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp index 00212d5..0efa775 100644 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp @@ -1116,7 +1116,7 @@ status_t OMXCameraAdapter::switchToExecuting() LOG_FUNCTION_NAME; - mSwitchToExecLock.lock(); + mStateSwitchLock.lock(); msg.command = CommandHandler::CAMERA_SWITCH_TO_EXECUTING; msg.arg1 = mErrorNotifier; ret = mCommandHandler->put(&msg); @@ -1134,7 +1134,7 @@ status_t OMXCameraAdapter::doSwitchToExecuting() if ( (mComponentState == OMX_StateExecuting) || (mComponentState == OMX_StateInvalid) ){ CAMHAL_LOGDA("Already in OMX_Executing state or OMX_StateInvalid state"); - mSwitchToExecLock.unlock(); + mStateSwitchLock.unlock(); return NO_ERROR; } @@ -1213,7 +1213,7 @@ status_t OMXCameraAdapter::doSwitchToExecuting() mComponentState = OMX_StateExecuting; CAMHAL_LOGVB("OMX_SendCommand(OMX_StateExecuting) 0x%x", eError); - mSwitchToExecLock.unlock(); + mStateSwitchLock.unlock(); LOG_FUNCTION_NAME_EXIT; return ret; @@ -1221,7 +1221,7 @@ status_t OMXCameraAdapter::doSwitchToExecuting() EXIT: CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); performCleanupAfterError(); - mSwitchToExecLock.unlock(); + mStateSwitchLock.unlock(); LOG_FUNCTION_NAME_EXIT; return (ret | ErrorUtils::omxToAndroidError(eError)); } @@ -1233,6 +1233,8 @@ status_t OMXCameraAdapter::switchToLoaded() LOG_FUNCTION_NAME; + Mutex::Autolock lock(mStateSwitchLock); + if ( mComponentState == OMX_StateLoaded || mComponentState == OMX_StateInvalid) { CAMHAL_LOGDA("Already in OMX_Loaded state or OMX_StateInvalid state"); @@ -1454,7 +1456,7 @@ status_t OMXCameraAdapter::UseBuffersPreview(void* bufArr, int num) return BAD_VALUE; } - mSwitchToExecLock.lock(); + mStateSwitchLock.lock(); if ( mComponentState == OMX_StateLoaded ) { @@ -1788,7 +1790,7 @@ status_t OMXCameraAdapter::startPreview() } - mSwitchToExecLock.unlock(); + mStateSwitchLock.unlock(); //Queue all the buffers on preview port for(int index=0;index< mPreviewData->mMaxQueueable;index++) @@ -1847,7 +1849,7 @@ status_t OMXCameraAdapter::startPreview() CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); performCleanupAfterError(); - mSwitchToExecLock.unlock(); + mStateSwitchLock.unlock(); LOG_FUNCTION_NAME_EXIT; return (ret | ErrorUtils::omxToAndroidError(eError)); diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h index 87e2987..8418ff4 100644 --- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h +++ b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h @@ -873,7 +873,7 @@ private: Semaphore mSwitchToLoadedSem; Semaphore mSwitchToExecSem; - mutable Mutex mSwitchToExecLock; + mutable Mutex mStateSwitchLock; Vector<struct TIUTILS::Message *> mEventSignalQ; Mutex mEventLock; |