Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 1 | /* |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 2 | * Copyright (C) 2017-2018 The Android Open Source Project |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "CamDevSession@3.4-impl" |
| 18 | #include <android/log.h> |
| 19 | |
| 20 | #include <set> |
| 21 | #include <utils/Trace.h> |
| 22 | #include <hardware/gralloc.h> |
| 23 | #include <hardware/gralloc1.h> |
| 24 | #include "CameraDeviceSession.h" |
Shuzhen Wang | 892e826 | 2019-02-08 16:12:30 -0800 | [diff] [blame] | 25 | #include "CameraModule.h" |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace camera { |
| 30 | namespace device { |
| 31 | namespace V3_4 { |
| 32 | namespace implementation { |
| 33 | |
Shuzhen Wang | 892e826 | 2019-02-08 16:12:30 -0800 | [diff] [blame] | 34 | using ::android::hardware::camera::common::V1_0::helper::CameraModule; |
| 35 | |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 36 | CameraDeviceSession::CameraDeviceSession( |
| 37 | camera3_device_t* device, |
| 38 | const camera_metadata_t* deviceInfo, |
| 39 | const sp<V3_2::ICameraDeviceCallback>& callback) : |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 40 | V3_3::implementation::CameraDeviceSession(device, deviceInfo, callback), |
| 41 | mResultBatcher_3_4(callback) { |
| 42 | |
| 43 | mHasCallback_3_4 = false; |
| 44 | |
| 45 | auto castResult = ICameraDeviceCallback::castFrom(callback); |
| 46 | if (castResult.isOk()) { |
| 47 | sp<ICameraDeviceCallback> callback3_4 = castResult; |
| 48 | if (callback3_4 != nullptr) { |
| 49 | process_capture_result = sProcessCaptureResult_3_4; |
| 50 | notify = sNotify_3_4; |
| 51 | mHasCallback_3_4 = true; |
| 52 | if (!mInitFail) { |
| 53 | mResultBatcher_3_4.setResultMetadataQueue(mResultMetadataQueue); |
| 54 | } |
| 55 | } |
| 56 | } |
Shuzhen Wang | 448b7e3 | 2018-03-29 23:34:51 -0700 | [diff] [blame] | 57 | |
Emilian Peev | 59dd3df | 2018-05-03 13:25:51 +0100 | [diff] [blame] | 58 | mResultBatcher_3_4.setNumPartialResults(mNumPartialResults); |
| 59 | |
Shuzhen Wang | 892e826 | 2019-02-08 16:12:30 -0800 | [diff] [blame] | 60 | // Parse and store current logical camera's physical ids. |
| 61 | (void)CameraModule::isLogicalMultiCamera(mDeviceInfo, &mPhysicalCameraIds); |
| 62 | |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | CameraDeviceSession::~CameraDeviceSession() { |
| 66 | } |
| 67 | |
| 68 | Return<void> CameraDeviceSession::configureStreams_3_4( |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 69 | const StreamConfiguration& requestedConfiguration, |
| 70 | ICameraDeviceSession::configureStreams_3_4_cb _hidl_cb) { |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 71 | configureStreams_3_4_Impl(requestedConfiguration, _hidl_cb); |
| 72 | return Void(); |
| 73 | } |
| 74 | |
| 75 | void CameraDeviceSession::configureStreams_3_4_Impl( |
| 76 | const StreamConfiguration& requestedConfiguration, |
| 77 | ICameraDeviceSession::configureStreams_3_4_cb _hidl_cb, |
| 78 | uint32_t streamConfigCounter) { |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 79 | Status status = initStatus(); |
| 80 | HalStreamConfiguration outStreams; |
| 81 | |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 82 | // If callback is 3.2, make sure no physical stream is configured |
| 83 | if (!mHasCallback_3_4) { |
| 84 | for (size_t i = 0; i < requestedConfiguration.streams.size(); i++) { |
| 85 | if (requestedConfiguration.streams[i].physicalCameraId.size() > 0) { |
| 86 | ALOGE("%s: trying to configureStreams with physical camera id with V3.2 callback", |
| 87 | __FUNCTION__); |
| 88 | _hidl_cb(Status::INTERNAL_ERROR, outStreams); |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 89 | return; |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 94 | // hold the inflight lock for entire configureStreams scope since there must not be any |
| 95 | // inflight request/results during stream configuration. |
| 96 | Mutex::Autolock _l(mInflightLock); |
| 97 | if (!mInflightBuffers.empty()) { |
| 98 | ALOGE("%s: trying to configureStreams while there are still %zu inflight buffers!", |
| 99 | __FUNCTION__, mInflightBuffers.size()); |
| 100 | _hidl_cb(Status::INTERNAL_ERROR, outStreams); |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 101 | return; |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | if (!mInflightAETriggerOverrides.empty()) { |
| 105 | ALOGE("%s: trying to configureStreams while there are still %zu inflight" |
| 106 | " trigger overrides!", __FUNCTION__, |
| 107 | mInflightAETriggerOverrides.size()); |
| 108 | _hidl_cb(Status::INTERNAL_ERROR, outStreams); |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 109 | return; |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | if (!mInflightRawBoostPresent.empty()) { |
| 113 | ALOGE("%s: trying to configureStreams while there are still %zu inflight" |
| 114 | " boost overrides!", __FUNCTION__, |
| 115 | mInflightRawBoostPresent.size()); |
| 116 | _hidl_cb(Status::INTERNAL_ERROR, outStreams); |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 117 | return; |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | if (status != Status::OK) { |
| 121 | _hidl_cb(status, outStreams); |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 122 | return; |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | const camera_metadata_t *paramBuffer = nullptr; |
| 126 | if (0 < requestedConfiguration.sessionParams.size()) { |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 127 | V3_2::implementation::convertFromHidl(requestedConfiguration.sessionParams, ¶mBuffer); |
| 128 | } |
| 129 | |
| 130 | camera3_stream_configuration_t stream_list{}; |
Yin-Chia Yeh | 9e3079b | 2019-02-13 15:18:16 -0800 | [diff] [blame^] | 131 | // Block reading mStreamConfigCounter until configureStream returns |
| 132 | Mutex::Autolock _sccl(mStreamConfigCounterLock); |
| 133 | mStreamConfigCounter = streamConfigCounter; |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 134 | hidl_vec<camera3_stream_t*> streams; |
| 135 | stream_list.session_parameters = paramBuffer; |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 136 | if (!preProcessConfigurationLocked_3_4(requestedConfiguration, &stream_list, &streams)) { |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 137 | _hidl_cb(Status::INTERNAL_ERROR, outStreams); |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 138 | return; |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | ATRACE_BEGIN("camera3->configure_streams"); |
| 142 | status_t ret = mDevice->ops->configure_streams(mDevice, &stream_list); |
| 143 | ATRACE_END(); |
| 144 | |
| 145 | // In case Hal returns error most likely it was not able to release |
| 146 | // the corresponding resources of the deleted streams. |
| 147 | if (ret == OK) { |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 148 | postProcessConfigurationLocked_3_4(requestedConfiguration); |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 149 | } else { |
| 150 | postProcessConfigurationFailureLocked_3_4(requestedConfiguration); |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | if (ret == -EINVAL) { |
| 154 | status = Status::ILLEGAL_ARGUMENT; |
| 155 | } else if (ret != OK) { |
| 156 | status = Status::INTERNAL_ERROR; |
| 157 | } else { |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 158 | V3_4::implementation::convertToHidl(stream_list, &outStreams); |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 159 | mFirstRequest = true; |
| 160 | } |
| 161 | |
| 162 | _hidl_cb(status, outStreams); |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 163 | return; |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 166 | bool CameraDeviceSession::preProcessConfigurationLocked_3_4( |
| 167 | const StreamConfiguration& requestedConfiguration, |
| 168 | camera3_stream_configuration_t *stream_list /*out*/, |
| 169 | hidl_vec<camera3_stream_t*> *streams /*out*/) { |
| 170 | |
| 171 | if ((stream_list == nullptr) || (streams == nullptr)) { |
| 172 | return false; |
| 173 | } |
| 174 | |
| 175 | stream_list->operation_mode = (uint32_t) requestedConfiguration.operationMode; |
| 176 | stream_list->num_streams = requestedConfiguration.streams.size(); |
| 177 | streams->resize(stream_list->num_streams); |
| 178 | stream_list->streams = streams->data(); |
| 179 | |
| 180 | for (uint32_t i = 0; i < stream_list->num_streams; i++) { |
| 181 | int id = requestedConfiguration.streams[i].v3_2.id; |
| 182 | |
| 183 | if (mStreamMap.count(id) == 0) { |
| 184 | Camera3Stream stream; |
| 185 | convertFromHidl(requestedConfiguration.streams[i], &stream); |
| 186 | mStreamMap[id] = stream; |
| 187 | mPhysicalCameraIdMap[id] = requestedConfiguration.streams[i].physicalCameraId; |
| 188 | mStreamMap[id].data_space = mapToLegacyDataspace( |
| 189 | mStreamMap[id].data_space); |
| 190 | mStreamMap[id].physical_camera_id = mPhysicalCameraIdMap[id].c_str(); |
| 191 | mCirculatingBuffers.emplace(stream.mId, CirculatingBuffers{}); |
| 192 | } else { |
| 193 | // width/height/format must not change, but usage/rotation might need to change |
| 194 | if (mStreamMap[id].stream_type != |
| 195 | (int) requestedConfiguration.streams[i].v3_2.streamType || |
| 196 | mStreamMap[id].width != requestedConfiguration.streams[i].v3_2.width || |
| 197 | mStreamMap[id].height != requestedConfiguration.streams[i].v3_2.height || |
| 198 | mStreamMap[id].format != (int) requestedConfiguration.streams[i].v3_2.format || |
| 199 | mStreamMap[id].data_space != |
| 200 | mapToLegacyDataspace( static_cast<android_dataspace_t> ( |
| 201 | requestedConfiguration.streams[i].v3_2.dataSpace)) || |
| 202 | mPhysicalCameraIdMap[id] != requestedConfiguration.streams[i].physicalCameraId) { |
| 203 | ALOGE("%s: stream %d configuration changed!", __FUNCTION__, id); |
| 204 | return false; |
| 205 | } |
| 206 | mStreamMap[id].rotation = (int) requestedConfiguration.streams[i].v3_2.rotation; |
| 207 | mStreamMap[id].usage = (uint32_t) requestedConfiguration.streams[i].v3_2.usage; |
| 208 | } |
| 209 | (*streams)[i] = &mStreamMap[id]; |
| 210 | } |
| 211 | |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 212 | if (mFreeBufEarly) { |
| 213 | // Remove buffers of deleted streams |
| 214 | for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { |
| 215 | int id = it->first; |
| 216 | bool found = false; |
| 217 | for (const auto& stream : requestedConfiguration.streams) { |
| 218 | if (id == stream.v3_2.id) { |
| 219 | found = true; |
| 220 | break; |
| 221 | } |
| 222 | } |
| 223 | if (!found) { |
| 224 | // Unmap all buffers of deleted stream |
| 225 | cleanupBuffersLocked(id); |
| 226 | } |
| 227 | } |
| 228 | } |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 229 | return true; |
| 230 | } |
| 231 | |
| 232 | void CameraDeviceSession::postProcessConfigurationLocked_3_4( |
| 233 | const StreamConfiguration& requestedConfiguration) { |
| 234 | // delete unused streams, note we do this after adding new streams to ensure new stream |
| 235 | // will not have the same address as deleted stream, and HAL has a chance to reference |
| 236 | // the to be deleted stream in configure_streams call |
| 237 | for(auto it = mStreamMap.begin(); it != mStreamMap.end();) { |
| 238 | int id = it->first; |
| 239 | bool found = false; |
| 240 | for (const auto& stream : requestedConfiguration.streams) { |
| 241 | if (id == stream.v3_2.id) { |
| 242 | found = true; |
| 243 | break; |
| 244 | } |
| 245 | } |
| 246 | if (!found) { |
| 247 | // Unmap all buffers of deleted stream |
| 248 | // in case the configuration call succeeds and HAL |
| 249 | // is able to release the corresponding resources too. |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 250 | if (!mFreeBufEarly) { |
| 251 | cleanupBuffersLocked(id); |
| 252 | } |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 253 | it = mStreamMap.erase(it); |
| 254 | } else { |
| 255 | ++it; |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | // Track video streams |
| 260 | mVideoStreamIds.clear(); |
| 261 | for (const auto& stream : requestedConfiguration.streams) { |
| 262 | if (stream.v3_2.streamType == StreamType::OUTPUT && |
| 263 | stream.v3_2.usage & |
| 264 | graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) { |
| 265 | mVideoStreamIds.push_back(stream.v3_2.id); |
| 266 | } |
| 267 | } |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 268 | mResultBatcher_3_4.setBatchedStreams(mVideoStreamIds); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 269 | } |
| 270 | |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 271 | void CameraDeviceSession::postProcessConfigurationFailureLocked_3_4( |
| 272 | const StreamConfiguration& requestedConfiguration) { |
| 273 | if (mFreeBufEarly) { |
| 274 | // Re-build the buf cache entry for deleted streams |
| 275 | for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { |
| 276 | int id = it->first; |
| 277 | bool found = false; |
| 278 | for (const auto& stream : requestedConfiguration.streams) { |
| 279 | if (id == stream.v3_2.id) { |
| 280 | found = true; |
| 281 | break; |
| 282 | } |
| 283 | } |
| 284 | if (!found) { |
| 285 | mCirculatingBuffers.emplace(id, CirculatingBuffers{}); |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 291 | Return<void> CameraDeviceSession::processCaptureRequest_3_4( |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 292 | const hidl_vec<V3_4::CaptureRequest>& requests, |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 293 | const hidl_vec<V3_2::BufferCache>& cachesToRemove, |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 294 | ICameraDeviceSession::processCaptureRequest_3_4_cb _hidl_cb) { |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 295 | updateBufferCaches(cachesToRemove); |
| 296 | |
| 297 | uint32_t numRequestProcessed = 0; |
| 298 | Status s = Status::OK; |
| 299 | for (size_t i = 0; i < requests.size(); i++, numRequestProcessed++) { |
| 300 | s = processOneCaptureRequest_3_4(requests[i]); |
| 301 | if (s != Status::OK) { |
| 302 | break; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | if (s == Status::OK && requests.size() > 1) { |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 307 | mResultBatcher_3_4.registerBatch(requests[0].v3_2.frameNumber, requests.size()); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | _hidl_cb(s, numRequestProcessed); |
| 311 | return Void(); |
| 312 | } |
| 313 | |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 314 | Status CameraDeviceSession::processOneCaptureRequest_3_4(const V3_4::CaptureRequest& request) { |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 315 | Status status = initStatus(); |
| 316 | if (status != Status::OK) { |
| 317 | ALOGE("%s: camera init failed or disconnected", __FUNCTION__); |
| 318 | return status; |
| 319 | } |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 320 | // If callback is 3.2, make sure there are no physical settings. |
| 321 | if (!mHasCallback_3_4) { |
| 322 | if (request.physicalCameraSettings.size() > 0) { |
| 323 | ALOGE("%s: trying to call processCaptureRequest_3_4 with physical camera id " |
| 324 | "and V3.2 callback", __FUNCTION__); |
| 325 | return Status::INTERNAL_ERROR; |
| 326 | } |
| 327 | } |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 328 | |
| 329 | camera3_capture_request_t halRequest; |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 330 | halRequest.frame_number = request.v3_2.frameNumber; |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 331 | |
| 332 | bool converted = true; |
| 333 | V3_2::CameraMetadata settingsFmq; // settings from FMQ |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 334 | if (request.v3_2.fmqSettingsSize > 0) { |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 335 | // non-blocking read; client must write metadata before calling |
| 336 | // processOneCaptureRequest |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 337 | settingsFmq.resize(request.v3_2.fmqSettingsSize); |
| 338 | bool read = mRequestMetadataQueue->read(settingsFmq.data(), request.v3_2.fmqSettingsSize); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 339 | if (read) { |
| 340 | converted = V3_2::implementation::convertFromHidl(settingsFmq, &halRequest.settings); |
| 341 | } else { |
| 342 | ALOGE("%s: capture request settings metadata couldn't be read from fmq!", __FUNCTION__); |
| 343 | converted = false; |
| 344 | } |
| 345 | } else { |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 346 | converted = V3_2::implementation::convertFromHidl(request.v3_2.settings, |
| 347 | &halRequest.settings); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | if (!converted) { |
| 351 | ALOGE("%s: capture request settings metadata is corrupt!", __FUNCTION__); |
| 352 | return Status::ILLEGAL_ARGUMENT; |
| 353 | } |
| 354 | |
| 355 | if (mFirstRequest && halRequest.settings == nullptr) { |
| 356 | ALOGE("%s: capture request settings must not be null for first request!", |
| 357 | __FUNCTION__); |
| 358 | return Status::ILLEGAL_ARGUMENT; |
| 359 | } |
| 360 | |
| 361 | hidl_vec<buffer_handle_t*> allBufPtrs; |
| 362 | hidl_vec<int> allFences; |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 363 | bool hasInputBuf = (request.v3_2.inputBuffer.streamId != -1 && |
| 364 | request.v3_2.inputBuffer.bufferId != 0); |
| 365 | size_t numOutputBufs = request.v3_2.outputBuffers.size(); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 366 | size_t numBufs = numOutputBufs + (hasInputBuf ? 1 : 0); |
| 367 | |
| 368 | if (numOutputBufs == 0) { |
| 369 | ALOGE("%s: capture request must have at least one output buffer!", __FUNCTION__); |
| 370 | return Status::ILLEGAL_ARGUMENT; |
| 371 | } |
| 372 | |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 373 | status = importRequest(request.v3_2, allBufPtrs, allFences); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 374 | if (status != Status::OK) { |
| 375 | return status; |
| 376 | } |
| 377 | |
| 378 | hidl_vec<camera3_stream_buffer_t> outHalBufs; |
| 379 | outHalBufs.resize(numOutputBufs); |
| 380 | bool aeCancelTriggerNeeded = false; |
| 381 | ::android::hardware::camera::common::V1_0::helper::CameraMetadata settingsOverride; |
| 382 | { |
| 383 | Mutex::Autolock _l(mInflightLock); |
| 384 | if (hasInputBuf) { |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 385 | auto streamId = request.v3_2.inputBuffer.streamId; |
| 386 | auto key = std::make_pair(request.v3_2.inputBuffer.streamId, request.v3_2.frameNumber); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 387 | auto& bufCache = mInflightBuffers[key] = camera3_stream_buffer_t{}; |
| 388 | convertFromHidl( |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 389 | allBufPtrs[numOutputBufs], request.v3_2.inputBuffer.status, |
| 390 | &mStreamMap[request.v3_2.inputBuffer.streamId], allFences[numOutputBufs], |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 391 | &bufCache); |
| 392 | bufCache.stream->physical_camera_id = mPhysicalCameraIdMap[streamId].c_str(); |
| 393 | halRequest.input_buffer = &bufCache; |
| 394 | } else { |
| 395 | halRequest.input_buffer = nullptr; |
| 396 | } |
| 397 | |
| 398 | halRequest.num_output_buffers = numOutputBufs; |
| 399 | for (size_t i = 0; i < numOutputBufs; i++) { |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 400 | auto streamId = request.v3_2.outputBuffers[i].streamId; |
| 401 | auto key = std::make_pair(streamId, request.v3_2.frameNumber); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 402 | auto& bufCache = mInflightBuffers[key] = camera3_stream_buffer_t{}; |
| 403 | convertFromHidl( |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 404 | allBufPtrs[i], request.v3_2.outputBuffers[i].status, |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 405 | &mStreamMap[streamId], allFences[i], |
| 406 | &bufCache); |
| 407 | bufCache.stream->physical_camera_id = mPhysicalCameraIdMap[streamId].c_str(); |
| 408 | outHalBufs[i] = bufCache; |
| 409 | } |
| 410 | halRequest.output_buffers = outHalBufs.data(); |
| 411 | |
| 412 | AETriggerCancelOverride triggerOverride; |
| 413 | aeCancelTriggerNeeded = handleAePrecaptureCancelRequestLocked( |
| 414 | halRequest, &settingsOverride /*out*/, &triggerOverride/*out*/); |
| 415 | if (aeCancelTriggerNeeded) { |
| 416 | mInflightAETriggerOverrides[halRequest.frame_number] = |
| 417 | triggerOverride; |
| 418 | halRequest.settings = settingsOverride.getAndLock(); |
| 419 | } |
| 420 | } |
| 421 | |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 422 | std::vector<const char *> physicalCameraIds; |
| 423 | std::vector<const camera_metadata_t *> physicalCameraSettings; |
| 424 | std::vector<V3_2::CameraMetadata> physicalFmq; |
| 425 | size_t settingsCount = request.physicalCameraSettings.size(); |
| 426 | if (settingsCount > 0) { |
| 427 | physicalCameraIds.reserve(settingsCount); |
| 428 | physicalCameraSettings.reserve(settingsCount); |
| 429 | physicalFmq.reserve(settingsCount); |
| 430 | |
| 431 | for (size_t i = 0; i < settingsCount; i++) { |
| 432 | uint64_t settingsSize = request.physicalCameraSettings[i].fmqSettingsSize; |
Emilian Peev | e0c52bb | 2018-02-05 21:32:00 +0000 | [diff] [blame] | 433 | const camera_metadata_t *settings = nullptr; |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 434 | if (settingsSize > 0) { |
| 435 | physicalFmq.push_back(V3_2::CameraMetadata(settingsSize)); |
| 436 | bool read = mRequestMetadataQueue->read(physicalFmq[i].data(), settingsSize); |
| 437 | if (read) { |
| 438 | converted = V3_2::implementation::convertFromHidl(physicalFmq[i], &settings); |
| 439 | physicalCameraSettings.push_back(settings); |
| 440 | } else { |
| 441 | ALOGE("%s: physical camera settings metadata couldn't be read from fmq!", |
| 442 | __FUNCTION__); |
| 443 | converted = false; |
| 444 | } |
| 445 | } else { |
| 446 | converted = V3_2::implementation::convertFromHidl( |
| 447 | request.physicalCameraSettings[i].settings, &settings); |
| 448 | physicalCameraSettings.push_back(settings); |
| 449 | } |
| 450 | |
| 451 | if (!converted) { |
| 452 | ALOGE("%s: physical camera settings metadata is corrupt!", __FUNCTION__); |
| 453 | return Status::ILLEGAL_ARGUMENT; |
| 454 | } |
Emilian Peev | e0c52bb | 2018-02-05 21:32:00 +0000 | [diff] [blame] | 455 | |
| 456 | if (mFirstRequest && settings == nullptr) { |
| 457 | ALOGE("%s: Individual request settings must not be null for first request!", |
| 458 | __FUNCTION__); |
| 459 | return Status::ILLEGAL_ARGUMENT; |
| 460 | } |
| 461 | |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 462 | physicalCameraIds.push_back(request.physicalCameraSettings[i].physicalCameraId.c_str()); |
| 463 | } |
| 464 | } |
| 465 | halRequest.num_physcam_settings = settingsCount; |
| 466 | halRequest.physcam_id = physicalCameraIds.data(); |
| 467 | halRequest.physcam_settings = physicalCameraSettings.data(); |
| 468 | |
| 469 | ATRACE_ASYNC_BEGIN("frame capture", request.v3_2.frameNumber); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 470 | ATRACE_BEGIN("camera3->process_capture_request"); |
| 471 | status_t ret = mDevice->ops->process_capture_request(mDevice, &halRequest); |
| 472 | ATRACE_END(); |
| 473 | if (aeCancelTriggerNeeded) { |
| 474 | settingsOverride.unlock(halRequest.settings); |
| 475 | } |
| 476 | if (ret != OK) { |
| 477 | Mutex::Autolock _l(mInflightLock); |
| 478 | ALOGE("%s: HAL process_capture_request call failed!", __FUNCTION__); |
| 479 | |
| 480 | cleanupInflightFences(allFences, numBufs); |
| 481 | if (hasInputBuf) { |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 482 | auto key = std::make_pair(request.v3_2.inputBuffer.streamId, request.v3_2.frameNumber); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 483 | mInflightBuffers.erase(key); |
| 484 | } |
| 485 | for (size_t i = 0; i < numOutputBufs; i++) { |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 486 | auto key = std::make_pair(request.v3_2.outputBuffers[i].streamId, |
| 487 | request.v3_2.frameNumber); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 488 | mInflightBuffers.erase(key); |
| 489 | } |
| 490 | if (aeCancelTriggerNeeded) { |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 491 | mInflightAETriggerOverrides.erase(request.v3_2.frameNumber); |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 492 | } |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 493 | |
| 494 | if (ret == BAD_VALUE) { |
| 495 | return Status::ILLEGAL_ARGUMENT; |
| 496 | } else { |
| 497 | return Status::INTERNAL_ERROR; |
| 498 | } |
Shuzhen Wang | 82e36b3 | 2017-11-28 17:00:43 -0800 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | mFirstRequest = false; |
| 502 | return Status::OK; |
| 503 | } |
| 504 | |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 505 | /** |
| 506 | * Static callback forwarding methods from HAL to instance |
| 507 | */ |
| 508 | void CameraDeviceSession::sProcessCaptureResult_3_4( |
| 509 | const camera3_callback_ops *cb, |
| 510 | const camera3_capture_result *hal_result) { |
| 511 | CameraDeviceSession *d = |
| 512 | const_cast<CameraDeviceSession*>(static_cast<const CameraDeviceSession*>(cb)); |
| 513 | |
Shuzhen Wang | 17d817a | 2018-03-09 15:58:43 -0800 | [diff] [blame] | 514 | CaptureResult result = {}; |
Yin-Chia Yeh | 090872a | 2018-05-17 15:53:30 -0700 | [diff] [blame] | 515 | camera3_capture_result shadowResult; |
| 516 | bool handlePhysCam = (d->mDeviceVersion >= CAMERA_DEVICE_API_VERSION_3_5); |
| 517 | std::vector<::android::hardware::camera::common::V1_0::helper::CameraMetadata> compactMds; |
| 518 | std::vector<const camera_metadata_t*> physCamMdArray; |
| 519 | sShrinkCaptureResult(&shadowResult, hal_result, &compactMds, &physCamMdArray, handlePhysCam); |
| 520 | |
| 521 | status_t ret = d->constructCaptureResult(result.v3_2, &shadowResult); |
Shuzhen Wang | 17d817a | 2018-03-09 15:58:43 -0800 | [diff] [blame] | 522 | if (ret != OK) { |
| 523 | return; |
| 524 | } |
| 525 | |
Yin-Chia Yeh | 090872a | 2018-05-17 15:53:30 -0700 | [diff] [blame] | 526 | if (handlePhysCam) { |
| 527 | if (shadowResult.num_physcam_metadata > d->mPhysicalCameraIds.size()) { |
| 528 | ALOGE("%s: Fatal: Invalid num_physcam_metadata %u", __FUNCTION__, |
| 529 | shadowResult.num_physcam_metadata); |
Shuzhen Wang | 448b7e3 | 2018-03-29 23:34:51 -0700 | [diff] [blame] | 530 | return; |
| 531 | } |
Yin-Chia Yeh | 090872a | 2018-05-17 15:53:30 -0700 | [diff] [blame] | 532 | result.physicalCameraMetadata.resize(shadowResult.num_physcam_metadata); |
| 533 | for (uint32_t i = 0; i < shadowResult.num_physcam_metadata; i++) { |
| 534 | std::string physicalId = shadowResult.physcam_ids[i]; |
| 535 | if (d->mPhysicalCameraIds.find(physicalId) == d->mPhysicalCameraIds.end()) { |
| 536 | ALOGE("%s: Fatal: Invalid physcam_ids[%u]: %s", __FUNCTION__, |
| 537 | i, shadowResult.physcam_ids[i]); |
| 538 | return; |
| 539 | } |
| 540 | V3_2::CameraMetadata physicalMetadata; |
| 541 | V3_2::implementation::convertToHidl( |
| 542 | shadowResult.physcam_metadata[i], &physicalMetadata); |
| 543 | PhysicalCameraMetadata physicalCameraMetadata = { |
| 544 | .fmqMetadataSize = 0, |
| 545 | .physicalCameraId = physicalId, |
| 546 | .metadata = physicalMetadata }; |
| 547 | result.physicalCameraMetadata[i] = physicalCameraMetadata; |
| 548 | } |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 549 | } |
| 550 | d->mResultBatcher_3_4.processCaptureResult_3_4(result); |
| 551 | } |
| 552 | |
| 553 | void CameraDeviceSession::sNotify_3_4( |
| 554 | const camera3_callback_ops *cb, |
| 555 | const camera3_notify_msg *msg) { |
| 556 | CameraDeviceSession *d = |
| 557 | const_cast<CameraDeviceSession*>(static_cast<const CameraDeviceSession*>(cb)); |
| 558 | V3_2::NotifyMsg hidlMsg; |
| 559 | V3_2::implementation::convertToHidl(msg, &hidlMsg); |
| 560 | |
| 561 | if (hidlMsg.type == (V3_2::MsgType) CAMERA3_MSG_ERROR && |
| 562 | hidlMsg.msg.error.errorStreamId != -1) { |
| 563 | if (d->mStreamMap.count(hidlMsg.msg.error.errorStreamId) != 1) { |
| 564 | ALOGE("%s: unknown stream ID %d reports an error!", |
| 565 | __FUNCTION__, hidlMsg.msg.error.errorStreamId); |
| 566 | return; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | if (static_cast<camera3_msg_type_t>(hidlMsg.type) == CAMERA3_MSG_ERROR) { |
| 571 | switch (hidlMsg.msg.error.errorCode) { |
| 572 | case V3_2::ErrorCode::ERROR_DEVICE: |
| 573 | case V3_2::ErrorCode::ERROR_REQUEST: |
| 574 | case V3_2::ErrorCode::ERROR_RESULT: { |
| 575 | Mutex::Autolock _l(d->mInflightLock); |
| 576 | auto entry = d->mInflightAETriggerOverrides.find( |
| 577 | hidlMsg.msg.error.frameNumber); |
| 578 | if (d->mInflightAETriggerOverrides.end() != entry) { |
| 579 | d->mInflightAETriggerOverrides.erase( |
| 580 | hidlMsg.msg.error.frameNumber); |
| 581 | } |
| 582 | |
| 583 | auto boostEntry = d->mInflightRawBoostPresent.find( |
| 584 | hidlMsg.msg.error.frameNumber); |
| 585 | if (d->mInflightRawBoostPresent.end() != boostEntry) { |
| 586 | d->mInflightRawBoostPresent.erase( |
| 587 | hidlMsg.msg.error.frameNumber); |
| 588 | } |
| 589 | |
| 590 | } |
| 591 | break; |
| 592 | case V3_2::ErrorCode::ERROR_BUFFER: |
| 593 | default: |
| 594 | break; |
| 595 | } |
| 596 | |
| 597 | } |
| 598 | |
| 599 | d->mResultBatcher_3_4.notify(hidlMsg); |
| 600 | } |
| 601 | |
| 602 | CameraDeviceSession::ResultBatcher_3_4::ResultBatcher_3_4( |
| 603 | const sp<V3_2::ICameraDeviceCallback>& callback) : |
| 604 | V3_3::implementation::CameraDeviceSession::ResultBatcher(callback) { |
| 605 | auto castResult = ICameraDeviceCallback::castFrom(callback); |
| 606 | if (castResult.isOk()) { |
| 607 | mCallback_3_4 = castResult; |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | void CameraDeviceSession::ResultBatcher_3_4::processCaptureResult_3_4(CaptureResult& result) { |
| 612 | auto pair = getBatch(result.v3_2.frameNumber); |
| 613 | int batchIdx = pair.first; |
| 614 | if (batchIdx == NOT_BATCHED) { |
| 615 | processOneCaptureResult_3_4(result); |
| 616 | return; |
| 617 | } |
| 618 | std::shared_ptr<InflightBatch> batch = pair.second; |
| 619 | { |
| 620 | Mutex::Autolock _l(batch->mLock); |
| 621 | // Check if the batch is removed (mostly by notify error) before lock was acquired |
| 622 | if (batch->mRemoved) { |
| 623 | // Fall back to non-batch path |
| 624 | processOneCaptureResult_3_4(result); |
| 625 | return; |
| 626 | } |
| 627 | |
| 628 | // queue metadata |
| 629 | if (result.v3_2.result.size() != 0) { |
| 630 | // Save a copy of metadata |
| 631 | batch->mResultMds[result.v3_2.partialResult].mMds.push_back( |
| 632 | std::make_pair(result.v3_2.frameNumber, result.v3_2.result)); |
| 633 | } |
| 634 | |
| 635 | // queue buffer |
| 636 | std::vector<int> filledStreams; |
| 637 | std::vector<V3_2::StreamBuffer> nonBatchedBuffers; |
| 638 | for (auto& buffer : result.v3_2.outputBuffers) { |
| 639 | auto it = batch->mBatchBufs.find(buffer.streamId); |
| 640 | if (it != batch->mBatchBufs.end()) { |
| 641 | InflightBatch::BufferBatch& bb = it->second; |
| 642 | pushStreamBuffer(std::move(buffer), bb.mBuffers); |
| 643 | filledStreams.push_back(buffer.streamId); |
| 644 | } else { |
| 645 | pushStreamBuffer(std::move(buffer), nonBatchedBuffers); |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | // send non-batched buffers up |
| 650 | if (nonBatchedBuffers.size() > 0 || result.v3_2.inputBuffer.streamId != -1) { |
| 651 | CaptureResult nonBatchedResult; |
| 652 | nonBatchedResult.v3_2.frameNumber = result.v3_2.frameNumber; |
| 653 | nonBatchedResult.v3_2.fmqResultSize = 0; |
| 654 | nonBatchedResult.v3_2.outputBuffers.resize(nonBatchedBuffers.size()); |
| 655 | for (size_t i = 0; i < nonBatchedBuffers.size(); i++) { |
| 656 | moveStreamBuffer( |
| 657 | std::move(nonBatchedBuffers[i]), nonBatchedResult.v3_2.outputBuffers[i]); |
| 658 | } |
| 659 | moveStreamBuffer(std::move(result.v3_2.inputBuffer), nonBatchedResult.v3_2.inputBuffer); |
| 660 | nonBatchedResult.v3_2.partialResult = 0; // 0 for buffer only results |
| 661 | processOneCaptureResult_3_4(nonBatchedResult); |
| 662 | } |
| 663 | |
| 664 | if (result.v3_2.frameNumber == batch->mLastFrame) { |
| 665 | // Send data up |
| 666 | if (result.v3_2.partialResult > 0) { |
| 667 | sendBatchMetadataLocked(batch, result.v3_2.partialResult); |
| 668 | } |
| 669 | // send buffer up |
| 670 | if (filledStreams.size() > 0) { |
| 671 | sendBatchBuffersLocked(batch, filledStreams); |
| 672 | } |
| 673 | } |
| 674 | } // end of batch lock scope |
| 675 | |
| 676 | // see if the batch is complete |
| 677 | if (result.v3_2.frameNumber == batch->mLastFrame) { |
| 678 | checkAndRemoveFirstBatch(); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | void CameraDeviceSession::ResultBatcher_3_4::processOneCaptureResult_3_4(CaptureResult& result) { |
| 683 | hidl_vec<CaptureResult> results; |
| 684 | results.resize(1); |
| 685 | results[0] = std::move(result); |
| 686 | invokeProcessCaptureResultCallback_3_4(results, /* tryWriteFmq */true); |
| 687 | freeReleaseFences_3_4(results); |
| 688 | return; |
| 689 | } |
| 690 | |
| 691 | void CameraDeviceSession::ResultBatcher_3_4::invokeProcessCaptureResultCallback_3_4( |
| 692 | hidl_vec<CaptureResult> &results, bool tryWriteFmq) { |
| 693 | if (mProcessCaptureResultLock.tryLock() != OK) { |
| 694 | ALOGV("%s: previous call is not finished! waiting 1s...", __FUNCTION__); |
| 695 | if (mProcessCaptureResultLock.timedLock(1000000000 /* 1s */) != OK) { |
| 696 | ALOGE("%s: cannot acquire lock in 1s, cannot proceed", |
| 697 | __FUNCTION__); |
| 698 | return; |
| 699 | } |
| 700 | } |
| 701 | if (tryWriteFmq && mResultMetadataQueue->availableToWrite() > 0) { |
| 702 | for (CaptureResult &result : results) { |
| 703 | if (result.v3_2.result.size() > 0) { |
| 704 | if (mResultMetadataQueue->write(result.v3_2.result.data(), |
| 705 | result.v3_2.result.size())) { |
| 706 | result.v3_2.fmqResultSize = result.v3_2.result.size(); |
| 707 | result.v3_2.result.resize(0); |
| 708 | } else { |
| 709 | ALOGW("%s: couldn't utilize fmq, fall back to hwbinder", __FUNCTION__); |
| 710 | result.v3_2.fmqResultSize = 0; |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | for (auto& onePhysMetadata : result.physicalCameraMetadata) { |
| 715 | if (mResultMetadataQueue->write(onePhysMetadata.metadata.data(), |
| 716 | onePhysMetadata.metadata.size())) { |
| 717 | onePhysMetadata.fmqMetadataSize = onePhysMetadata.metadata.size(); |
| 718 | onePhysMetadata.metadata.resize(0); |
| 719 | } else { |
| 720 | ALOGW("%s: couldn't utilize fmq, fall back to hwbinder", __FUNCTION__); |
| 721 | onePhysMetadata.fmqMetadataSize = 0; |
| 722 | } |
| 723 | } |
| 724 | } |
| 725 | } |
| 726 | mCallback_3_4->processCaptureResult_3_4(results); |
| 727 | mProcessCaptureResultLock.unlock(); |
| 728 | } |
| 729 | |
| 730 | void CameraDeviceSession::ResultBatcher_3_4::freeReleaseFences_3_4(hidl_vec<CaptureResult>& results) { |
| 731 | for (auto& result : results) { |
| 732 | if (result.v3_2.inputBuffer.releaseFence.getNativeHandle() != nullptr) { |
| 733 | native_handle_t* handle = const_cast<native_handle_t*>( |
| 734 | result.v3_2.inputBuffer.releaseFence.getNativeHandle()); |
| 735 | native_handle_close(handle); |
| 736 | native_handle_delete(handle); |
| 737 | } |
| 738 | for (auto& buf : result.v3_2.outputBuffers) { |
| 739 | if (buf.releaseFence.getNativeHandle() != nullptr) { |
| 740 | native_handle_t* handle = const_cast<native_handle_t*>( |
| 741 | buf.releaseFence.getNativeHandle()); |
| 742 | native_handle_close(handle); |
| 743 | native_handle_delete(handle); |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | return; |
| 748 | } |
| 749 | |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 750 | } // namespace implementation |
| 751 | } // namespace V3_4 |
| 752 | } // namespace device |
| 753 | } // namespace camera |
| 754 | } // namespace hardware |
| 755 | } // namespace android |