[{"id":19768,"web_url":"https://patchwork.libcamera.org/comment/19768/","msgid":"<20210922045656.GD4382@pyrite.rasen.tech>","date":"2021-09-22T04:56:56","subject":"Re: [libcamera-devel] [PATCH v2 3/3] test: gstreamer: Simplify\n\telements' ownerships","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Vedant,\n\nOn Tue, Sep 21, 2021 at 11:09:55PM +0530, Vedant Paranjape wrote:\n> In gstreamer, when elements are created, usually a floating [1]\n> reference is returned which simply means, there is no ownership\n> transfer (yet). Once can simply check for NULL and return through\n> an error path, without bothering to clean up. Hence, g_autoptr is\n> not much of help here.\n> \n> If the NULL checks have been passed successfully, elements are ready\n> to use. However, we must claim ownership/reference it before using\n> them via g_object_ref_sink().\n> \n> This patch build upon this principle and removes the g_autoptr\n> from gstreamer test base class (gstreamer_test.cpp) whereever\n> necessary to tide up the code.\n> \n> [1] https://gstreamer.freedesktop.org/documentation/additional/design/MT-refcounting.html?gi-language=c#refcounting1\n> \n> Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  test/gstreamer/gstreamer_test.cpp | 9 ++++-----\n>  1 file changed, 4 insertions(+), 5 deletions(-)\n> \n> diff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp\n> index 4171250584e6..227a5c37fbe1 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> -- \n> 2.25.1\n>","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 D7999BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Sep 2021 04:57:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A6D836918C;\n\tWed, 22 Sep 2021 06:57:05 +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 1A92C6012C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Sep 2021 06:57:04 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 56CAAF1;\n\tWed, 22 Sep 2021 06:57:02 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"AH3UR0qg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632286623;\n\tbh=uuGMpu0ajkYIKIpmqF1+XQw1jPmYiW5nTHEBG3Mce3s=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AH3UR0qgMV72LFyRSyyUH4UqAvy7MXaaUx3RYvNHNFsBJMEP+VOuFirNtMDjgV0/e\n\tIUhDkwU5imGIE1zpYUHBdpLtUeozcaIgGjjPFORogLq+qUKo+McJRQkRsa+PVNMbg4\n\tUEPCBUMtgbCv4Fv3wb9vhnafG9Pjap5AAl3qgJRY=","Date":"Wed, 22 Sep 2021 13:56:56 +0900","From":"paul.elder@ideasonboard.com","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<20210922045656.GD4382@pyrite.rasen.tech>","References":"<20210921173955.20408-1-vedantparanjape160201@gmail.com>\n\t<20210921173955.20408-3-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210921173955.20408-3-vedantparanjape160201@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2 3/3] test: gstreamer: Simplify\n\telements' ownerships","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>","Cc":"libcamera-devel@lists.libcamera.org,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]