Files
external_libcamera/include/libcamera/timer.h
Niklas Söderlund 08b2e03a8a libcamera: timer: Stop timer when it is deleted
If a timer is running while it's deleted it is still register with the
event dispatcher. This causes a segmentation fault when the timer
time-out and its signal is emitted. Fix this my stopping the timer when
it's deleted.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-01 23:48:03 +02:00

39 lines
625 B
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* timer.h - Generic timer
*/
#ifndef __LIBCAMERA_TIMER_H__
#define __LIBCAMERA_TIMER_H__
#include <cstdint>
#include <libcamera/signal.h>
namespace libcamera {
class Timer
{
public:
Timer();
~Timer();
void start(unsigned int msec);
void stop();
bool isRunning() const;
unsigned int interval() const { return interval_; }
uint64_t deadline() const { return deadline_; }
Signal<Timer *> timeout;
private:
unsigned int interval_;
uint64_t deadline_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_TIMER_H__ */