{"id":13881,"url":"https://patchwork.libcamera.org/api/patches/13881/?format=json","web_url":"https://patchwork.libcamera.org/patch/13881/","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":"<20210921173955.20408-3-vedantparanjape160201@gmail.com>","date":"2021-09-21T17:39:55","name":"[libcamera-devel,v2,3/3] test: gstreamer: Simplify elements' ownerships","commit_ref":"c7daf645d449fc74415770b9d811ec21571e7823","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/13881/mbox/","series":[{"id":2542,"url":"https://patchwork.libcamera.org/api/series/2542/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2542","date":"2021-09-21T17:39:53","name":"[libcamera-devel,v2,1/3] test: gstreamer_single_stream_test: Fix memory leak","version":2,"mbox":"https://patchwork.libcamera.org/series/2542/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13881/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13881/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 A5580BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Sep 2021 17:40:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 644D569191;\n\tTue, 21 Sep 2021 19:40:26 +0200 (CEST)","from mail-pf1-x434.google.com (mail-pf1-x434.google.com\n\t[IPv6:2607:f8b0:4864:20::434])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 564FB6918A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Sep 2021 19:40:25 +0200 (CEST)","by mail-pf1-x434.google.com with SMTP id c1so148943pfp.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Sep 2021 10:40:25 -0700 (PDT)","from localhost.localdomain ([1.186.167.167])\n\tby smtp.googlemail.com with ESMTPSA id\n\tk190sm19800772pgc.11.2021.09.21.10.40.21\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 21 Sep 2021 10:40:23 -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=\"HrvX5kJs\"; 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=HrvX5kJsYIGMeH1I8RYGxMJhicwcuUre4dw9dg6igYoVAmg6K1EoDXTgulLdsuXLeJ\n\tnAWr6aIisvMRpWLJ3ghG3DBxxAmjp3+QTY1SO71lUssLGq584vH692MKKqraRtupGEth\n\tFmxA46xlXtQFlLKUqMRKeHkU3UBTLQpKA0UE6bYfiNuog5i/tRJX8v4KYgYX5hTWR0Xu\n\t9Jt46dW2hWOJCDQwks2Hnnq5U8H5sK2HxOyG0cx5UkY6/UKzvb/xOiYWwsnA2S3tsmWs\n\tqgxxfOv/sM/3cJLf5zmPYw/C1MWMuYUsNZU/jBtilqnQK8QK6udBCRihU/Zq/vTdXdhe\n\tMKxQ==","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=n/LUq7YMyhrPyfaK92ikXJudnVBB4NiLohes06HCJB2fg4L9k+FjkhKFW4VZhRZe/y\n\tfV/vL0Pw383XugeEzpSwBXC13q/VhkLaIAvLMFGLyXnfEZlLUQ15akOn8zSj0sFnyZnj\n\tvZJteSWyn7zP+CAEnWEwwigyNMc0DR8ndhY4eh8vfYvOAoRRHGyV356GiEpRHFW/YaEp\n\tURKJfoEW9aukoDp3bx6by99QIlX60i02ma2g9oQVfsmAUaFb4I82a4Y/O91zeBDXCWEI\n\tJR+ihDShVQ3uZjTFFbefRPhgBXOZmd6yhoq/Q0o5x4sWneL0m8q6U4dAdQtHmeH1PFyo\n\tAVpw==","X-Gm-Message-State":"AOAM533Qa4MoIzlp4mZnTlnAuM6uelWyD0Pfl0XzhTeDNj1eqI9aCb3I\n\t0gRNzTORxGBZh7JWI+5xEfguLpSCpcOpZ7/Z","X-Google-Smtp-Source":"ABdhPJy0/of+yIpHQw/cdmicN4OamsCuh7bjNoQmSndJdYXLU3WcsYAZoIFesoRcGIJoix6tsbWOTA==","X-Received":"by 2002:a63:774e:: with SMTP id\n\ts75mr15830187pgc.73.1632246023625; \n\tTue, 21 Sep 2021 10:40:23 -0700 (PDT)","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 21 Sep 2021 23:09:55 +0530","Message-Id":"<20210921173955.20408-3-vedantparanjape160201@gmail.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20210921173955.20408-1-vedantparanjape160201@gmail.com>","References":"<20210921173955.20408-1-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[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":"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","v2","3/3"]}