summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2012-03-14 23:37:20 -0500
committerEino-Ville Talvala <etalvala@google.com>2012-03-23 12:11:09 -0700
commit609bc02b21c725825bd469391e9ecd4e2d462fe1 (patch)
tree059871533bb941e9e087ff2cf83eb3bb755be99f /camera
parent796f0f82433a3040198f216d15fd9ce17c04f360 (diff)
downloadhardware_ti_omap4xxx-609bc02b21c725825bd469391e9ecd4e2d462fe1.zip
hardware_ti_omap4xxx-609bc02b21c725825bd469391e9ecd4e2d462fe1.tar.gz
hardware_ti_omap4xxx-609bc02b21c725825bd469391e9ecd4e2d462fe1.tar.bz2
camera: prevent possible deadlock scenario
Hold scope of returnFrame lock for just the calculation of refCount. Otherwise, we could have a scenario where endImageCapture and stopRecording could cause a deadlock competing for mReturnFrameLock and mLock. Issue arises mainly because endImageCapture is signalled from fillThisBuffer which stopRecording will need to get into. Make sure mEventQ has a message before calling get() since read on the pipe will block with notifyEvent holding mLock. Change-Id: I3a125711632fa311fd794e300cd5008321a84c40 Signed-off-by: Tyler Luu <tluu@ti.com>
Diffstat (limited to 'camera')
-rw-r--r--camera/AppCallbackNotifier.cpp8
-rw-r--r--camera/BaseCameraAdapter.cpp3
2 files changed, 7 insertions, 4 deletions
diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp
index 77b0556..aa41141 100644
--- a/camera/AppCallbackNotifier.cpp
+++ b/camera/AppCallbackNotifier.cpp
@@ -311,8 +311,12 @@ void AppCallbackNotifier::notifyEvent()
TIUTILS::Message msg;
LOG_FUNCTION_NAME;
{
- Mutex::Autolock lock(mLock);
- mEventQ.get(&msg);
+ Mutex::Autolock lock(mLock);
+ if(!mEventQ.isEmpty()) {
+ mEventQ.get(&msg);
+ } else {
+ return;
+ }
}
bool ret = true;
CameraHalEvent *evt = NULL;
diff --git a/camera/BaseCameraAdapter.cpp b/camera/BaseCameraAdapter.cpp
index 69291af..ec75232 100644
--- a/camera/BaseCameraAdapter.cpp
+++ b/camera/BaseCameraAdapter.cpp
@@ -258,8 +258,6 @@ void BaseCameraAdapter::returnFrame(void* frameBuf, CameraFrame::FrameType frame
size_t subscriberCount = 0;
int refCount = -1;
- Mutex::Autolock lock(mReturnFrameLock);
-
if ( NULL == frameBuf )
{
CAMHAL_LOGEA("Invalid frameBuf");
@@ -268,6 +266,7 @@ void BaseCameraAdapter::returnFrame(void* frameBuf, CameraFrame::FrameType frame
if ( NO_ERROR == res)
{
+ Mutex::Autolock lock(mReturnFrameLock);
refCount = getFrameRefCount(frameBuf, frameType);