summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilian Peev <epeev@mm-sol.com>2012-09-11 19:19:38 +0300
committerJason Simmons <jsimmons@google.com>2012-11-07 14:36:31 -0800
commit7dd4515cbb0d6914deb6d656adac547cacf91745 (patch)
tree0c3d8a2d0d56949a13136f15ba54b0a4990c3dec
parent8a91acbce48c2b7ab2d270310b4d0c844facdfb6 (diff)
downloadomap4-aah-7dd4515cbb0d6914deb6d656adac547cacf91745.tar.gz
CameraHal: Check return frames count before waiting on condition
- The Thread responsible for retrieving free buffers from the tapout is possible to miss some incoming signals and wait while buffers are available in the ST. Solution is to count all outgoing buffers and not wait on the condition when buffers are available. Change-Id: I31526dd334a08f52f0c6069cea847ae14e2cffbc Signed-off-by: Emilian Peev <epeev@mm-sol.com> Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>
-rw-r--r--camera/BufferSourceAdapter.cpp3
-rw-r--r--camera/inc/BufferSourceAdapter.h17
2 files changed, 15 insertions, 5 deletions
diff --git a/camera/BufferSourceAdapter.cpp b/camera/BufferSourceAdapter.cpp
index 036ce72..ba517a8 100644
--- a/camera/BufferSourceAdapter.cpp
+++ b/camera/BufferSourceAdapter.cpp
@@ -904,9 +904,6 @@ void BufferSourceAdapter::handleFrameCallback(CameraFrame* frame)
}
mFramesWithCameraAdapterMap.removeItem((buffer_handle_t *) frame->mBuffer->opaque);
-
- // signal return frame thread that it can dequeue a buffer now
- mReturnFrame->signal();
}
diff --git a/camera/inc/BufferSourceAdapter.h b/camera/inc/BufferSourceAdapter.h
index c62c3c8..8d1fa7c 100644
--- a/camera/inc/BufferSourceAdapter.h
+++ b/camera/inc/BufferSourceAdapter.h
@@ -47,6 +47,7 @@ private:
ReturnFrame(BufferSourceAdapter* __this) : mBufferSourceAdapter(__this) {
android::AutoMutex lock(mReturnFrameMutex);
mDestroying = false;
+ mFrameCount = 0;
}
~ReturnFrame() {
@@ -54,6 +55,8 @@ private:
}
void signal() {
+ android::AutoMutex lock(mReturnFrameMutex);
+ mFrameCount++;
mReturnFrameCondition.signal();
}
@@ -67,8 +70,13 @@ private:
virtual bool threadLoop() {
android::AutoMutex lock(mReturnFrameMutex);
- mReturnFrameCondition.wait(mReturnFrameMutex);
- if (!mDestroying) mBufferSourceAdapter->handleFrameReturn();
+ if ( 0 >= mFrameCount ) {
+ mReturnFrameCondition.wait(mReturnFrameMutex);
+ }
+ if (!mDestroying) {
+ mBufferSourceAdapter->handleFrameReturn();
+ mFrameCount--;
+ }
return true;
}
@@ -76,6 +84,7 @@ private:
BufferSourceAdapter* mBufferSourceAdapter;
android::Condition mReturnFrameCondition;
android::Mutex mReturnFrameMutex;
+ int mFrameCount;
bool mDestroying;
};
@@ -124,6 +133,10 @@ private:
if (frame) {
mBufferSourceAdapter->handleFrameCallback(frame);
frame->mMetaData.clear();
+
+ // signal return frame thread that it can dequeue a buffer now
+ mBufferSourceAdapter->mReturnFrame->signal();
+
delete frame;
}