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

Fix likely REQBUFS failure when memory still mapped #52

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

stephematician
Copy link
Contributor

According to 7.52 ioctl - VIDIOC_REQBUFS:

Applications can call ioctl VIDIOC_REQBUFS again to change the number of buffers. Note that if any buffers are still mapped or exported via DMABUF, then ioctl VIDIOC_REQBUFS can only succeed if the V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS capability is set. Otherwise ioctl VIDIOC_REQBUFS will return the EBUSY error code.

Because many devices, e.g. v4l2loopback in particular, don't support V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS it's better to ensure that the mmap buffers are closed before invoking VIDIOC_REQBUF.

This PR should correctly call munmap() first if using cpython. I haven't tested with other python implementations.

Side note: v4l2loopback (in particular 0.13.x) has issues with denying REQBUFS even when it shouldn't - I'm just now working on a fix for that, too (see umlaeute/v4l2loopback#599).

explicitly close the mmap buffers before invoke VIDIOC_REQBUF
@tiagocoutinho
Copy link
Owner

Awesome! Thanks for the fix.
Also thanks for commenting on https://unix.stackexchange.com/questions/779821/open-v4l2loopback-device-with-o-nonblock ;-)

@tiagocoutinho tiagocoutinho reopened this Oct 22, 2024
@tiagocoutinho tiagocoutinho merged commit d223fa2 into tiagocoutinho:master Oct 22, 2024
0 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants