From de5d7bfb4152cdfd46975c0b94f4604b14d2e8a4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 6 Oct 2019 07:37:25 +0300 Subject: libcamera: timer: Allow restarting a timer before expiration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Timer API allows restarting a timer before expiration. This isn't correctly implemented, fix it. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/timer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/libcamera/timer.cpp') 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(); } -- cgit v1.2.1