diff options
author | Bill Peckham <bpeckham@google.com> | 2018-09-05 13:08:15 -0700 |
---|---|---|
committer | Bill Peckham <bpeckham@google.com> | 2018-09-05 13:08:53 -0700 |
commit | d190f3a68a52f0b7b32fdc52fc21482d9e93c095 (patch) | |
tree | dbbf7a05367c3bf041fdeeff17329661b400bad9 /camera/device/3.2/default/CameraDeviceSession.cpp | |
parent | 21431e337b6b9a6e967f8f32716b35f7f37d8304 (diff) |
Merge QP1A.180823.001
Change-Id: I0e80bda07db2ee67575e7d3c8bde46bf29d8c790
Diffstat (limited to 'camera/device/3.2/default/CameraDeviceSession.cpp')
-rw-r--r-- | camera/device/3.2/default/CameraDeviceSession.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/camera/device/3.2/default/CameraDeviceSession.cpp b/camera/device/3.2/default/CameraDeviceSession.cpp index 64d6d81a28..21dfd8894a 100644 --- a/camera/device/3.2/default/CameraDeviceSession.cpp +++ b/camera/device/3.2/default/CameraDeviceSession.cpp @@ -53,6 +53,7 @@ CameraDeviceSession::CameraDeviceSession( camera3_callback_ops({&sProcessCaptureResult, &sNotify}), mDevice(device), mDeviceVersion(device->common.version), + mFreeBufEarly(shouldFreeBufEarly()), mIsAELockAvailable(false), mDerivePostRawSensKey(false), mNumPartialResults(1), @@ -129,6 +130,10 @@ bool CameraDeviceSession::initialize() { return false; } +bool CameraDeviceSession::shouldFreeBufEarly() { + return property_get_bool("ro.vendor.camera.free_buf_early", 0) == 1; +} + CameraDeviceSession::~CameraDeviceSession() { if (!isClosed()) { ALOGE("CameraDeviceSession deleted before close!"); @@ -887,6 +892,24 @@ bool CameraDeviceSession::preProcessConfigurationLocked( (*streams)[i] = &mStreamMap[id]; } + if (mFreeBufEarly) { + // Remove buffers of deleted streams + for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { + int id = it->first; + bool found = false; + for (const auto& stream : requestedConfiguration.streams) { + if (id == stream.id) { + found = true; + break; + } + } + if (!found) { + // Unmap all buffers of deleted stream + cleanupBuffersLocked(id); + } + } + } + return true; } @@ -908,7 +931,9 @@ void CameraDeviceSession::postProcessConfigurationLocked( // Unmap all buffers of deleted stream // in case the configuration call succeeds and HAL // is able to release the corresponding resources too. - cleanupBuffersLocked(id); + if (!mFreeBufEarly) { + cleanupBuffersLocked(id); + } it = mStreamMap.erase(it); } else { ++it; @@ -927,6 +952,27 @@ void CameraDeviceSession::postProcessConfigurationLocked( mResultBatcher.setBatchedStreams(mVideoStreamIds); } + +void CameraDeviceSession::postProcessConfigurationFailureLocked( + const StreamConfiguration& requestedConfiguration) { + if (mFreeBufEarly) { + // Re-build the buf cache entry for deleted streams + for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { + int id = it->first; + bool found = false; + for (const auto& stream : requestedConfiguration.streams) { + if (id == stream.id) { + found = true; + break; + } + } + if (!found) { + mCirculatingBuffers.emplace(id, CirculatingBuffers{}); + } + } + } +} + Return<void> CameraDeviceSession::configureStreams( const StreamConfiguration& requestedConfiguration, ICameraDeviceSession::configureStreams_cb _hidl_cb) { @@ -979,6 +1025,8 @@ Return<void> CameraDeviceSession::configureStreams( // the corresponding resources of the deleted streams. if (ret == OK) { postProcessConfigurationLocked(requestedConfiguration); + } else { + postProcessConfigurationFailureLocked(requestedConfiguration); } if (ret == -EINVAL) { |