{"id":10849,"url":"https://patchwork.libcamera.org/api/patches/10849/?format=json","web_url":"https://patchwork.libcamera.org/patch/10849/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20210112045140.10979-2-email@uajain.com>","date":"2021-01-12T04:51:39","name":"[libcamera-devel,v2,1/2] libcamera: v4l2_videodevice: Track streaming state","commit_ref":"c0bad607ce16ea66aa9c4de892598793402281c6","pull_url":null,"state":"accepted","archived":false,"hash":"ea7914dce356763ad91a53acf3573826b58a3f2f","submitter":{"id":1,"url":"https://patchwork.libcamera.org/api/people/1/?format=json","name":"Umang Jain","email":"email@uajain.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/10849/mbox/","series":[{"id":1575,"url":"https://patchwork.libcamera.org/api/series/1575/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1575","date":"2021-01-12T04:51:38","name":"Simplify error paths","version":2,"mbox":"https://patchwork.libcamera.org/series/1575/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10849/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10849/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 05E90BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 Jan 2021 04:51:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C2ABD680C8;\n\tTue, 12 Jan 2021 05:51:49 +0100 (CET)","from mail.uajain.com (static.126.159.217.95.clients.your-server.de\n\t[95.217.159.126])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D0C860523\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Jan 2021 05:51:48 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"iLr+3Wl6\"; dkim-atps=neutral","From":"Umang Jain <email@uajain.com>","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail;\n\tt=1610427107; bh=UWgzg2JrMvee+s7TpRi3IE6dUgfl0XwSoy7hTz45BPM=;\n\th=From:To:Cc:Subject:In-Reply-To:References;\n\tb=iLr+3Wl647mP/+AcqFqrkJJkfYvbzgTlwSSH9G5y2Kw7OgkLr1MyHd64RCGTWHU3N\n\tra6daNwjqnNNWZ3M10OAkDpNrD9c+92ByCgV6HU18Yl9MDrat5whgvgFc2fkdSsl54\n\t0OrfzB5XP+HZEVpJ/L1PvobFI2vXwH8kJTe+IkW2p8Et/P5o1Q2YOJkn/G56KrP+jN\n\txqzpZBVarPzWBLOl9ooJrplfuW8mvdRnkMhdow9qIduj2/seCeZVfHpO2XFPJzsQhD\n\tV1TkC0+eyftM9K/Qv3Xy3SsAXaZx4ZYJ/vmdxYvzndKLMGjMfdfaRNklXLBPb+pTvy\n\tIEtkds2u3tZlw==","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 12 Jan 2021 10:21:39 +0530","Message-Id":"<20210112045140.10979-2-email@uajain.com>","In-Reply-To":"<20210112045140.10979-1-email@uajain.com>","References":"<20210112045140.10979-1-email@uajain.com>","Mime-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 1/2] 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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nTrack 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\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Umang Jain <email@uajain.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_videodevice.h |  2 ++\n src/libcamera/v4l2_videodevice.cpp            | 12 +++++++++++-\n 2 files changed, 13 insertions(+), 1 deletion(-)","diff":"diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 529ca0e3..626dfbcd 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -249,6 +249,8 @@ private:\n \tstd::map<unsigned int, FrameBuffer *> queuedBuffers_;\n \n \tEventNotifier *fdBufferNotifier_;\n+\n+\tbool streaming_;\n };\n \n class V4L2M2MDevice\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex baf683d6..a9509bff 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -481,7 +481,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), cache_(nullptr), fdBufferNotifier_(nullptr)\n+\t: V4L2Device(deviceNode), cache_(nullptr), fdBufferNotifier_(nullptr),\n+\t  streaming_(false)\n {\n \t/*\n \t * We default to an MMAP based CAPTURE video device, however this will\n@@ -1554,6 +1555,8 @@ int V4L2VideoDevice::streamOn()\n \t\treturn ret;\n \t}\n \n+\tstreaming_ = true;\n+\n \treturn 0;\n }\n \n@@ -1565,12 +1568,18 @@ int V4L2VideoDevice::streamOn()\n  * and the bufferReady signal is emitted for them. The order in which those\n  * buffers are dequeued is not specified.\n  *\n+ * This will be a no-op if the stream is not started in the first place and\n+ * has no queued buffers.\n+ *\n  * \\return 0 on success or a negative error code otherwise\n  */\n int V4L2VideoDevice::streamOff()\n {\n \tint ret;\n \n+\tif (!streaming_ && queuedBuffers_.empty())\n+\t\treturn 0;\n+\n \tret = ioctl(VIDIOC_STREAMOFF, &bufferType_);\n \tif (ret < 0) {\n \t\tLOG(V4L2, Error)\n@@ -1588,6 +1597,7 @@ int V4L2VideoDevice::streamOff()\n \n \tqueuedBuffers_.clear();\n \tfdBufferNotifier_->setEnabled(false);\n+\tstreaming_ = false;\n \n \treturn 0;\n }\n","prefixes":["libcamera-devel","v2","1/2"]}