{"id":13877,"url":"https://patchwork.libcamera.org/api/patches/13877/?format=json","web_url":"https://patchwork.libcamera.org/patch/13877/","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":"<20210921115610.366553-3-vedantparanjape160201@gmail.com>","date":"2021-09-21T11:56:10","name":"[libcamera-devel,v1,3/3] test: gstreamer: Simplify elements' ownerships","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"ba22fd5d444b258337d3830b653f7bbd48c873ed","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/?format=json","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13877/mbox/","series":[{"id":2540,"url":"https://patchwork.libcamera.org/api/series/2540/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2540","date":"2021-09-21T11:56:08","name":"[libcamera-devel,v1,1/3] test: gstreamer_single_stream_test: Fix memory leak","version":1,"mbox":"https://patchwork.libcamera.org/series/2540/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13877/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13877/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 59AE0BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Sep 2021 11:56:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 28C356918A;\n\tTue, 21 Sep 2021 13:56:35 +0200 (CEST)","from mail-pf1-x430.google.com (mail-pf1-x430.google.com\n\t[IPv6:2607:f8b0:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9348460247\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Sep 2021 13:56:33 +0200 (CEST)","by mail-pf1-x430.google.com with SMTP id j6so19242338pfa.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Sep 2021 04:56:33 -0700 (PDT)","from localhost.localdomain ([1.186.167.167])\n\tby smtp.googlemail.com with ESMTPSA id\n\ty5sm16654906pfb.207.2021.09.21.04.56.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 21 Sep 2021 04:56:31 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Gxh3cDRz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=+Ae9N/Ehz4QT7RYpuRU7NvHlnRTxJlESW1W2mEkgbGg=;\n\tb=Gxh3cDRzTS6c+x+/pZrfGJQq47uxBfZJG8s++5YJEa8itNHUknO4Z9srQj626IxR2W\n\tFdBvutdW7gZn1kKk/q6jGeqgNddREnVQQcYqZOsyz5/Y139Tw5Waya4uRdf8w2ejOQHt\n\tblxqCzI86L5h3EuSrwq2UmLFIdAcL/cZuiTUAB6K2ENm5bWPKcWEYNwcVUm7fqOxcRqQ\n\tkcI5HyfxGOf1kpBYlDNhRG4PWKyQ4zUBPNlTr0bna135bYvM7UHMLHdkJW3ttEEOQ0iS\n\tA7KAPoSStogs0FGzjjEaXMwVjHwmkXQUVolAb8PCugXIsZ8qUWwP6s/xinyWMac5yo0D\n\t4K6w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=+Ae9N/Ehz4QT7RYpuRU7NvHlnRTxJlESW1W2mEkgbGg=;\n\tb=fTRS1pkFqy7+GEcovU8jT59rV5hBq72Xrs+wdTIqL65O6Jw6r0mj17n9f6i+P4ZpnD\n\tNCZE08AbyNs9gXsoYbfiTR+pon3vehJdVDCz1YKNuWbdFnPS12Rm6+ta7uMKRo0ST1jV\n\tVPvcv38b2sQj2ctBYO6sHHjkXU+OYTJwx1V36ViFVuJTHr8XRkeqH6DCRH54h4P5/hiL\n\t1yBg+aJudfzCF6QisF1jDdD8GtTxtzZXOYq43GKzpBJ39xWnlXI1wBN/vfSEFG5u43Qf\n\tmXxhZxY8OBP9wFW1GynihumrxDrW6e8OhxZSOHRRsh3VemxsMlFPLNP/g8aPcTqcanlT\n\t8o4Q==","X-Gm-Message-State":"AOAM531P3tO1JUMyqfU3cEFolWWo1OXLgBsf36Ll/8jnPc3u1pLkjMrN\n\tWDRWJNtcmHcF5dUjqsSiS29GtauB5Jyzcg==","X-Google-Smtp-Source":"ABdhPJxHVGiB0qgrnF8TtBI1i2ZMksgn3oyxRWQsmvWe552OULUE3tTmixQexKp/vrT+fxuflARMrQ==","X-Received":"by 2002:a63:9dc7:: with SMTP id\n\ti190mr6845698pgd.261.1632225391710; \n\tTue, 21 Sep 2021 04:56:31 -0700 (PDT)","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 21 Sep 2021 17:26:10 +0530","Message-Id":"<20210921115610.366553-3-vedantparanjape160201@gmail.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20210921115610.366553-1-vedantparanjape160201@gmail.com>","References":"<20210921115610.366553-1-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 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":"Nicolas Dufresne <nicolas.dufresne@collabora.com>,\n\tVedant Paranjape <vedantparanjape160201@gmail.com>","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 test base class (gstreamer_test.cpp) whereever\nnecessary 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: Vedant Paranjape <vedantparanjape160201@gmail.com>\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n---\n test/gstreamer/gstreamer_test.cpp | 9 ++++-----\n 1 file changed, 4 insertions(+), 5 deletions(-)","diff":"diff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp\nindex 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","prefixes":["libcamera-devel","v1","3/3"]}