diff options
author | Igor Murashkin <iam@google.com> | 2013-10-07 18:01:46 -0700 |
---|---|---|
committer | Igor Murashkin <iam@google.com> | 2013-10-07 18:01:46 -0700 |
commit | 215bb3499c7eeea6303e55fac66452f2574c022a (patch) | |
tree | 4a42ea582e33d46c79c9a033ff8d10b14e4aad42 /services | |
parent | fee4ce338d78eeb58af1f66831ead53322d3859e (diff) | |
download | frameworks_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')
-rw-r--r-- | services/camera/libcameraservice/common/FrameProcessorBase.cpp | 10 | ||||
-rw-r--r-- | services/camera/libcameraservice/common/FrameProcessorBase.h | 1 |
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; |