Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow repeat REQBUF when buffers not mapped #599

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions v4l2loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -1581,8 +1581,13 @@ static int vidioc_reqbufs(struct file *file, void *fh,
return 0;
}

if (V4L2_TYPE_IS_OUTPUT(b->type) && (!dev->ready_for_output)) {
return -EBUSY;
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
if (!dev->ready_for_output)
return -EBUSY;
int i;
for (i = 0; i < dev->buffers_number; ++i)
if (dev->buffers[i].buffer.flags & V4L2_BUF_FLAG_MAPPED)
return -EBUSY;
}

init_buffers(dev);
Expand Down Expand Up @@ -1957,8 +1962,11 @@ static int vidioc_streamoff(struct file *file, void *fh,
opener = fh_to_opener(fh);
switch (type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
if (dev->ready_for_capture > 0)
dev->ready_for_capture--;
if (opener->type == WRITER) {
if (dev->ready_for_capture > 0)
dev->ready_for_capture--;
dev->ready_for_output = 1;
}
return 0;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (opener->type == READER) {
Expand Down