diff options
author | Sundar Raman <sunds@ti.com> | 2011-11-10 08:15:13 -0800 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2011-11-10 13:49:03 -0800 |
commit | f9df3ee5cfb3c3177bcc630abf6d756e8a60254c (patch) | |
tree | e54483e9f121255bb3d4562e82b2ab2b40bd8f8d /camera | |
parent | 3ec18006399d61e97382601d14aaa43ee339c8b6 (diff) | |
download | hardware_ti_omap4xxx-f9df3ee5cfb3c3177bcc630abf6d756e8a60254c.zip hardware_ti_omap4xxx-f9df3ee5cfb3c3177bcc630abf6d756e8a60254c.tar.gz hardware_ti_omap4xxx-f9df3ee5cfb3c3177bcc630abf6d756e8a60254c.tar.bz2 |
CameraHAL: Clear events queue fix, clear command queue on exit
Fix 2/3 for b/5593964.
1. The events queue wasn't being cleared correctly inside
OMXCameraAdapter as some items were being removed while the
index was being formulated based on the original size
2. The command queue should be cleared before posting the EXIT
message for the OMX adapter threads so as not to process those
messages since we are exiting
Change-Id: I0a5eaceb3d1504fee05b064ebb5fe888e129ad44
Signed-off-by: Sundar Raman <sunds@ti.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
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 2268e44..6b09e17 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; |