[libcamera-devel] libcamera: v4l2_videodevice: Fix uninitialised watchdogDuration_
diff mbox series

Message ID 20220406144553.193858-1-umang.jain@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] libcamera: v4l2_videodevice: Fix uninitialised watchdogDuration_
Related show

Commit Message

Umang Jain April 6, 2022, 2:45 p.m. UTC
Initialise the watchdogDuration_ member to 0ms before it is used
in rest of the code base. Failing to do so, spews out log warnings
regarding dequeue timer being expired.

Fixes: 16f3d2de50ff ("libcamera: v4l2_videodevice: Add a dequeue timer")
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/libcamera/v4l2_videodevice.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Naushir Patuck April 6, 2022, 2:53 p.m. UTC | #1
Hi Umang,

Thank you for fixing this.  Sorry I did not spot it earlier.

On Wed, 6 Apr 2022 at 15:46, Umang Jain <umang.jain@ideasonboard.com> wrote:

> Initialise the watchdogDuration_ member to 0ms before it is used
> in rest of the code base. Failing to do so, spews out log warnings
> regarding dequeue timer being expired.
>
> Fixes: 16f3d2de50ff ("libcamera: v4l2_videodevice: Add a dequeue timer")
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
>

Reviewed-by: Naushir Patuck <naush@raspberrypi.com>


> ---
>  src/libcamera/v4l2_videodevice.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/libcamera/v4l2_videodevice.cpp
> b/src/libcamera/v4l2_videodevice.cpp
> index 634ac4a5..8e0afffe 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -39,6 +39,8 @@
>
>  namespace libcamera {
>
> +using namespace std::literals::chrono_literals;
> +
>  LOG_DECLARE_CATEGORY(V4L2)
>
>  /**
> @@ -520,7 +522,8 @@ const std::string V4L2DeviceFormat::toString() const
>   */
>  V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)
>         : V4L2Device(deviceNode), formatInfo_(nullptr), cache_(nullptr),
> -         fdBufferNotifier_(nullptr), state_(State::Stopped)
> +         fdBufferNotifier_(nullptr), state_(State::Stopped),
> +         watchdogDuration_(0ms)
>  {
>         /*
>          * We default to an MMAP based CAPTURE video device, however this
> will
> --
> 2.31.0
>
>
Laurent Pinchart April 6, 2022, 3:09 p.m. UTC | #2
Hi Umang,

Thank you for the patch.

On Wed, Apr 06, 2022 at 08:15:53PM +0530, Umang Jain wrote:
> Initialise the watchdogDuration_ member to 0ms before it is used
> in rest of the code base. Failing to do so, spews out log warnings
> regarding dequeue timer being expired.
> 
> Fixes: 16f3d2de50ff ("libcamera: v4l2_videodevice: Add a dequeue timer")
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  src/libcamera/v4l2_videodevice.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> index 634ac4a5..8e0afffe 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -39,6 +39,8 @@
>  
>  namespace libcamera {
>  
> +using namespace std::literals::chrono_literals;
> +
>  LOG_DECLARE_CATEGORY(V4L2)
>  
>  /**
> @@ -520,7 +522,8 @@ const std::string V4L2DeviceFormat::toString() const
>   */
>  V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)
>  	: V4L2Device(deviceNode), formatInfo_(nullptr), cache_(nullptr),
> -	  fdBufferNotifier_(nullptr), state_(State::Stopped)
> +	  fdBufferNotifier_(nullptr), state_(State::Stopped),
> +	  watchdogDuration_(0ms)

The duration is expressed in nanoseconds internally, but thanks to
chrono types, that doesn't matter :-)

I would write

	watchdogDuration_(0.0)

but that's not possible as the utils::Duration class is missing an
appropriate constructor. I'll fix this in a separate patch, but for
this,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  {
>  	/*
>  	 * We default to an MMAP based CAPTURE video device, however this will

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 634ac4a5..8e0afffe 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -39,6 +39,8 @@ 
 
 namespace libcamera {
 
+using namespace std::literals::chrono_literals;
+
 LOG_DECLARE_CATEGORY(V4L2)
 
 /**
@@ -520,7 +522,8 @@  const std::string V4L2DeviceFormat::toString() const
  */
 V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)
 	: V4L2Device(deviceNode), formatInfo_(nullptr), cache_(nullptr),
-	  fdBufferNotifier_(nullptr), state_(State::Stopped)
+	  fdBufferNotifier_(nullptr), state_(State::Stopped),
+	  watchdogDuration_(0ms)
 {
 	/*
 	 * We default to an MMAP based CAPTURE video device, however this will