diff options
author | Igor Murashkin <iam@google.com> | 2013-05-23 13:44:15 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-05-23 13:44:15 -0700 |
commit | 9b89c15d9d8abb9408760ffdb022df4c4367685b (patch) | |
tree | f0b1620a561469b74aaec6594e674b34c2825eb7 | |
parent | 98730cd7456b32255a37d691a70f49df22975a72 (diff) | |
parent | ca3fb120f5697c05e3ea1a50abe913a9cc4a8d73 (diff) | |
download | frameworks_av-9b89c15d9d8abb9408760ffdb022df4c4367685b.zip frameworks_av-9b89c15d9d8abb9408760ffdb022df4c4367685b.tar.gz frameworks_av-9b89c15d9d8abb9408760ffdb022df4c4367685b.tar.bz2 |
am ca3fb120: Merge "camera3: Fix zsl buffers released-while-in-use race condition" into jb-mr2-dev
* commit 'ca3fb120f5697c05e3ea1a50abe913a9cc4a8d73':
camera3: Fix zsl buffers released-while-in-use race condition
-rw-r--r-- | services/camera/libcameraservice/camera2/ZslProcessor3.cpp | 2 | ||||
-rw-r--r-- | services/camera/libcameraservice/gui/RingBufferConsumer.cpp | 30 |
2 files changed, 20 insertions, 12 deletions
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor3.cpp b/services/camera/libcameraservice/camera2/ZslProcessor3.cpp index af3e266..2e06691 100644 --- a/services/camera/libcameraservice/camera2/ZslProcessor3.cpp +++ b/services/camera/libcameraservice/camera2/ZslProcessor3.cpp @@ -413,6 +413,8 @@ nsecs_t ZslProcessor3::getCandidateTimestampLocked(size_t* metadataIdx) const { minTimestamp = frameTimestamp; idx = j; } + + ALOGVV("%s: Saw timestamp %lld", __FUNCTION__, frameTimestamp); } } diff --git a/services/camera/libcameraservice/gui/RingBufferConsumer.cpp b/services/camera/libcameraservice/gui/RingBufferConsumer.cpp index 2fa78a4..cd39bad 100644 --- a/services/camera/libcameraservice/gui/RingBufferConsumer.cpp +++ b/services/camera/libcameraservice/gui/RingBufferConsumer.cpp @@ -101,12 +101,6 @@ sp<PinnedBufferItem> RingBufferConsumer::pinSelectedBuffer( } // end scope of mMutex autolock - if (pinnedBuffer != 0) { - BI_LOGV("Pinned buffer frame %lld, timestamp %lld", - pinnedBuffer->getBufferItem().mFrameNumber, - pinnedBuffer->getBufferItem().mTimestamp); - } - if (waitForFence) { status_t err = pinnedBuffer->getBufferItem().mFence->waitForever( "RingBufferConsumer::pinSelectedBuffer"); @@ -172,6 +166,9 @@ void RingBufferConsumer::pinBufferLocked(const BufferItem& item) { if (it == end) { BI_LOGE("Failed to pin buffer (timestamp %lld, framenumber %lld)", item.mTimestamp, item.mFrameNumber); + } else { + BI_LOGV("Pinned buffer (frame %lld, timestamp %lld)", + item.mFrameNumber, item.mTimestamp); } } @@ -182,7 +179,7 @@ status_t RingBufferConsumer::releaseOldestBufferLocked(size_t* pinnedFrames) { it = mBufferItemList.begin(); end = mBufferItemList.end(); - accIt = it; + accIt = end; if (it == end) { /** @@ -197,12 +194,17 @@ status_t RingBufferConsumer::releaseOldestBufferLocked(size_t* pinnedFrames) { for (; it != end; ++it) { RingBufferItem& find = *it; - if (find.mTimestamp < accIt->mTimestamp && find.mPinCount <= 0) { - accIt = it; + + if (find.mPinCount > 0) { + if (pinnedFrames != NULL) { + ++(*pinnedFrames); + } + // Filter out pinned frame when searching for buffer to release + continue; } - if (find.mPinCount > 0 && pinnedFrames != NULL) { - ++(*pinnedFrames); + if (find.mTimestamp < accIt->mTimestamp || accIt == end) { + accIt = it; } } @@ -323,7 +325,11 @@ void RingBufferConsumer::unpinBuffer(const BufferItem& item) { } if (it == end) { - BI_LOGE("Failed to unpin buffer (timestamp %lld, framenumber %lld", + // This should never happen. If it happens, we have a bug. + BI_LOGE("Failed to unpin buffer (timestamp %lld, framenumber %lld)", + item.mTimestamp, item.mFrameNumber); + } else { + BI_LOGV("Unpinned buffer (timestamp %lld, framenumber %lld)", item.mTimestamp, item.mFrameNumber); } } |