ExternalCameraHAL: improve buffer and error handling am: 895f5bbddc
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3011718
Change-Id: I6d6802877bb80aeb8101e9465fe9c57c4de1c04b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/camera/device/default/ExternalCameraDeviceSession.cpp b/camera/device/default/ExternalCameraDeviceSession.cpp
index 479167c..075a9f6 100644
--- a/camera/device/default/ExternalCameraDeviceSession.cpp
+++ b/camera/device/default/ExternalCameraDeviceSession.cpp
@@ -1726,8 +1726,8 @@
result.outputBuffers[i].bufferId = req->buffers[i].bufferId;
result.outputBuffers[i].status = BufferStatus::ERROR;
if (req->buffers[i].acquireFence >= 0) {
- native_handle_t* handle = native_handle_create(/*numFds*/ 1, /*numInts*/ 0);
- handle->data[0] = req->buffers[i].acquireFence;
+ // numFds = 0 for error
+ native_handle_t* handle = native_handle_create(/*numFds*/ 0, /*numInts*/ 0);
result.outputBuffers[i].releaseFence = android::dupToAidl(handle);
native_handle_delete(handle);
}
@@ -1961,6 +1961,7 @@
std::chrono::milliseconds timeout = std::chrono::milliseconds(kReqProcTimeoutMs);
auto st = mRequestDoneCond.wait_for(lk, timeout);
if (st == std::cv_status::timeout) {
+ mRequestingBuffer = false;
ALOGE("%s: wait for buffer request finish timeout!", __FUNCTION__);
return -1;
}
@@ -2078,6 +2079,7 @@
}
} else {
ALOGE("%s: requestStreamBuffers call failed!", __FUNCTION__);
+ return false;
}
mPendingReturnBufferReqs = std::move(mBufferReqs);
@@ -2797,9 +2799,15 @@
ATRACE_END();
if (res != 0) {
+ // HAL buffer management buffer request can fail
ALOGE("%s: wait for BufferRequest done failed! res %d", __FUNCTION__, res);
lk.unlock();
- return onDeviceError("%s: failed to process buffer request error!", __FUNCTION__);
+ Status st = parent->processCaptureRequestError(req);
+ if (st != Status::OK) {
+ return onDeviceError("%s: failed to process capture request error!", __FUNCTION__);
+ }
+ signalRequestDone();
+ return true;
}
ALOGV("%s processing new request", __FUNCTION__);