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>
This commit is contained in:
Laurent Pinchart
2019-10-06 07:37:25 +03:00
parent dfe1d89441
commit de5d7bfb41

View File

@@ -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();
}