summaryrefslogtreecommitdiffstats
path: root/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
diff options
context:
space:
mode:
authorSundar Raman <sunds@ti.com>2011-11-10 08:15:13 -0800
committerIliyan Malchev <malchev@google.com>2011-11-10 13:49:03 -0800
commitf9df3ee5cfb3c3177bcc630abf6d756e8a60254c (patch)
treee54483e9f121255bb3d4562e82b2ab2b40bd8f8d /camera/OMXCameraAdapter/OMXCameraAdapter.cpp
parent3ec18006399d61e97382601d14aaa43ee339c8b6 (diff)
downloadhardware_ti_omap4xxx-f9df3ee5cfb3c3177bcc630abf6d756e8a60254c.tar.gz
hardware_ti_omap4xxx-f9df3ee5cfb3c3177bcc630abf6d756e8a60254c.tar.bz2
hardware_ti_omap4xxx-f9df3ee5cfb3c3177bcc630abf6d756e8a60254c.zip
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/OMXCameraAdapter/OMXCameraAdapter.cpp')
-rwxr-xr-xcamera/OMXCameraAdapter/OMXCameraAdapter.cpp16
1 files changed, 13 insertions, 3 deletions
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();