summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2020-08-01 09:01:49 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-08-05 17:48:55 +0300
commitdb552b0b925a9ba2c3cc54aa40feed6fb7e66981 (patch)
treeacd8fea87ed8cb93f1d6ddac20c5564e457704b8 /src
parent3a680a667fc98cefdaeba9b55751c8725a35aa36 (diff)
libcamera: ipa: raspberrypi: ALSC: Improve locking in a few places
Fix up a few locations where we call notify_one() with the lock held. In particular, restartAsync does not need to be called with the lock held for its entire duration. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/ipa/raspberrypi/controller/rpi/alsc.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp
index 76e2f04b..12359dc5 100644
--- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp
@@ -32,8 +32,8 @@ Alsc::~Alsc()
{
std::lock_guard<std::mutex> lock(mutex_);
async_abort_ = true;
- async_signal_.notify_one();
}
+ async_signal_.notify_one();
async_thread_.join();
}
@@ -268,8 +268,11 @@ void Alsc::restartAsync(StatisticsPtr &stats, Metadata *image_metadata)
frame_phase_ = 0;
// copy the camera mode so it won't change during the calculations
async_camera_mode_ = camera_mode_;
- async_start_ = true;
async_started_ = true;
+ {
+ std::lock_guard<std::mutex> lock(mutex_);
+ async_start_ = true;
+ }
async_signal_.notify_one();
}
@@ -315,7 +318,6 @@ void Alsc::Process(StatisticsPtr &stats, Metadata *image_metadata)
RPI_LOG("Alsc: frame_phase " << frame_phase_);
if (frame_phase_ >= (int)config_.frame_period ||
frame_count2_ < (int)config_.startup_frames) {
- std::unique_lock<std::mutex> lock(mutex_);
if (async_started_ == false) {
RPI_LOG("ALSC thread starting");
restartAsync(stats, image_metadata);
@@ -339,8 +341,8 @@ void Alsc::asyncFunc()
{
std::lock_guard<std::mutex> lock(mutex_);
async_finished_ = true;
- sync_signal_.notify_one();
}
+ sync_signal_.notify_one();
}
}