Patch Detail
Show a patch.
GET /api/1.1/patches/3032/?format=api
{ "id": 3032, "url": "https://patchwork.libcamera.org/api/1.1/patches/3032/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3032/", "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": "<20200306202637.525587-27-nicolas@ndufresne.ca>", "date": "2020-03-06T20:26:36", "name": "[libcamera-devel,v3,26/27] gst: libcamerasrc: Prevent src task deadlock on exhausted buffer pool", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "fa6d5573afbe3bf349226413e0c2c26a189f14c7", "submitter": { "id": 30, "url": "https://patchwork.libcamera.org/api/1.1/people/30/?format=api", "name": "Nicolas Dufresne", "email": "nicolas@ndufresne.ca" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3032/mbox/", "series": [ { "id": 705, "url": "https://patchwork.libcamera.org/api/1.1/series/705/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=705", "date": "2020-03-06T20:26:10", "name": "GStreamer Element for libcamera", "version": 3, "mbox": "https://patchwork.libcamera.org/series/705/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3032/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3032/checks/", "tags": {}, "headers": { "Return-Path": "<nicolas@ndufresne.ca>", "Received": [ "from bhuna.collabora.co.uk (bhuna.collabora.co.uk\n\t[IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F7E0628B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 6 Mar 2020 21:27:13 +0100 (CET)", "from nicolas-tpx395.localdomain (unknown [IPv6:2610:98:8005::527])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits))\n\t(No client certificate requested) (Authenticated sender: nicolas)\n\tby bhuna.collabora.co.uk (Postfix) with ESMTPSA id 008E52970E7;\n\tFri, 6 Mar 2020 20:27:12 +0000 (GMT)" ], "From": "Nicolas Dufresne <nicolas@ndufresne.ca>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Jakub Adam <jakub.adam@collabora.com>", "Date": "Fri, 6 Mar 2020 15:26:36 -0500", "Message-Id": "<20200306202637.525587-27-nicolas@ndufresne.ca>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200306202637.525587-1-nicolas@ndufresne.ca>", "References": "<20200306202637.525587-1-nicolas@ndufresne.ca>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 26/27] gst: libcamerasrc: Prevent src\n\ttask deadlock on exhausted buffer pool", "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, 06 Mar 2020 20:27:13 -0000" }, "content": "From: Jakub Adam <jakub.adam@collabora.com>\n\nAllow GstLibcameraPool to notify the source when a new buffer has become\navailable in a previously exhausted buffer pool. This can be used to\nresume a src task that got paused because it couldn't acquire a buffer.\n\nWithout this change the src task will never resume from pause once the\npool gets exhausted.\n\nTo trigger the deadlock (it doesn't happen every time), run:\n\n gst-launch-1.0 libcamerasrc ! queue ! glimagesink\n\nSigned-off-by: Jakub Adam <jakub.adam@collabora.com>\n---\n src/gstreamer/gstlibcamerapool.cpp | 17 +++++++++++++++++\n src/gstreamer/gstlibcamerasrc.cpp | 5 ++++-\n 2 files changed, 21 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/gstreamer/gstlibcamerapool.cpp b/src/gstreamer/gstlibcamerapool.cpp\nindex 3868905..8f53616 100644\n--- a/src/gstreamer/gstlibcamerapool.cpp\n+++ b/src/gstreamer/gstlibcamerapool.cpp\n@@ -14,6 +14,13 @@\n \n using namespace libcamera;\n \n+enum {\n+\tSIGNAL_BUFFER_NOTIFY,\n+\tN_SIGNALS\n+};\n+\n+static guint signals[N_SIGNALS];\n+\n struct _GstLibcameraPool {\n \tGstBufferPool parent;\n \n@@ -55,7 +62,12 @@ static void\n gst_libcamera_pool_release_buffer(GstBufferPool *pool, GstBuffer *buffer)\n {\n \tGstLibcameraPool *self = GST_LIBCAMERA_POOL(pool);\n+\tbool do_notify = gst_atomic_queue_length(self->queue) == 0;\n+\n \tgst_atomic_queue_push(self->queue, buffer);\n+\n+\tif (do_notify)\n+\t\tg_signal_emit(self, signals[SIGNAL_BUFFER_NOTIFY], 0);\n }\n \n static void\n@@ -90,6 +102,11 @@ gst_libcamera_pool_class_init(GstLibcameraPoolClass *klass)\n \tpool_class->acquire_buffer = gst_libcamera_pool_acquire_buffer;\n \tpool_class->reset_buffer = gst_libcamera_pool_reset_buffer;\n \tpool_class->release_buffer = gst_libcamera_pool_release_buffer;\n+\n+\tsignals[SIGNAL_BUFFER_NOTIFY] = g_signal_new(\"buffer-notify\",\n+\t\t\t\t\t\t G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST,\n+\t\t\t\t\t\t 0, nullptr, nullptr, nullptr,\n+\t\t\t\t\t\t G_TYPE_NONE, 0);\n }\n \n GstLibcameraPool *\ndiff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 22d9175..9755922 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -439,6 +439,9 @@ gst_libcamera_src_task_enter(GstTask *task, GThread *thread, gpointer user_data)\n \t\tconst StreamConfiguration &stream_cfg = state->config_->at(i);\n \t\tGstLibcameraPool *pool = gst_libcamera_pool_new(self->allocator,\n \t\t\t\t\t\t\t\tstream_cfg.stream());\n+\t\tg_signal_connect_swapped(pool, \"buffer-notify\",\n+\t\t\t\t\t G_CALLBACK(gst_libcamera_resume_task), task);\n+\n \t\tgst_libcamera_pad_set_pool(srcpad, pool);\n \t\tgst_flow_combiner_add_pad(self->flow_combiner, srcpad);\n \t}\n@@ -474,7 +477,7 @@ gst_libcamera_src_task_leave(GstTask *task, GThread *thread, gpointer user_data)\n \tstate->cam_->stop();\n \n \tfor (GstPad *srcpad : state->srcpads_)\n-\t\tgst_libcamera_pad_set_pool(srcpad, NULL);\n+\t\tgst_libcamera_pad_set_pool(srcpad, nullptr);\n \n \tg_clear_object(&self->allocator);\n \tg_clear_pointer(&self->flow_combiner,\n", "prefixes": [ "libcamera-devel", "v3", "26/27" ] }