summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-06 07:37:25 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-07 06:02:23 +0300
commitde5d7bfb4152cdfd46975c0b94f4604b14d2e8a4 (patch)
tree820a9dfe78ad88f018413cd238c66a582ae4855a /src
parentdfe1d8944141c36f3d6958b81668768d8bb7a023 (diff)
libcamera: timer: Allow restarting a timer before expiration
The Timer API allows restarting a timer before expiration. This isn't correctly implemented, fix it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/timer.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp
index 8c74e101..5d4e5271 100644
--- a/src/libcamera/timer.cpp
+++ b/src/libcamera/timer.cpp
@@ -75,6 +75,9 @@ void Timer::start(std::chrono::milliseconds duration)
<< duration.count() << ": deadline "
<< utils::time_point_to_string(deadline_);
+ if (isRunning())
+ unregisterTimer();
+
registerTimer();
}
@@ -88,6 +91,9 @@ void Timer::start(std::chrono::milliseconds duration)
*/
void Timer::stop()
{
+ if (!isRunning())
+ return;
+
unregisterTimer();
}