From 9988e1b6ee2d593c8efe5551de897c0c06d4f450 Mon Sep 17 00:00:00 2001 From: Todor Tomov Date: Tue, 4 Sep 2018 11:33:08 +0300 Subject: [PATCH] cap_v4l: Fix private control enumeration end condition Currently the private control enumeration will be stopped when QUERYCTRL returns -EINVAL only. It is possible however that other errors occur. One particular case is when the v4l2 device doesn't support any controls and doesn't implement the QUERYCTRL ioctl. In that case the v4l2 framework returns -ENOTTY. In that case the current control enumeration will go in an endless loop. To fix this change the control enumeration stop condition. If any errors occur, end the control enumeration. Signed-off-by: Todor Tomov --- modules/videoio/src/cap_v4l.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/videoio/src/cap_v4l.cpp b/modules/videoio/src/cap_v4l.cpp index 0416231f65..1650093e7f 100644 --- a/modules/videoio/src/cap_v4l.cpp +++ b/modules/videoio/src/cap_v4l.cpp @@ -512,9 +512,11 @@ static void v4l2_scan_controls(CvCaptureCAM_V4L* capture) for (ctrl_id = V4L2_CID_PRIVATE_BASE;;ctrl_id++) { + errno = 0; + v4l2_control_range(capture, ctrl_id); - if (errno == EINVAL) + if (errno) break; }