Skip to content

Commit

Permalink
Properly query video device pixel format
Browse files Browse the repository at this point in the history
The `ioctl` to query `VIDIOC_G_FMT` was previously unchecked and always failed due to a missing initialization of the structure passed.
  • Loading branch information
BenBE committed Jan 22, 2022
1 parent e3d1c22 commit 56d94fd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion videoio/loopback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ int loopback_init(const std::string& device, int w, int h, int debug) {
}

memset(&vid_format, 0, sizeof(vid_format));
//usleep(100000);
vid_format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;

ret_code = ioctl(fdwr, VIDIOC_G_FMT, &vid_format);
if(ret_code < 0) {
fprintf(stderr, "%s:%d(%s): Failed to get device video format: %s\n", __FILE__, __LINE__, __func__, strerror(errno));
close(fdwr);
return -1;
}

vid_format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
vid_format.fmt.pix.width = w;
Expand Down

0 comments on commit 56d94fd

Please sign in to comment.