From 22b7aa164f89fba1798481fc589a78214c0b0633 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Tue, 25 Feb 2014 20:09:48 +0100 Subject: [PATCH] v4l2-ctl: skip captured buffers with flag V4L2_BUF_FLAG_ERROR These buffers contain invalid data, so just QBUF them again. Signed-off-by: Hans Verkuil --- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp index d920b28..ea62661 100644 --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -586,14 +586,19 @@ static int do_handle_cap(int fd, buffers &b, FILE *fout, int *index, buf.length = VIDEO_MAX_PLANES; } - ret = test_ioctl(fd, VIDIOC_DQBUF, &buf); - if (ret < 0 && errno == EAGAIN) - return 0; - if (ret < 0) { - fprintf(stderr, "%s: failed: %s\n", "VIDIOC_DQBUF", strerror(errno)); - return -1; + for (;;) { + ret = test_ioctl(fd, VIDIOC_DQBUF, &buf); + if (ret < 0 && errno == EAGAIN) + return 0; + if (ret < 0) { + fprintf(stderr, "%s: failed: %s\n", "VIDIOC_DQBUF", strerror(errno)); + return -1; + } + if (!(buf.flags & V4L2_BUF_FLAG_ERROR)) + break; + test_ioctl(fd, VIDIOC_QBUF, &buf); } - if (fout && (!stream_skip || ignore_count_skip)) { + if (fout && (!stream_skip || ignore_count_skip) && !(buf.flags & V4L2_BUF_FLAG_ERROR)) { for (unsigned j = 0; j < b.num_planes; j++) { unsigned used = b.is_mplane ? planes[j].bytesused : buf.bytesused; unsigned offset = b.is_mplane ? planes[j].data_offset : 0; -- 2.7.4