Show a patch.

GET /api/1.1/patches/16447/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 16447,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16447/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16447/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20220630000251.31295-11-laurent.pinchart@ideasonboard.com>",
    "date": "2022-06-30T00:02:49",
    "name": "[libcamera-devel,v2,10/12] gstreamer: Split request creation to a separate function",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "ef248638207207b45c91fac598d7d2bae4b94474",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16447/mbox/",
    "series": [
        {
            "id": 3234,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3234/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3234",
            "date": "2022-06-30T00:02:39",
            "name": "gstreamer: Queue multiple requests",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3234/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16447/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16447/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 18C22BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jun 2022 00:03:35 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 84A9C65651;\n\tThu, 30 Jun 2022 02:03:34 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B4B1065631\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jun 2022 02:03:19 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 47D3759D;\n\tThu, 30 Jun 2022 02:03:19 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656547414;\n\tbh=Ae/27g0zHudhp25ye9Tl3b34HDNP1IjxR/EQ3EbRSb0=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=De4XnUtZUjbbq3k/NVIwJbNwaOntzyFZ9sqio3tNP8NmUFZ07AzLKnuz5MK2tODx1\n\tdrhMaLu5IAi2u8WZgX0dj5f0GGmzt6+s9XjZdmFJT2hcAKJIr0qaJikralZcJcoizk\n\tKW1EQGjAl6+Lk73EIfEsosJfxviIHK/DEEpJHJ6v4P9IHjW1/lmilF61P6xHUlsitK\n\tYjBMfEnbY87j+yI3m4y+NjpK+onwQr8RJ0OTdi7Ig/eWLvK7aQyJ4hvV2BA3bNJo/0\n\t5VYX8Lkrt42O4rnuyMBRkShXJSpNmhlZ4i4DXjC71os7BuAoLZxTKq00MUkT60uTKA\n\tViGMyFjJvLhMA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656547399;\n\tbh=Ae/27g0zHudhp25ye9Tl3b34HDNP1IjxR/EQ3EbRSb0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=BpR8cO1QjgzxD2twPLbLVUMgw/Z3QjUk/k5qE/5lcEb/trD/X6i+vCPq9Yi7rMRf1\n\tM9PMzl49DlMFxvlAKvMtGVNKprF8vR/AncO+VZOiVtfSVcXoq7cRu1SOM3LW3RczsU\n\tKXH5MXkGrPigNLqnP4CyB8m8BWPWurPJ6tqvJtpY="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"BpR8cO1Q\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 30 Jun 2022 03:02:49 +0300",
        "Message-Id": "<20220630000251.31295-11-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "In-Reply-To": "<20220630000251.31295-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20220630000251.31295-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 10/12] gstreamer: Split request\n\tcreation to a separate function",
        "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>",
        "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Cc": "Nicolas Dufresne <nicolas.dufresne@collabora.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "In order to prepare for creation and queuing of multiple requests, move\nthe request creation and queueing code to a separate function. No\nfunctional change intended.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n---\nChanges since v1:\n\n- Add comment about locking requirement\n- Add a scope around the locker\n---\n src/gstreamer/gstlibcamerasrc.cpp | 79 ++++++++++++++++++-------------\n 1 file changed, 45 insertions(+), 34 deletions(-)",
    "diff": "diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex c92ca7d29fe6..d63083d0cd8f 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -133,6 +133,7 @@ struct GstLibcameraSrcState {\n \n \tguint group_id_;\n \n+\tint queueRequest();\n \tvoid requestCompleted(Request *request);\n };\n \n@@ -170,6 +171,47 @@ GstStaticPadTemplate request_src_template = {\n \t\"src_%u\", GST_PAD_SRC, GST_PAD_REQUEST, TEMPLATE_CAPS\n };\n \n+/* Must be called with stream_lock held. */\n+int GstLibcameraSrcState::queueRequest()\n+{\n+\tstd::unique_ptr<Request> request = cam_->createRequest();\n+\tif (!request)\n+\t\treturn -ENOMEM;\n+\n+\tstd::unique_ptr<RequestWrap> wrap =\n+\t\tstd::make_unique<RequestWrap>(std::move(request));\n+\n+\tfor (GstPad *srcpad : srcpads_) {\n+\t\tStream *stream = gst_libcamera_pad_get_stream(srcpad);\n+\t\tGstLibcameraPool *pool = gst_libcamera_pad_get_pool(srcpad);\n+\t\tGstBuffer *buffer;\n+\t\tGstFlowReturn ret;\n+\n+\t\tret = gst_buffer_pool_acquire_buffer(GST_BUFFER_POOL(pool),\n+\t\t\t\t\t\t     &buffer, nullptr);\n+\t\tif (ret != GST_FLOW_OK) {\n+\t\t\t/*\n+\t\t\t * RequestWrap has ownership of the request, and we\n+\t\t\t * won't be queueing this one due to lack of buffers.\n+\t\t\t */\n+\t\t\treturn -ENOBUFS;\n+\t\t}\n+\n+\t\twrap->attachBuffer(stream, buffer);\n+\t}\n+\n+\tGST_TRACE_OBJECT(src_, \"Requesting buffers\");\n+\tcam_->queueRequest(wrap->request_.get());\n+\n+\t{\n+\t\tMutexLocker locker(lock_);\n+\t\tqueuedRequests_.push(std::move(wrap));\n+\t}\n+\n+\t/* The RequestWrap will be deleted in the completion handler. */\n+\treturn 0;\n+}\n+\n void\n GstLibcameraSrcState::requestCompleted(Request *request)\n {\n@@ -279,8 +321,8 @@ gst_libcamera_src_task_run(gpointer user_data)\n \tGstLibcameraSrc *self = GST_LIBCAMERA_SRC(user_data);\n \tGstLibcameraSrcState *state = self->state;\n \n-\tstd::unique_ptr<Request> request = state->cam_->createRequest();\n-\tif (!request) {\n+\tint err = state->queueRequest();\n+\tif (err == -ENOMEM) {\n \t\tGST_ELEMENT_ERROR(self, RESOURCE, NO_SPACE_LEFT,\n \t\t\t\t  (\"Failed to allocate request for camera '%s'.\",\n \t\t\t\t   state->cam_->id().c_str()),\n@@ -289,38 +331,7 @@ gst_libcamera_src_task_run(gpointer user_data)\n \t\treturn;\n \t}\n \n-\tstd::unique_ptr<RequestWrap> wrap =\n-\t\tstd::make_unique<RequestWrap>(std::move(request));\n-\n-\tfor (GstPad *srcpad : state->srcpads_) {\n-\t\tStream *stream = gst_libcamera_pad_get_stream(srcpad);\n-\t\tGstLibcameraPool *pool = gst_libcamera_pad_get_pool(srcpad);\n-\t\tGstBuffer *buffer;\n-\t\tGstFlowReturn ret;\n-\n-\t\tret = gst_buffer_pool_acquire_buffer(GST_BUFFER_POOL(pool),\n-\t\t\t\t\t\t     &buffer, nullptr);\n-\t\tif (ret != GST_FLOW_OK) {\n-\t\t\t/*\n-\t\t\t * RequestWrap has ownership of the request, and we\n-\t\t\t * won't be queueing this one due to lack of buffers.\n-\t\t\t */\n-\t\t\twrap.release();\n-\t\t\tbreak;\n-\t\t}\n-\n-\t\twrap->attachBuffer(stream, buffer);\n-\t}\n-\n-\tif (wrap) {\n-\t\tGST_TRACE_OBJECT(self, \"Requesting buffers\");\n-\t\tstate->cam_->queueRequest(wrap->request_.get());\n-\n-\t\tMutexLocker locker(state->lock_);\n-\t\tstate->queuedRequests_.push(std::move(wrap));\n-\n-\t\t/* The RequestWrap will be deleted in the completion handler. */\n-\t}\n+\tstd::unique_ptr<RequestWrap> wrap;\n \n \t{\n \t\tMutexLocker locker(state->lock_);\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "10/12"
    ]
}