[{"id":3685,"web_url":"https://patchwork.libcamera.org/comment/3685/","msgid":"<20200212002718.GS20823@pendragon.ideasonboard.com>","date":"2020-02-12T00:27:18","subject":"Re: [libcamera-devel] [PATCH v1 19/23] gst: libcamerasrc: Allocate\n\tand release buffers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nicolas,\n\nThank you for the patch.\n\nOn Tue, Jan 28, 2020 at 10:32:06PM -0500, Nicolas Dufresne wrote:\n> From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> \n> Setup the allocation and the release of buffers in the\n> element. We have one pooling GstAllocator that wraps the\n> FrameBufferAllocator and tracks the live time of FrameBuffer\n\ns/live time/lifetime/\n\n> object. Then for each pads we have a GstBufferPool object\n\ns/pads/pad/\n\n> which is only used to avoid re-allocation the GstBuffer\n\ns/allocation/allocating/ ?\n\n> shell everything.\n\nI'm not sure to get that.\n\n> \n> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> ---\n>  src/gstreamer/gstlibcamerasrc.cpp | 29 +++++++++++++++++++++++++++++\n>  1 file changed, 29 insertions(+)\n> \n> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\n> index 0df71c6..5fc4393 100644\n> --- a/src/gstreamer/gstlibcamerasrc.cpp\n> +++ b/src/gstreamer/gstlibcamerasrc.cpp\n> @@ -8,6 +8,8 @@\n>  \n>  #include \"gstlibcamerasrc.h\"\n>  #include \"gstlibcamerapad.h\"\n> +#include \"gstlibcameraallocator.h\"\n> +#include \"gstlibcamerapool.h\"\n>  #include \"gstlibcamera-utils.h\"\n>  \n>  #include <libcamera/camera.h>\n> @@ -37,6 +39,7 @@ struct _GstLibcameraSrc {\n>  \tgchar *camera_name;\n>  \n>  \tGstLibcameraSrcState *state;\n> +\tGstLibcameraAllocator *allocator;\n>  };\n>  \n>  enum {\n> @@ -207,6 +210,23 @@ gst_libcamera_src_task_enter(GstTask *task, GThread *thread, gpointer user_data)\n>  \t\treturn;\n>  \t}\n>  \n> +\tself->allocator = gst_libcamera_allocator_new(state->cam);\n> +\tif (!self->allocator) {\n> +\t\tGST_ELEMENT_ERROR(self, RESOURCE, NO_SPACE_LEFT,\n> +\t\t\t\t  (\"Failed to allocate memory\"),\n> +\t\t\t\t  (\"gst_libcamera_allocator_new() failed.\"));\n> +\t\tgst_task_stop(task);\n> +\t\treturn;\n> +\t}\n> +\n> +\tfor (gsize i = 0; i < state->srcpads.size(); i++) {\n> +\t\tGstPad *srcpad = state->srcpads[i];\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\tgst_libcamera_pad_set_pool(srcpad, pool);\n> +\t}\n> +\n>  done:\n>  \tswitch (flow_ret) {\n>  \tcase GST_FLOW_NOT_NEGOTIATED:\n> @@ -225,8 +245,15 @@ static void\n>  gst_libcamera_src_task_leave(GstTask *task, GThread *thread, gpointer user_data)\n>  {\n>  \tGstLibcameraSrc *self = GST_LIBCAMERA_SRC(user_data);\n> +\tGstLibcameraSrcState *state = self->state;\n>  \n>  \tGST_DEBUG_OBJECT(self, \"Streaming thread is about to stop\");\n> +\tstate->cam->stop();\n\nAs this patch doesn't add cam->start(), doesn't this belong to another\npatch ?\n\n> +\n> +\tfor (GstPad *srcpad : state->srcpads)\n> +\t\tgst_libcamera_pad_set_pool(srcpad, NULL);\n> +\n> +\tg_clear_object(&self->allocator);\n>  }\n>  \n>  static void\n> @@ -235,6 +262,8 @@ gst_libcamera_src_close(GstLibcameraSrc *self)\n>  \tGstLibcameraSrcState *state = self->state;\n>  \tgint ret;\n>  \n> +\tGST_DEBUG_OBJECT(self, \"Releasing resources\");\n> +\n>  \tret = state->cam->release();\n>  \tif (ret) {\n>  \t\tGST_ELEMENT_WARNING(self, RESOURCE, BUSY,","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 591F761020\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Feb 2020 01:27:34 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9F7FD9DA;\n\tWed, 12 Feb 2020 01:27:33 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581467253;\n\tbh=6b8spmf0a54B8lrOLG0R4qYrxvXJKDAj8f5pc5mJebc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=pdrxXiouF94CTebvrViXeVq+a0wtYQFp4Rd7Tsk/aPzBRvnOJRsIg58BZhyKrzpq4\n\tCbmbwo6P0Lg4/RFrZkHooG0bC9J9SdN91B46hXwtTxBx2gmKvdYMfq/7/LA/4vTe8E\n\tIhR5nYMvNznL47BEfbSco6gage0dZa0ChOY/XQaY=","Date":"Wed, 12 Feb 2020 02:27:18 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Nicolas Dufresne <nicolas@ndufresne.ca>","Cc":"libcamera-devel@lists.libcamera.org,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Message-ID":"<20200212002718.GS20823@pendragon.ideasonboard.com>","References":"<20200129033210.278800-1-nicolas@ndufresne.ca>\n\t<20200129033210.278800-20-nicolas@ndufresne.ca>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200129033210.278800-20-nicolas@ndufresne.ca>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v1 19/23] gst: libcamerasrc: Allocate\n\tand release buffers","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":"Wed, 12 Feb 2020 00:27:34 -0000"}},{"id":3695,"web_url":"https://patchwork.libcamera.org/comment/3695/","msgid":"<d0042b6f0d898bb36cb5caec5e83b01313edcbc5.camel@ndufresne.ca>","date":"2020-02-12T17:38:32","subject":"Re: [libcamera-devel] [PATCH v1 19/23] gst: libcamerasrc: Allocate\n\tand release buffers","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/people/30/","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"content":"Le mercredi 12 février 2020 à 02:27 +0200, Laurent Pinchart a écrit :\n> Hi Nicolas,\n> \n> Thank you for the patch.\n> \n> On Tue, Jan 28, 2020 at 10:32:06PM -0500, Nicolas Dufresne wrote:\n> > From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> > \n> > Setup the allocation and the release of buffers in the\n> > element. We have one pooling GstAllocator that wraps the\n> > FrameBufferAllocator and tracks the live time of FrameBuffer\n> \n> s/live time/lifetime/\n> \n> > object. Then for each pads we have a GstBufferPool object\n> \n> s/pads/pad/\n> \n> > which is only used to avoid re-allocation the GstBuffer\n> \n> s/allocation/allocating/ ?\n> \n> > shell everything.\n> \n> I'm not sure to get that.\n\nSame, I'll try and figure out.\n\n> \n> > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> > ---\n> >  src/gstreamer/gstlibcamerasrc.cpp | 29 +++++++++++++++++++++++++++++\n> >  1 file changed, 29 insertions(+)\n> > \n> > diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\n> > index 0df71c6..5fc4393 100644\n> > --- a/src/gstreamer/gstlibcamerasrc.cpp\n> > +++ b/src/gstreamer/gstlibcamerasrc.cpp\n> > @@ -8,6 +8,8 @@\n> >  \n> >  #include \"gstlibcamerasrc.h\"\n> >  #include \"gstlibcamerapad.h\"\n> > +#include \"gstlibcameraallocator.h\"\n> > +#include \"gstlibcamerapool.h\"\n> >  #include \"gstlibcamera-utils.h\"\n> >  \n> >  #include <libcamera/camera.h>\n> > @@ -37,6 +39,7 @@ struct _GstLibcameraSrc {\n> >  \tgchar *camera_name;\n> >  \n> >  \tGstLibcameraSrcState *state;\n> > +\tGstLibcameraAllocator *allocator;\n> >  };\n> >  \n> >  enum {\n> > @@ -207,6 +210,23 @@ gst_libcamera_src_task_enter(GstTask *task, GThread *thread, gpointer user_data)\n> >  \t\treturn;\n> >  \t}\n> >  \n> > +\tself->allocator = gst_libcamera_allocator_new(state->cam);\n> > +\tif (!self->allocator) {\n> > +\t\tGST_ELEMENT_ERROR(self, RESOURCE, NO_SPACE_LEFT,\n> > +\t\t\t\t  (\"Failed to allocate memory\"),\n> > +\t\t\t\t  (\"gst_libcamera_allocator_new() failed.\"));\n> > +\t\tgst_task_stop(task);\n> > +\t\treturn;\n> > +\t}\n> > +\n> > +\tfor (gsize i = 0; i < state->srcpads.size(); i++) {\n> > +\t\tGstPad *srcpad = state->srcpads[i];\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\tgst_libcamera_pad_set_pool(srcpad, pool);\n> > +\t}\n> > +\n> >  done:\n> >  \tswitch (flow_ret) {\n> >  \tcase GST_FLOW_NOT_NEGOTIATED:\n> > @@ -225,8 +245,15 @@ static void\n> >  gst_libcamera_src_task_leave(GstTask *task, GThread *thread, gpointer user_data)\n> >  {\n> >  \tGstLibcameraSrc *self = GST_LIBCAMERA_SRC(user_data);\n> > +\tGstLibcameraSrcState *state = self->state;\n> >  \n> >  \tGST_DEBUG_OBJECT(self, \"Streaming thread is about to stop\");\n> > +\tstate->cam->stop();\n> \n> As this patch doesn't add cam->start(), doesn't this belong to another\n> patch ?\n> \n> > +\n> > +\tfor (GstPad *srcpad : state->srcpads)\n> > +\t\tgst_libcamera_pad_set_pool(srcpad, NULL);\n> > +\n> > +\tg_clear_object(&self->allocator);\n> >  }\n> >  \n> >  static void\n> > @@ -235,6 +262,8 @@ gst_libcamera_src_close(GstLibcameraSrc *self)\n> >  \tGstLibcameraSrcState *state = self->state;\n> >  \tgint ret;\n> >  \n> > +\tGST_DEBUG_OBJECT(self, \"Releasing resources\");\n> > +\n> >  \tret = state->cam->release();\n> >  \tif (ret) {\n> >  \t\tGST_ELEMENT_WARNING(self, RESOURCE, BUSY,","headers":{"Return-Path":"<nicolas@ndufresne.ca>","Received":["from mail-qk1-x742.google.com (mail-qk1-x742.google.com\n\t[IPv6:2607:f8b0:4864:20::742])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4FCDA6043B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Feb 2020 18:38:35 +0100 (CET)","by mail-qk1-x742.google.com with SMTP id p7so2835739qkh.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Feb 2020 09:38:35 -0800 (PST)","from skullcanyon ([192.222.193.21])\n\tby smtp.gmail.com with ESMTPSA id\n\to6sm542168qkk.53.2020.02.12.09.38.33\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 12 Feb 2020 09:38:33 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ndufresne-ca.20150623.gappssmtp.com; s=20150623;\n\th=message-id:subject:from:to:cc:date:in-reply-to:references\n\t:user-agent:mime-version:content-transfer-encoding;\n\tbh=IohdimGKVNzbaxZjd/1VuVfX1HV4y1Q4NDMYuD1yETs=;\n\tb=Grun7npMyCPfhIfTi3c+geLZrOQnZ+sxQQ5utEsTctUa6asTI9y0H/YIMGIXvhzh6U\n\tuJd3nJ8G5JITpP9RAyp+tZM3nEoatRjOsKzQqTs7TPoUJO42RoxXZHADNRs12nTZ7blo\n\tolJiOGmNNf52dzmnTuURAXojKmrytrlK6l34eueFNrYVwk5UMb5eAeO/ZI7G5R7uVK/C\n\tnlQCZe+rxyoJsbFCg42vgul2Tbpy4FhKrsmSb2WKcyuf8QgP2jmOfSvMmbbD05s8vR9t\n\thZjul+s/lFlzrEv3DzdGQS0Edp3yWjGrmepIfJB6xINdVzUE9PQITz2RxHs+srloRBHU\n\tUHBQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to\n\t:references:user-agent:mime-version:content-transfer-encoding;\n\tbh=IohdimGKVNzbaxZjd/1VuVfX1HV4y1Q4NDMYuD1yETs=;\n\tb=chmGKWWij9h10nrn9uVcVCx3rcB9RXh6NBRm7g8+rgEXbOARmm4JijCuEkxmCoU1dL\n\tsIwvbnJxcncb8V57OTkCRg8iyt/fJpIgpuCHdXY9TPwYUE4l+jtdfUMJpEA/6G7j9Dkc\n\tJch8RSEVQeIEjMeOjSTLsnQ3zl2FQzcx7+V3XYYoS/56KJbY4SL0FLfVRIMoKT1+LO8V\n\t6rrb6mK06EA8tcXIwWX4EzH8yTKbXlqD8CT3JJMYujyx/VJksCs2EA6QZP784CN6bYVD\n\taZVdwqy55ZvnbKePVN6vYNIIZVEXLyqtGi1FZ/qNtDl0KNSqotukKQz6gUJkyMmj2891\n\tEqXw==","X-Gm-Message-State":"APjAAAUZLX2qnbBep8pqSNvevXhJ2Z5yl9aGNNwk71UXCJ+rJV3ccG5S\n\t9lkH2nayyHtQlbuxNIOZQbTC82dfOxfk2w==","X-Google-Smtp-Source":"APXvYqyHIYOkfC0Yf7c3nTZUxE/OfoSFWEvJxBjK84Ea8avPm8GeEBIr0WgIRwXY6RHc3Y7EqZtrIg==","X-Received":"by 2002:a37:4b4b:: with SMTP id\n\ty72mr11737932qka.175.1581529114304; \n\tWed, 12 Feb 2020 09:38:34 -0800 (PST)","Message-ID":"<d0042b6f0d898bb36cb5caec5e83b01313edcbc5.camel@ndufresne.ca>","From":"Nicolas Dufresne <nicolas@ndufresne.ca>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Date":"Wed, 12 Feb 2020 12:38:32 -0500","In-Reply-To":"<20200212002718.GS20823@pendragon.ideasonboard.com>","References":"<20200129033210.278800-1-nicolas@ndufresne.ca>\n\t<20200129033210.278800-20-nicolas@ndufresne.ca>\n\t<20200212002718.GS20823@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","User-Agent":"Evolution 3.34.3 (3.34.3-1.fc31) ","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v1 19/23] gst: libcamerasrc: Allocate\n\tand release buffers","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":"Wed, 12 Feb 2020 17:38:35 -0000"}}]