public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Michael J Gruber <mjg@fedoraproject.org>
To: git-commits@fedoraproject.org
Subject: [rpms/obs-studio] epel9: fix v4loopback usage
Date: Sat, 10 Oct 2026 20:01:32 GMT	[thread overview]
Message-ID: <179166249246.1.11564966719702198858.rpms-obs-studio-974938b48841@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/obs-studio
            Branch : epel9
            Commit : 974938b488411b06ddfb40635083a18757064406
            Author : Michael J Gruber <mjg@fedoraproject.org>
            Date   : 2025-04-02T11:27:38+02:00
            Stats  : +119/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/obs-studio/c/974938b488411b06ddfb40635083a18757064406?branch=epel9

            Log:
            fix v4loopback usage

obs-studio fails to start the virtual camera with v4l2loopback 0.14. The
reason is a fix in obs-studio for earlier failures to restart the
camera. With v4l2loopback 0.14, that fix is not only obsolete but keeps
obs-studio from opening the device at all.

The patch from the PR reenables the virtual camera.

---
diff --git a/52d57cf70ca70f55378112f6eeb5708fb7680a6b.patch b/52d57cf70ca70f55378112f6eeb5708fb7680a6b.patch
new file mode 100644
index 0000000..803b868
--- /dev/null
+++ b/52d57cf70ca70f55378112f6eeb5708fb7680a6b.patch
@@ -0,0 +1,112 @@
+From 52d57cf70ca70f55378112f6eeb5708fb7680a6b Mon Sep 17 00:00:00 2001
+From: stephematician <steph.fn.contact@proton.me>
+Date: Wed, 19 Mar 2025 13:59:21 +1100
+Subject: [PATCH] linux-v4l2: Fix virtual camera start failure
+
+Add function that tries to reset v4l2loopback output for module versions
+from 0.12.5 to 0.12.7. If successful, then set flag that STREAMON and
+STREAMOFF are necessary each time the device is opened/closed.
+---
+ plugins/linux-v4l2/v4l2-output.c | 57 ++++++++++++++++++++++++++++++--
+ 1 file changed, 54 insertions(+), 3 deletions(-)
+
+diff --git a/plugins/linux-v4l2/v4l2-output.c b/plugins/linux-v4l2/v4l2-output.c
+index 366fc474f69d4e..d5e4e0f6ad57fb 100644
+--- a/plugins/linux-v4l2/v4l2-output.c
++++ b/plugins/linux-v4l2/v4l2-output.c
+@@ -15,6 +15,7 @@ struct virtualcam_data {
+ 	obs_output_t *output;
+ 	int device;
+ 	uint32_t frame_size;
++	bool use_caps_workaround;
+ };
+ 
+ static const char *virtualcam_name(void *unused)
+@@ -110,11 +111,54 @@ static void *virtualcam_create(obs_data_t *settings, obs_output_t *output)
+ 	return vcam;
+ }
+ 
++bool try_reset_output_caps(const char *device)
++{
++	struct v4l2_capability capability;
++	struct v4l2_format format;
++	int fd;
++
++	blog(LOG_INFO, "Attempting to reset output capability of '%s'", device);
++
++	fd = open(device, O_RDWR);
++	if (fd < 0)
++		return false;
++
++	format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
++	if (ioctl(fd, VIDIOC_G_FMT, &format) < 0)
++		goto reset_fail_close_fd;
++
++	if (ioctl(fd, VIDIOC_S_FMT, &format) < 0)
++		goto reset_fail_close_fd;
++
++	if (ioctl(fd, VIDIOC_STREAMON, &format.type) < 0)
++		goto reset_fail_close_fd;
++
++	if (ioctl(fd, VIDIOC_STREAMOFF, &format.type) < 0)
++		goto reset_fail_close_fd;
++
++	close(fd);
++
++	fd = open(device, O_RDWR);
++	if (fd < 0)
++		return false;
++
++	if (ioctl(fd, VIDIOC_QUERYCAP, &capability) < 0)
++		goto reset_fail_close_fd;
++
++	close(fd);
++	return (capability.device_caps & V4L2_CAP_VIDEO_OUTPUT) != 0;
++
++reset_fail_close_fd:
++	close(fd);
++	return false;
++}
++
+ static bool try_connect(void *data, const char *device)
+ {
++	static bool use_caps_workaround = false;
+ 	struct virtualcam_data *vcam = (struct virtualcam_data *)data;
+-	struct v4l2_format format;
+ 	struct v4l2_capability capability;
++	struct v4l2_format format;
+ 	struct v4l2_streamparm parm;
+ 
+ 	uint32_t width = obs_output_get_width(vcam->output);
+@@ -130,6 +174,13 @@ static bool try_connect(void *data, const char *device)
+ 	if (ioctl(vcam->device, VIDIOC_QUERYCAP, &capability) < 0)
+ 		goto fail_close_device;
+ 
++	if (!use_caps_workaround && !(capability.device_caps & V4L2_CAP_VIDEO_OUTPUT)) {
++		if (!try_reset_output_caps(device))
++			goto fail_close_device;
++		use_caps_workaround = true;
++	}
++	vcam->use_caps_workaround = use_caps_workaround;
++
+ 	format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ 
+ 	if (ioctl(vcam->device, VIDIOC_G_FMT, &format) < 0)
+@@ -165,7 +216,7 @@ static bool try_connect(void *data, const char *device)
+ 	memset(&parm, 0, sizeof(parm));
+ 	parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ 
+-	if (ioctl(vcam->device, VIDIOC_STREAMON, &parm) < 0) {
++	if (vcam->use_caps_workaround && ioctl(vcam->device, VIDIOC_STREAMON, &parm.type) < 0) {
+ 		blog(LOG_ERROR, "Failed to start streaming on '%s' (%s)", device, strerror(errno));
+ 		goto fail_close_device;
+ 	}
+@@ -241,7 +292,7 @@ static void virtualcam_stop(void *data, uint64_t ts)
+ 	struct v4l2_streamparm parm = {0};
+ 	parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ 
+-	if (ioctl(vcam->device, VIDIOC_STREAMOFF, &parm) < 0) {
++	if (vcam->use_caps_workaround && ioctl(vcam->device, VIDIOC_STREAMOFF, &parm) < 0) {
+ 		blog(LOG_WARNING, "Failed to stop streaming on video device %d (%s)", vcam->device, strerror(errno));
+ 	}
+ 

diff --git a/obs-studio.spec b/obs-studio.spec
index cb724c7..516a8ba 100644
--- a/obs-studio.spec
+++ b/obs-studio.spec
@@ -34,7 +34,7 @@
 
 Name:           obs-studio
 Version:        31.0.2
-Release:        5%{?dist}
+Release:        6%{?dist}
 Summary:        Open Broadcaster Software Studio
 
 # OBS itself is GPL-2.0-or-later, while various plugin dependencies are of various other licenses
@@ -58,6 +58,9 @@ Patch0102:      0102-obs-ffmpeg-Add-initial-support-for-the-OpenH264-H.26.patch
 Patch0103:      0103-UI-Add-support-for-OpenH264-as-the-worst-case-fallba.patch
 
 Patch0104:      add_missing_include.patch
+## From: https://github.com/obsproject/obs-studio/pull/11906
+## https://github.com/obsproject/obs-studio/commit/52d57cf70ca70f55378112f6eeb5708fb7680a6b.patch
+Patch0105:      52d57cf70ca70f55378112f6eeb5708fb7680a6b.patch
 # Downstream Fedora patches
 ## Use fdk-aac by default
 Patch1001:      obs-studio-UI-use-fdk-aac-by-default.patch
@@ -360,6 +363,9 @@ appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/*.metainf
 
 
 %changelog
+* Tue Apr 01 2025 Michael J Gruber <mjg@fedoraproject.org> - 31.0.2-6
+- fix v4loopback usage
+
 * Fri Mar 28 2025 Jan Grulich <jgrulich@redhat.com> - 31.0.2-5
 - Rebuild (qt6)
 

                 reply	other threads:[~2026-10-10 20:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179166249246.1.11564966719702198858.rpms-obs-studio-974938b48841@fedoraproject.org \
    --to=mjg@fedoraproject.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox