diff options
author | Sundar Raman <sunds@ti.com> | 2011-11-10 22:00:07 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-11-10 22:00:07 +0000 |
commit | 1c69663b39e9d68f4f952d35e5a9b8e9b7fd376a (patch) | |
tree | 6cf07844e80fb21bbb11d4e54ee7fc023e8dc640 /camera | |
parent | 6788320d1e4a9f4af03f2cbd506f53b3c6de9ba3 (diff) | |
parent | bd74ef4ea4745901c9c8ef71f89fa059fb9c3f5b (diff) | |
download | hardware_ti_omap4-1c69663b39e9d68f4f952d35e5a9b8e9b7fd376a.zip hardware_ti_omap4-1c69663b39e9d68f4f952d35e5a9b8e9b7fd376a.tar.gz hardware_ti_omap4-1c69663b39e9d68f4f952d35e5a9b8e9b7fd376a.tar.bz2 |
am fef08387: am 7e51020e: am f9df3ee5: CameraHAL: Clear events queue fix, clear command queue on exit
* commit 'fef083876a27ebab9451c0151ce6fbaae0f66ccf':
CameraHAL: Clear events queue fix, clear command queue on exit
Diffstat (limited to 'camera')
-rw-r--r-- | camera/AppCallbackNotifier.cpp | 4 | ||||
-rwxr-xr-x | camera/OMXCameraAdapter/OMXCameraAdapter.cpp | 16 | ||||
-rw-r--r-- | camera/inc/OMXCameraAdapter/OMXCameraAdapter.h | 16 |
3 files changed, 30 insertions, 6 deletions
diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp index 4513c48..b431f54 100644 --- a/camera/AppCallbackNotifier.cpp +++ b/camera/AppCallbackNotifier.cpp @@ -1168,9 +1168,7 @@ void AppCallbackNotifier::flushEventQueue() { Mutex::Autolock lock(mLock); - TIUTILS::Message msg; - while(!mEventQ.isEmpty()) - mEventQ.get(&msg); + mEventQ.clear(); } } diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp index 0c64b74..1fa1607 100755 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp @@ -261,11 +261,11 @@ status_t OMXCameraAdapter::initialize(CameraProperties::Properties* caps) for (unsigned int i = 0 ;i < mEventSignalQ.size(); i++ ) { TIUTILS::Message *msg = mEventSignalQ.itemAt(i); //remove from queue and free msg - mEventSignalQ.removeAt(i); if ( NULL != msg ) { free(msg); } } + mEventSignalQ.clear(); } OMX_INIT_STRUCT_PTR (&mRegionPriority, OMX_TI_CONFIG_3A_REGION_PRIORITY); @@ -2646,7 +2646,6 @@ OMX_ERRORTYPE OMXCameraAdapter::OMXCameraAdapterEventHandler(OMX_IN OMX_HANDLETY if ( NULL != msg ) { Semaphore *sem = (Semaphore*) msg->arg3; - mEventSignalQ.removeAt(i); if ( sem ) { sem->Signal(); @@ -2654,6 +2653,7 @@ OMX_ERRORTYPE OMXCameraAdapter::OMXCameraAdapterEventHandler(OMX_IN OMX_HANDLETY free(msg); } } + mEventSignalQ.clear(); } ///Report Error to App mErrorNotifier->errorNotify(CAMERA_ERROR_FATAL); @@ -3305,7 +3305,10 @@ bool OMXCameraAdapter::CommandHandler::Handler() stat = NO_ERROR; CAMHAL_LOGDA("Handler: waiting for messsage..."); TIUTILS::MessageQueue::waitForMsg(&mCommandMsgQ, NULL, NULL, -1); + { + Mutex::Autolock lock(mLock); mCommandMsgQ.get(&msg); + } CAMHAL_LOGDB("msg.command = %d", msg.command); switch ( msg.command ) { case CommandHandler::CAMERA_START_IMAGE_CAPTURE: @@ -3348,7 +3351,11 @@ bool OMXCameraAdapter::OMXCallbackHandler::Handler() while(forever){ TIUTILS::MessageQueue::waitForMsg(&mCommandMsgQ, NULL, NULL, -1); + { + Mutex::Autolock lock(mLock); mCommandMsgQ.get(&msg); + } + switch ( msg.command ) { case OMXCallbackHandler::CAMERA_FILL_BUFFER_DONE: { @@ -3456,12 +3463,12 @@ OMXCameraAdapter::~OMXCameraAdapter() if ( NULL != msg ) { Semaphore *sem = (Semaphore*) msg->arg3; - mEventSignalQ.removeAt(i); sem->Signal(); free(msg); } } + mEventSignalQ.clear(); } //Exit and free ref to command handling thread @@ -3470,6 +3477,7 @@ OMXCameraAdapter::~OMXCameraAdapter() TIUTILS::Message msg; msg.command = CommandHandler::COMMAND_EXIT; msg.arg1 = mErrorNotifier; + mCommandHandler->clearCommandQ(); mCommandHandler->put(&msg); mCommandHandler->requestExitAndWait(); mCommandHandler.clear(); @@ -3480,6 +3488,8 @@ OMXCameraAdapter::~OMXCameraAdapter() { TIUTILS::Message msg; msg.command = OMXCallbackHandler::COMMAND_EXIT; + //Clear all messages pending first + mOMXCallbackHandler->clearCommandQ(); mOMXCallbackHandler->put(&msg); mOMXCallbackHandler->requestExitAndWait(); mOMXCallbackHandler.clear(); diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h index 7358f22..463032a 100644 --- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h +++ b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h @@ -654,9 +654,16 @@ private: } status_t put(TIUTILS::Message* msg){ + Mutex::Autolock lock(mLock); return mCommandMsgQ.put(msg); } + void clearCommandQ() + { + Mutex::Autolock lock(mLock); + mCommandMsgQ.clear(); + } + enum { COMMAND_EXIT = -1, CAMERA_START_IMAGE_CAPTURE = 0, @@ -668,6 +675,7 @@ private: bool Handler(); TIUTILS::MessageQueue mCommandMsgQ; OMXCameraAdapter* mCameraAdapter; + Mutex mLock; }; sp<CommandHandler> mCommandHandler; @@ -685,9 +693,16 @@ public: } status_t put(TIUTILS::Message* msg){ + Mutex::Autolock lock(mLock); return mCommandMsgQ.put(msg); } + void clearCommandQ() + { + Mutex::Autolock lock(mLock); + mCommandMsgQ.clear(); + } + enum { COMMAND_EXIT = -1, CAMERA_FILL_BUFFER_DONE, @@ -697,6 +712,7 @@ public: bool Handler(); TIUTILS::MessageQueue mCommandMsgQ; OMXCameraAdapter* mCameraAdapter; + Mutex mLock; }; sp<OMXCallbackHandler> mOMXCallbackHandler; |