Patch Detail
Show a patch.
GET /api/patches/13845/?format=api
{ "id": 13845, "url": "https://patchwork.libcamera.org/api/patches/13845/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13845/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20210914121700.122591-2-umang.jain@ideasonboard.com>", "date": "2021-09-14T12:16:59", "name": "[libcamera-devel,1/2] test: gstreamer: Simplify elements' ownerships", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "9b1338a0e203840b7cb173a475b8c1ba9017a44d", "submitter": { "id": 86, "url": "https://patchwork.libcamera.org/api/people/86/?format=api", "name": "Umang Jain", "email": "umang.jain@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13845/mbox/", "series": [ { "id": 2528, "url": "https://patchwork.libcamera.org/api/series/2528/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2528", "date": "2021-09-14T12:16:58", "name": "test: gstreamer: cleanup and memory leak fixes", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2528/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13845/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13845/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 4E337BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Sep 2021 12:17:19 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E16366918C;\n\tTue, 14 Sep 2021 14:17:18 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 01FDF60248\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Sep 2021 14:17:17 +0200 (CEST)", "from perceval.ideasonboard.com (unknown [103.251.226.94])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0667C2A5;\n\tTue, 14 Sep 2021 14:17:15 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"JYJw2/ID\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631621836;\n\tbh=i4/i/y8SjMu8QvP4lRXhBnH7iaL03Fvjt7U33rtEXgE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JYJw2/IDODwabrU3UudfKIP3STmi8PtZs0huj12+jnLNbAAjn/68T6VldJZ1wKSR8\n\t/w7B9p7CDUAlAIgNTukVHWNHRJAnqy0r+9zwQaBg6wXqW9/KAGQWxXYgzNmkCFYrd3\n\tMpQsKFQr8hiWBRse+faMPYHY0u/KP9NnItSL9OI0=", "From": "Umang Jain <umang.jain@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 14 Sep 2021 17:46:59 +0530", "Message-Id": "<20210914121700.122591-2-umang.jain@ideasonboard.com>", "X-Mailer": "git-send-email 2.31.1", "In-Reply-To": "<20210914121700.122591-1-umang.jain@ideasonboard.com>", "References": "<20210914121700.122591-1-umang.jain@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 1/2] test: gstreamer: Simplify elements'\n\townerships", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "In gstreamer, when elements are created, usually a floating [1]\nreference is returned which simply means, there is no ownership\ntransfer (yet). Once can simply check for NULL and return through\nan error path, without bothering to clean up. Hence, g_autoptr is\nnot much of help here.\n\nIf the NULL checks have been passed successfully, elements are ready\nto use. However, we must claim ownership/reference it before using\nthem via g_object_ref_sink().\n\nThis patch build upon this principle and removes the g_autoptr\nfrom gstreamer tests whereever necessary to tide up the code.\n\n[1] https://gstreamer.freedesktop.org/documentation/additional/design/MT-refcounting.html?gi-language=c#refcounting1\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n test/gstreamer/gstreamer_single_stream_test.cpp | 14 ++++++--------\n test/gstreamer/gstreamer_test.cpp | 9 ++++-----\n 2 files changed, 10 insertions(+), 13 deletions(-)", "diff": "diff --git a/test/gstreamer/gstreamer_single_stream_test.cpp b/test/gstreamer/gstreamer_single_stream_test.cpp\nindex 7292f328..d992455c 100644\n--- a/test/gstreamer/gstreamer_single_stream_test.cpp\n+++ b/test/gstreamer/gstreamer_single_stream_test.cpp\n@@ -33,20 +33,18 @@ protected:\n \t\tif (status_ != TestPass)\n \t\t\treturn status_;\n \n-\t\tg_autoptr(GstElement) convert0 = gst_element_factory_make(\"videoconvert\", \"convert0\");\n-\t\tg_autoptr(GstElement) sink0 = gst_element_factory_make(\"fakesink\", \"sink0\");\n-\t\tg_object_ref_sink(convert0);\n-\t\tg_object_ref_sink(sink0);\n+\t\tconvert0_ = gst_element_factory_make(\"videoconvert\", \"convert0\");\n+\t\tsink0_ = gst_element_factory_make(\"fakesink\", \"sink0\");\n \n-\t\tif (!convert0 || !sink0) {\n+\t\tif (!convert0_ || !sink0_) {\n \t\t\tg_printerr(\"Not all elements could be created. %p.%p\\n\",\n-\t\t\t\t convert0, sink0);\n+\t\t\t\t convert0_, sink0_);\n \n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tconvert0_ = reinterpret_cast<GstElement *>(g_steal_pointer(&convert0));\n-\t\tsink0_ = reinterpret_cast<GstElement *>(g_steal_pointer(&sink0));\n+\t\tg_object_ref_sink(convert0_);\n+\t\tg_object_ref_sink(sink0_);\n \n \t\tif (createPipeline() != TestPass)\n \t\t\treturn TestFail;\ndiff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp\nindex 41712505..227a5c37 100644\n--- a/test/gstreamer/gstreamer_test.cpp\n+++ b/test/gstreamer/gstreamer_test.cpp\n@@ -78,18 +78,17 @@ GstreamerTest::~GstreamerTest()\n \n int GstreamerTest::createPipeline()\n {\n-\tg_autoptr(GstElement) libcameraSrc = gst_element_factory_make(\"libcamerasrc\", \"libcamera\");\n+\tlibcameraSrc_ = gst_element_factory_make(\"libcamerasrc\", \"libcamera\");\n \tpipeline_ = gst_pipeline_new(\"test-pipeline\");\n-\tg_object_ref_sink(libcameraSrc);\n \n-\tif (!libcameraSrc || !pipeline_) {\n+\tif (!libcameraSrc_ || !pipeline_) {\n \t\tg_printerr(\"Unable to create create pipeline %p.%p\\n\",\n-\t\t\t libcameraSrc, pipeline_);\n+\t\t\t libcameraSrc_, pipeline_);\n \n \t\treturn TestFail;\n \t}\n \n-\tlibcameraSrc_ = reinterpret_cast<GstElement *>(g_steal_pointer(&libcameraSrc));\n+\tg_object_ref_sink(libcameraSrc_);\n \n \treturn TestPass;\n }\n", "prefixes": [ "libcamera-devel", "1/2" ] }