[libcamera-devel] [PATCH 5/9] libcamera: timer: Allow restarting a timer before expiration

Jacopo Mondi jacopo at jmondi.org
Sun Oct 6 20:59:19 CEST 2019


Hi Laurent

On Sun, Oct 06, 2019 at 08:32:22AM +0300, Laurent Pinchart wrote:
> The Timer API allows restarting a timer before expiration. This isn't
> correctly implemented, fix it.

How come the timer.cpp test which test restarts was not failing ?
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  src/libcamera/timer.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp
> index 8c74e1015e43..5d4e52713e6e 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();
>  }
>
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20191006/bedb08f8/attachment-0001.sig>


More information about the libcamera-devel mailing list