{"id":2221,"url":"https://patchwork.libcamera.org/api/1.1/patches/2221/?format=json","web_url":"https://patchwork.libcamera.org/patch/2221/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20191025141327.2803-1-kieran.bingham@ideasonboard.com>","date":"2019-10-25T14:13:27","name":"[libcamera-devel] libcamera: v4l2_videodevice: Track streaming state","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"cac354b17461133ec340f88f253451b2b38be608","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":{"id":11,"url":"https://patchwork.libcamera.org/api/1.1/users/11/?format=json","username":"kbingham","first_name":"Kieran","last_name":"Bingham","email":"kieran.bingham@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/2221/mbox/","series":[{"id":549,"url":"https://patchwork.libcamera.org/api/1.1/series/549/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=549","date":"2019-10-25T14:13:27","name":"[libcamera-devel] libcamera: v4l2_videodevice: Track streaming state","version":1,"mbox":"https://patchwork.libcamera.org/series/549/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2221/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2221/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3294F61378\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Oct 2019 16:13:32 +0200 (CEST)","from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net\n\t[86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8421E33A;\n\tFri, 25 Oct 2019 16:13:31 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1572012811;\n\tbh=8aRG3VqWJyMocYHHYjy5Yk5xUgFS8XOIcNnu6whvxy4=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=FKoo6zQfB1zOIzzh9VXy8GqxL57E/p/fiWVqRGLXkysbmU0g+fsesSCXGcA14fYOy\n\t7bvgetiQgDVg579e9K5YlrFSMnaR3xiZdqVadH5AE3cE87AwT6VT20ynlA+UjS1AW3\n\tXJnD6piIA//Ow0saxvuVxBNSemWCFE13x+FSyibs=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Fri, 25 Oct 2019 15:13:27 +0100","Message-Id":"<20191025141327.2803-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] libcamera: v4l2_videodevice: Track\n\tstreaming state","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 25 Oct 2019 14:13:32 -0000"},"content":"Track the state of streamon/streamoff calls to simplify error paths.\n\nEnsuring that streamOff() can be called on non-streaming streams\nfacilitates simpler error code paths, where a set of devices can all\ncall streamOff regardless of their initialisation state.\n\nAcked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n\nSince RFC:\n - Rebased to master.\n\n src/libcamera/include/v4l2_videodevice.h |  2 ++\n src/libcamera/v4l2_videodevice.cpp       | 10 +++++++++-\n 2 files changed, 11 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\nindex 4b8cf9394eb9..caf36bf9c1aa 100644\n--- a/src/libcamera/include/v4l2_videodevice.h\n+++ b/src/libcamera/include/v4l2_videodevice.h\n@@ -187,6 +187,8 @@ private:\n \tstd::map<unsigned int, Buffer *> queuedBuffers_;\n \n \tEventNotifier *fdEvent_;\n+\n+\tbool streaming_;\n };\n \n class V4L2M2MDevice\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 208ab54199b1..c0b3a79f76da 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -272,7 +272,8 @@ const std::string V4L2DeviceFormat::toString() const\n  * \\param[in] deviceNode The file-system path to the video device node\n  */\n V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)\n-\t: V4L2Device(deviceNode), bufferPool_(nullptr), fdEvent_(nullptr)\n+\t: V4L2Device(deviceNode), bufferPool_(nullptr), fdEvent_(nullptr),\n+\t  streaming_(false)\n {\n \t/*\n \t * We default to an MMAP based CAPTURE video device, however this will\n@@ -1173,6 +1174,8 @@ int V4L2VideoDevice::streamOn()\n \t\treturn ret;\n \t}\n \n+\tstreaming_ = true;\n+\n \treturn 0;\n }\n \n@@ -1190,6 +1193,9 @@ int V4L2VideoDevice::streamOff()\n {\n \tint ret;\n \n+\tif (!streaming_)\n+\t\treturn 0;\n+\n \tret = ioctl(VIDIOC_STREAMOFF, &bufferType_);\n \tif (ret < 0) {\n \t\tLOG(V4L2, Error)\n@@ -1210,6 +1216,8 @@ int V4L2VideoDevice::streamOff()\n \tqueuedBuffers_.clear();\n \tfdEvent_->setEnabled(false);\n \n+\tstreaming_ = false;\n+\n \treturn 0;\n }\n \n","prefixes":["libcamera-devel"]}