summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorEmilian Peev <epeev@mm-sol.com>2012-09-14 10:26:45 +0300
committerDaniel Levin <dendy@ti.com>2012-10-10 18:55:50 +0300
commit0ca3a704f4445bdb317d0208cc3453e5a547619a (patch)
tree4a1b17b56ecc4ccf52eaaed38b7c459112b70579 /camera
parent2e97c4af00e4e6fbeeaf568e67f0d664e1d6e9d8 (diff)
downloadhardware_ti_omap4-0ca3a704f4445bdb317d0208cc3453e5a547619a.zip
hardware_ti_omap4-0ca3a704f4445bdb317d0208cc3453e5a547619a.tar.gz
hardware_ti_omap4-0ca3a704f4445bdb317d0208cc3453e5a547619a.tar.bz2
CameraHal: Avoid concurrent access to 'mFramestype'
- This vector is potentially accessed by two threads and needs to be protected by 'mLock'. - The change should resolve an instability observed with one MTBC test. Change-Id: I64f4b423bf6f1baab6ed16d3345c8ac1f96817cd Signed-off-by: Emilian Peev <epeev@mm-sol.com>
Diffstat (limited to 'camera')
-rw-r--r--camera/ANativeWindowDisplayAdapter.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/camera/ANativeWindowDisplayAdapter.cpp b/camera/ANativeWindowDisplayAdapter.cpp
index 7fe574a..ae11f4a 100644
--- a/camera/ANativeWindowDisplayAdapter.cpp
+++ b/camera/ANativeWindowDisplayAdapter.cpp
@@ -1099,13 +1099,14 @@ status_t ANativeWindowDisplayAdapter::PostFrame(ANativeWindowDisplayAdapter::Dis
}
- mFramesType.add( (int)mBuffers[i].opaque ,dispFrame.mType );
+ android::AutoMutex lock(mLock);
+
+ mFramesType.add( (int)mBuffers[i].opaque, dispFrame.mType);
if ( mDisplayState == ANativeWindowDisplayAdapter::DISPLAY_STARTED &&
(!mPaused || CameraFrame::CameraFrame::SNAPSHOT_FRAME == dispFrame.mType) &&
!mSuspend)
{
- android::AutoMutex lock(mLock);
uint32_t xOff = (dispFrame.mOffset% PAGE_SIZE);
uint32_t yOff = (dispFrame.mOffset / PAGE_SIZE);
@@ -1185,7 +1186,6 @@ status_t ANativeWindowDisplayAdapter::PostFrame(ANativeWindowDisplayAdapter::Dis
}
else
{
- android::AutoMutex lock(mLock);
buffer_handle_t *handle = (buffer_handle_t *) mBuffers[i].opaque;
// unlock buffer before giving it up
@@ -1217,6 +1217,8 @@ bool ANativeWindowDisplayAdapter::handleFrameReturn()
int stride; // dummy variable to get stride
android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get();
android::Rect bounds;
+ CameraFrame::FrameType frameType = CameraFrame::PREVIEW_FRAME_SYNC;
+
void *y_uv[2];
// TODO(XXX): Do we need to keep stride information in camera hal?
@@ -1279,18 +1281,19 @@ bool ANativeWindowDisplayAdapter::handleFrameReturn()
{
android::AutoMutex lock(mLock);
mFramesWithCameraAdapterMap.add((buffer_handle_t *) mBuffers[i].opaque, i);
- }
- for( k = 0; k < mFramesType.size() ; k++) {
- if(mFramesType.keyAt(k) == (int)mBuffers[i].opaque)
- break;
- }
- if ( k == mFramesType.size() ) {
- CAMHAL_LOGE("Frame type for preview buffer 0%x not found!!", mBuffers[i].opaque);
- return false;
- }
+ for( k = 0; k < mFramesType.size() ; k++) {
+ if(mFramesType.keyAt(k) == (int)mBuffers[i].opaque)
+ break;
+ }
- CameraFrame::FrameType frameType = (CameraFrame::FrameType) mFramesType.valueAt(k);
+ if ( k == mFramesType.size() ) {
+ CAMHAL_LOGE("Frame type for preview buffer 0%x not found!!", mBuffers[i].opaque);
+ return false;
+ }
+
+ frameType = (CameraFrame::FrameType) mFramesType.valueAt(k);
+ }
CAMHAL_LOGVB("handleFrameReturn: found graphic buffer %d of %d", i, mBufferCount-1);
mFrameProvider->returnFrame(&mBuffers[i], frameType);