summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortimothywang <timothywang@google.com>2022-06-14 05:27:16 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-06-14 05:27:16 +0000
commit65c9ef8a9b2079658805f28fcc1ef380b30bcde6 (patch)
treed1781c434cb804b2c47039605e4b55375c5b2f80
parentd60b447dd64a218c185cfa078e76471b1d7a9935 (diff)
parent02c7c6903e8afe9cec01e935075795915cfb1dc1 (diff)
downloadcamera-65c9ef8a9b2079658805f28fcc1ef380b30bcde6.tar.gz
Reduce result lock scope am: 02c7c6903e
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/google/camera/+/18670831 Change-Id: I8492cb091a9ebd32094de36a0d30eaa64bb064c0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--common/hal/utils/result_dispatcher.cc38
1 files changed, 20 insertions, 18 deletions
diff --git a/common/hal/utils/result_dispatcher.cc b/common/hal/utils/result_dispatcher.cc
index 2d6d120..0a4832c 100644
--- a/common/hal/utils/result_dispatcher.cc
+++ b/common/hal/utils/result_dispatcher.cc
@@ -240,27 +240,29 @@ status_t ResultDispatcher::AddShutter(uint32_t frame_number,
int64_t timestamp_ns,
int64_t readout_timestamp_ns) {
ATRACE_CALL();
- std::lock_guard<std::mutex> lock(result_lock_);
+ {
+ std::lock_guard<std::mutex> lock(result_lock_);
- auto shutter_it = pending_shutters_.find(frame_number);
- if (shutter_it == pending_shutters_.end()) {
- ALOGE("%s: Cannot find the pending shutter for frame %u", __FUNCTION__,
- frame_number);
- return NAME_NOT_FOUND;
- }
+ auto shutter_it = pending_shutters_.find(frame_number);
+ if (shutter_it == pending_shutters_.end()) {
+ ALOGE("%s: Cannot find the pending shutter for frame %u", __FUNCTION__,
+ frame_number);
+ return NAME_NOT_FOUND;
+ }
- if (shutter_it->second.ready) {
- ALOGE("%s: Already received shutter (%" PRId64
- ") for frame %u. New "
- "timestamp %" PRId64,
- __FUNCTION__, shutter_it->second.timestamp_ns, frame_number,
- timestamp_ns);
- return ALREADY_EXISTS;
- }
+ if (shutter_it->second.ready) {
+ ALOGE("%s: Already received shutter (%" PRId64
+ ") for frame %u. New "
+ "timestamp %" PRId64,
+ __FUNCTION__, shutter_it->second.timestamp_ns, frame_number,
+ timestamp_ns);
+ return ALREADY_EXISTS;
+ }
- shutter_it->second.timestamp_ns = timestamp_ns;
- shutter_it->second.readout_timestamp_ns = readout_timestamp_ns;
- shutter_it->second.ready = true;
+ shutter_it->second.timestamp_ns = timestamp_ns;
+ shutter_it->second.readout_timestamp_ns = readout_timestamp_ns;
+ shutter_it->second.ready = true;
+ }
{
std::unique_lock<std::mutex> lock(notify_callback_lock_);
is_result_shutter_updated_ = true;