<div dir="ltr"><div dir="ltr">Hi,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 5 May 2022 at 09:48, Naushir Patuck <<a href="mailto:naush@raspberrypi.com">naush@raspberrypi.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Only enable/reset the watchdog timer when there are buffers queued in the V4L2<br>
device. Otherwise, we may trigger spurious warnings when the watchdog times out<br>
even if there are no buffers queued in the device.<br>
<br>
Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br></blockquote><div><br></div><div>Gentle ping.  This needs one more R-B tag to get merged.</div><div><br></div><div>Regards,</div><div>Naush</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 src/libcamera/v4l2_videodevice.cpp | 22 +++++++++++++++-------<br>
 1 file changed, 15 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp<br>
index 5b4637b1a39e..430715afd554 100644<br>
--- a/src/libcamera/v4l2_videodevice.cpp<br>
+++ b/src/libcamera/v4l2_videodevice.cpp<br>
@@ -1662,8 +1662,11 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)<br>
                return ret;<br>
        }<br>
<br>
-       if (queuedBuffers_.empty())<br>
+       if (queuedBuffers_.empty()) {<br>
                fdBufferNotifier_->setEnabled(true);<br>
+               if (watchdogDuration_)<br>
+                       watchdog_.start(std::chrono::duration_cast<std::chrono::milliseconds>(watchdogDuration_));<br>
+       }<br>
<br>
        queuedBuffers_[buf.index] = buffer;<br>
<br>
@@ -1742,16 +1745,21 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()<br>
                return nullptr;<br>
        }<br>
<br>
-       if (watchdogDuration_.count())<br>
-               watchdog_.start(std::chrono::duration_cast<std::chrono::milliseconds>(watchdogDuration_));<br>
-<br>
        cache_->put(buf.index);<br>
<br>
        FrameBuffer *buffer = it->second;<br>
        queuedBuffers_.erase(it);<br>
<br>
-       if (queuedBuffers_.empty())<br>
+       if (queuedBuffers_.empty()) {<br>
                fdBufferNotifier_->setEnabled(false);<br>
+               watchdog_.stop();<br>
+       } else if (watchdogDuration_) {<br>
+               /*<br>
+                * Restart the watchdog timer if there are buffers still queued<br>
+                * in the device.<br>
+                */<br>
+               watchdog_.start(std::chrono::duration_cast<std::chrono::milliseconds>(watchdogDuration_));<br>
+       }<br>
<br>
        buffer->metadata_.status = buf.flags & V4L2_BUF_FLAG_ERROR<br>
                                 ? FrameMetadata::FrameError<br>
@@ -1847,7 +1855,7 @@ int V4L2VideoDevice::streamOn()<br>
        }<br>
<br>
        state_ = State::Streaming;<br>
-       if (watchdogDuration_.count())<br>
+       if (watchdogDuration_ && !queuedBuffers_.empty())<br>
                watchdog_.start(std::chrono::duration_cast<std::chrono::milliseconds>(watchdogDuration_));<br>
<br>
        return 0;<br>
@@ -1924,7 +1932,7 @@ void V4L2VideoDevice::setDequeueTimeout(utils::Duration timeout)<br>
        watchdogDuration_ = timeout;<br>
<br>
        watchdog_.stop();<br>
-       if (watchdogDuration_.count() && state_ == State::Streaming)<br>
+       if (watchdogDuration_ && state_ == State::Streaming && !queuedBuffers_.empty())<br>
                watchdog_.start(std::chrono::duration_cast<std::chrono::milliseconds>(timeout));<br>
 }<br>
<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div></div>