summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Gu <gucheng@google.com>2022-07-20 22:16:42 +0000
committerCheng Gu <gucheng@google.com>2022-07-25 22:19:30 +0000
commit1ef0944f5b16d877116844634bb75a2499fb6114 (patch)
tree131ef99ddc9ca4f1449fdd29414df34e5698f1c1
parentfa296befd2850ed6461bacd04aababb5fa10fc8f (diff)
downloadcamera-1ef0944f5b16d877116844634bb75a2499fb6114.tar.gz
realtime_zsl: Make a helper to return result with error
Moves the logic to a helper function that returns a result if there is already error with that frame. This commit doesn't change functionality, and is meant to allow future commits to re-use the same logic. Bug: 235371520 Test: Framework stress test, CTS Change-Id: I719e5b0ee6c517b729d751f442e744fdf9b251c8
-rw-r--r--common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc42
-rw-r--r--common/hal/google_camera_hal/realtime_zsl_result_request_processor.h6
2 files changed, 30 insertions, 18 deletions
diff --git a/common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc b/common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc
index cac5a28..d65d9f0 100644
--- a/common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc
+++ b/common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc
@@ -165,24 +165,8 @@ void RealtimeZslResultRequestProcessor::ProcessResult(
if (pending_error_frames_.find(result->frame_number) !=
pending_error_frames_.end()) {
RequestEntry& error_entry = pending_error_frames_[result->frame_number];
- // Also need to process pending buffers and metadata for the frame if exists.
- // If the result is complete (buffers and all partial results arrived), send
- // the callback directly. Otherwise wait until the missing pieces arrive.
- CombineErrorAndPendingEntriesToResult(error_entry, pending_request, result);
-
- if (AllDataCollected(error_entry)) {
- pending_error_frames_.erase(result->frame_number);
- pending_frame_number_to_requests_.erase(result->frame_number);
- }
-
- // Don't send result to framework if only internal raw callback
- if (pending_request.has_returned_output_to_internal_stream_manager &&
- result->result_metadata == nullptr &&
- result->output_buffers.size() == 0) {
- return;
- }
- process_capture_result_(std::move(result));
- return;
+ return ReturnResultDirectlyForFramesWithErrorsLocked(
+ error_entry, pending_request, std::move(result));
}
// Fill in final result metadata
@@ -393,5 +377,27 @@ void RealtimeZslResultRequestProcessor::CombineErrorAndPendingEntriesToResult(
pending_request.capture_request->frame_number = result->frame_number;
}
+void RealtimeZslResultRequestProcessor::ReturnResultDirectlyForFramesWithErrorsLocked(
+ RequestEntry& error_entry, RequestEntry& pending_request,
+ std::unique_ptr<CaptureResult> result) {
+ // Also need to process pending buffers and metadata for the frame if exists.
+ // If the result is complete (buffers and all partial results arrived), send
+ // the callback directly. Otherwise wait until the missing pieces arrive.
+ CombineErrorAndPendingEntriesToResult(error_entry, pending_request, result);
+
+ if (AllDataCollected(error_entry)) {
+ pending_error_frames_.erase(result->frame_number);
+ pending_frame_number_to_requests_.erase(result->frame_number);
+ }
+
+ // Don't send result to framework if only internal raw callback
+ if (pending_request.has_returned_output_to_internal_stream_manager &&
+ result->result_metadata == nullptr && result->output_buffers.size() == 0) {
+ return;
+ }
+ process_capture_result_(std::move(result));
+ return;
+}
+
} // namespace google_camera_hal
} // namespace android
diff --git a/common/hal/google_camera_hal/realtime_zsl_result_request_processor.h b/common/hal/google_camera_hal/realtime_zsl_result_request_processor.h
index 8bbf6d8..5454916 100644
--- a/common/hal/google_camera_hal/realtime_zsl_result_request_processor.h
+++ b/common/hal/google_camera_hal/realtime_zsl_result_request_processor.h
@@ -95,6 +95,12 @@ class RealtimeZslResultRequestProcessor : public RealtimeZslResultProcessor,
RequestEntry& error_entry, RequestEntry& pending_request,
std::unique_ptr<CaptureResult>& result) const;
+ // Returns result directly for frames with errors, if applicable. Call site
+ // must hold callback_lock_.
+ void ReturnResultDirectlyForFramesWithErrorsLocked(
+ RequestEntry& error_entry, RequestEntry& pending_request,
+ std::unique_ptr<CaptureResult> result);
+
// Results collected so far on a valid frame. Results are passed to the
// processor block once all items in the RequestEntry struct are complete -
// i.e. all buffers arrived an all partial results arrived.