69 lines
1.7 KiB
Diff
69 lines
1.7 KiB
Diff
From 40a880b4640486262ca0b5171dec88d633278366 Mon Sep 17 00:00:00 2001
|
|
From: Rodrigo Oliveira <mdkcore@qtrnn.io>
|
|
Date: Thu, 20 Oct 2022 18:44:11 -0300
|
|
Subject: [PATCH 2/2] Backport PR #485 [1]
|
|
|
|
[1] https://github.com/umlaeute/v4l2loopback/pull/485
|
|
---
|
|
v4l2loopback.c | 22 +++++++++++++++++++---
|
|
1 file changed, 19 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/v4l2loopback.c b/v4l2loopback.c
|
|
index 22e9795..1be694c 100644
|
|
--- a/v4l2loopback.c
|
|
+++ b/v4l2loopback.c
|
|
@@ -1730,19 +1730,19 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
|
|
|
switch (type) {
|
|
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
|
|
- opener->type = WRITER;
|
|
- dev->ready_for_output = 0;
|
|
if (!dev->ready_for_capture) {
|
|
int ret = allocate_buffers(dev);
|
|
if (ret < 0)
|
|
return ret;
|
|
+ opener->type = WRITER;
|
|
+ dev->ready_for_output = 0;
|
|
dev->ready_for_capture = 1;
|
|
}
|
|
return 0;
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
|
- opener->type = READER;
|
|
if (!dev->ready_for_capture)
|
|
return -EIO;
|
|
+ opener->type = READER;
|
|
return 0;
|
|
default:
|
|
return -EINVAL;
|
|
@@ -2042,11 +2042,27 @@ static ssize_t v4l2_loopback_write(struct file *file, const char __user *buf,
|
|
struct v4l2_loopback_device *dev;
|
|
int write_index;
|
|
struct v4l2_buffer *b;
|
|
+ int err = 0;
|
|
+
|
|
MARK();
|
|
|
|
dev = v4l2loopback_getdevice(file);
|
|
opener = fh_to_opener(file->private_data);
|
|
|
|
+ if (UNNEGOTIATED == opener->type) {
|
|
+ spin_lock(&dev->lock);
|
|
+
|
|
+ if (dev->ready_for_output) {
|
|
+ err = vidioc_streamon(file, file->private_data, V4L2_BUF_TYPE_VIDEO_OUTPUT);
|
|
+ }
|
|
+
|
|
+ spin_unlock(&dev->lock);
|
|
+
|
|
+ if (err < 0)
|
|
+ return err;
|
|
+ }
|
|
+
|
|
+
|
|
if (WRITER != opener->type)
|
|
return -EINVAL;
|
|
|
|
--
|
|
2.38.1
|
|
|