-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
linux-v4l2: Fix virtual camera start failure #11906
base: master
Are you sure you want to change the base?
Conversation
For clarification, is there a reason to hold on to the old behavior for older versions? If the issue is stricter requirements on the v4l2loopback side, wouldn't this just be a backwards compatible change? What breaks in the old versions with this change, or is that untested and just an attempt to not change what has been working? |
The existing behaviour should be kept when using loopback <= 0.13.2, otherwise there'll be regression to #4808 An alternative solution: Simply ignore any errors from STREAMON or STREAMOFF. In a way; this would be cleaner - but there is a relatively harmless issue where, say, a user has an older loopback module and STREAMON fails for a legitimate reason. In that case - presumably the next call to |
I just remembered I forgot to close the file pointer. Such a noob mistake! |
I'm mostly just confused by the presentation of what this is actually fixing. It sounds like this is actually resulting from what was a bug in v4l2loopback, and we had previously put a workaround in place for, and now that bug is fixed (in the name of better compliance, presumably) and the workaround is now causing issues. |
Yes. Sorry, I should have answered your quetion. That is exactly the issue.
Happy to change approach with this PR if needed. |
I'll leave the technical specifics to others to comment on, we were just a bit confused on the context around this. Makes perfect sense now, thanks! |
I can relate. It took me a ridiculously long time to get my head about the loopback module as I was updating it. Thanks for your questions! |
FWIW: the "simpler" fix would be to treat the failed STREAMON (or STREAMOFF) as an info/warning message and not an error; e.g. in if (ioctl(vcam->device, VIDIOC_STREAMON, &parm) < 0) {
- blog(LOG_ERROR, "Failed to start streaming on '%s' (%s)", device, strerror(errno));
- goto fail_close_device;
+ if (errno == -EINVAL) {
+ blog(LOG_INFO, "EINVAL returned from loopback STREAMON, likely an error in loopback version <= 0.13.2");
+ } else {
+ blog(LOG_ERROR, "Failed to start streaming on '%s' (%s)", device, strerror(errno));
+ goto fail_close_device;
+ }
}
blog(LOG_INFO, "Virtual camera started"); |
9b2e9c0
to
770881a
Compare
Somewhat tidied up; also noticed that the dimensions (and pixel format) returned by S_FMT were being ignored; which can lead to unexpected behaviour if the (virtual) device chooses a different size (or pixel format) to the request. So that's fixed now, too. |
Skip the non-compliant usage of STREAMON ioctl when loopback module version is newer than 0.13.2
S_FMT can succeed even if it does not set the pixel format and dimensions to the requested value. Use the return value to check that the pixel format was set, and use the returned dimensions for conversion.
770881a
to
059f980
Compare
Skip the non-compliant usage of STREAMON ioctl when loopback module version is newer than 0.13.2
Description
When starting (or stopping) the virtual camera:
/sys/modules/v4l2loopback/version
;Motivation and Context
Fixes #11891 (thanks to the release of v4l2loopback 0.14.0).
v4l2loopback source was recently updated to have stronger compliance with V4L2 UAPI; thus, the invocation of STREAMON by OBS when no streaming I/O buffers have been negotiated (e.g. via REQBUFS) results in an error. If a user has the newer v4l2loopback, then OBS needs to skip the old STREAMON kludge (see #4808 and fca624e). If the user has the older v4l2loopback (version 0.13.2 or earlier); then the existing behaviour should be maintained.
How Has This Been Tested?
Built on Ubuntu 24.04, x64 machine, with the v4l2loopback source:
Types of changes
Checklist: