From: Damjan Jovanovic Subject: [PATCH 1/2] avicap32: verify v4l devices can capture before returning them Message-Id: Date: Tue, 23 Apr 2019 03:15:16 +0200 /dev/video* device nodes aren't all capture devices, and returning those that aren't results in devenum reporting them to applications, which will later fail when opening them with IMoniker::BindToObject(). avicap32 already tries to call VIDIOC_QUERYCAP to check whether it's dealing with a v4l device, but it does not check a successful result any further. Get it to verify the device supports the V4L2_CAP_VIDEO_CAPTURE flag, like we do in qcap/v4l.c. Signed-off-by: Damjan Jovanovic --- dlls/avicap32/avicap32_main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dlls/avicap32/avicap32_main.c b/dlls/avicap32/avicap32_main.c index 445656cbfe..1c4170e239 100644 --- a/dlls/avicap32/avicap32_main.c +++ b/dlls/avicap32/avicap32_main.c @@ -128,11 +128,18 @@ static BOOL query_video_device(int devnum, char *name, int namesize, char *versi memset(&caps, 0, sizeof(caps)); if (xioctl(fd, VIDIOC_QUERYCAP, &caps) != -1) { - lstrcpynA(name, (char *)caps.card, namesize); - snprintf(version, versionsize, "%s v%u.%u.%u", (char *)caps.driver, (caps.version >> 16) & 0xFF, + BOOL isCaptureDevice; + if (caps.capabilities & V4L2_CAP_DEVICE_CAPS) + isCaptureDevice = caps.device_caps & V4L2_CAP_VIDEO_CAPTURE; + else + isCaptureDevice = caps.capabilities & V4L2_CAP_VIDEO_CAPTURE; + if (isCaptureDevice) { + lstrcpynA(name, (char *)caps.card, namesize); + snprintf(version, versionsize, "%s v%u.%u.%u", (char *)caps.driver, (caps.version >> 16) & 0xFF, (caps.version >> 8) & 0xFF, caps.version & 0xFF); + } close(fd); - return TRUE; + return isCaptureDevice; } if (errno != EINVAL && errno != 515)