summaryrefslogtreecommitdiffstats
path: root/services/camera
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2013-10-07 18:01:46 -0700
committerIgor Murashkin <iam@google.com>2013-10-07 18:01:46 -0700
commit215bb3499c7eeea6303e55fac66452f2574c022a (patch)
tree4a42ea582e33d46c79c9a033ff8d10b14e4aad42 /services/camera
parentfee4ce338d78eeb58af1f66831ead53322d3859e (diff)
downloadframeworks_av-215bb3499c7eeea6303e55fac66452f2574c022a.zip
frameworks_av-215bb3499c7eeea6303e55fac66452f2574c022a.tar.gz
frameworks_av-215bb3499c7eeea6303e55fac66452f2574c022a.tar.bz2
camera2: Don't race while dumping last frame metadata
Bug: 11095203 Change-Id: Icfb31e1719634b62004d6c15a95a9316e9642e4c
Diffstat (limited to 'services/camera')
-rw-r--r--services/camera/libcameraservice/common/FrameProcessorBase.cpp10
-rw-r--r--services/camera/libcameraservice/common/FrameProcessorBase.h1
2 files changed, 10 insertions, 1 deletions
diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.cpp b/services/camera/libcameraservice/common/FrameProcessorBase.cpp
index e7b440a..52906ee 100644
--- a/services/camera/libcameraservice/common/FrameProcessorBase.cpp
+++ b/services/camera/libcameraservice/common/FrameProcessorBase.cpp
@@ -66,7 +66,14 @@ status_t FrameProcessorBase::removeListener(int32_t minId,
void FrameProcessorBase::dump(int fd, const Vector<String16>& /*args*/) {
String8 result(" Latest received frame:\n");
write(fd, result.string(), result.size());
- mLastFrame.dump(fd, 2, 6);
+
+ CameraMetadata lastFrame;
+ {
+ // Don't race while dumping metadata
+ Mutex::Autolock al(mLastFrameMutex);
+ lastFrame = CameraMetadata(mLastFrame);
+ }
+ lastFrame.dump(fd, 2, 6);
}
bool FrameProcessorBase::threadLoop() {
@@ -113,6 +120,7 @@ void FrameProcessorBase::processNewFrames(const sp<CameraDeviceBase> &device) {
}
if (!frame.isEmpty()) {
+ Mutex::Autolock al(mLastFrameMutex);
mLastFrame.acquire(frame);
}
}
diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.h b/services/camera/libcameraservice/common/FrameProcessorBase.h
index f96caff..4d80ebf 100644
--- a/services/camera/libcameraservice/common/FrameProcessorBase.h
+++ b/services/camera/libcameraservice/common/FrameProcessorBase.h
@@ -58,6 +58,7 @@ class FrameProcessorBase: public Thread {
virtual bool threadLoop();
Mutex mInputMutex;
+ Mutex mLastFrameMutex;
struct RangeListener {
int32_t minId;