[{"id":2095,"web_url":"https://patchwork.libcamera.org/comment/2095/","msgid":"<20190701223614.GC11004@bigcity.dyn.berto.se>","date":"2019-07-01T22:36:14","subject":"Re: [libcamera-devel] [RFC 2/8] libcamera: stream: Provide\n\taccessors to buffers","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2019-06-30 20:10:43 +0200, Jacopo Mondi wrote:\n> All interactions with the Stream's buffers currently go through the\n> BufferPool. In order to shorten accessing the buffers array, and\n> restrict access to the Stream's internal buffer pool, provide operations\n> to access the buffers, create and destriy them.\n\ns/destriy/destroy/\n\n> \n> It is still possible to access the pool for pipeline handlers to\n> populate it by exporting buffers from a video device to the pool.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  include/libcamera/stream.h           | 12 ++++++++++\n>  src/cam/capture.cpp                  |  4 ++--\n>  src/libcamera/camera.cpp             |  6 ++---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp |  4 ++--\n>  src/libcamera/stream.cpp             | 35 +++++++++++++++++++++++-----\n>  src/qcam/main_window.cpp             |  4 +---\n>  test/camera/capture.cpp              |  3 +--\n>  test/camera/statemachine.cpp         |  3 +--\n>  8 files changed, 51 insertions(+), 20 deletions(-)\n> \n> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\n> index 5b4fea324ce4..fa7d6ba4987c 100644\n> --- a/include/libcamera/stream.h\n> +++ b/include/libcamera/stream.h\n> @@ -66,12 +66,24 @@ class Stream\n>  {\n>  public:\n>  \tStream();\n> +\t/*\n> +\t * FIXME:\n> +\t * If I could find a way to export buffers in pipeline handlers\n> +\t * without accessing the pool with\n> +\t * \tvideo_->exportBuffers(&stream->bufferPool());\n> +\t * we could remove access to the internal pool completely.\n> +\t */\n\nI see no real harm in exposing these functions but if you really wish to \nhide them could you not do something like,\n\n        int importBuffers(V4L2VideoDevice *video)\n        {\n            return video->exportBuffers(&bufferPool());\n        }\n\n>  \tBufferPool &bufferPool() { return bufferPool_; }\n> +\tstd::vector<Buffer> &buffers() { return bufferPool_.buffers(); }\n> +\tunsigned int bufferCount() const { return bufferPool_.count(); }\n>  \tconst StreamConfiguration &configuration() const { return configuration_; }\n>  \n>  protected:\n>  \tfriend class Camera;\n>  \n> +\tvoid createBuffers(unsigned int count);\n> +\tvoid destroyBuffers();\n> +\n>  \tBufferPool bufferPool_;\n>  \tStreamConfiguration configuration_;\n>  };\n> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> index 6b842d73390d..1bcc9c7e9cf4 100644\n> --- a/src/cam/capture.cpp\n> +++ b/src/cam/capture.cpp\n> @@ -76,7 +76,7 @@ int Capture::capture(EventLoop *loop)\n>  \tunsigned int nbuffers = UINT_MAX;\n>  \tfor (StreamConfiguration &cfg : *config_) {\n>  \t\tStream *stream = cfg.stream();\n> -\t\tnbuffers = std::min(nbuffers, stream->bufferPool().count());\n> +\t\tnbuffers = std::min(nbuffers, stream->bufferCount());\n>  \t}\n>  \n>  \t/*\n> @@ -95,7 +95,7 @@ int Capture::capture(EventLoop *loop)\n>  \t\tstd::map<Stream *, Buffer *> map;\n>  \t\tfor (StreamConfiguration &cfg : *config_) {\n>  \t\t\tStream *stream = cfg.stream();\n> -\t\t\tmap[stream] = &stream->bufferPool().buffers()[i];\n> +\t\t\tmap[stream] = &stream->buffers()[i];\n>  \t\t}\n>  \n>  \t\tret = request->setBuffers(map);\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 617ea99cdf71..023ae53e5f9d 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -671,7 +671,7 @@ int Camera::configure(CameraConfiguration *config)\n>  \t\t * Allocate buffer objects in the pool.\n>  \t\t * Memory will be allocated and assigned later.\n>  \t\t */\n> -\t\tstream->bufferPool().createBuffers(cfg.bufferCount);\n> +\t\tstream->createBuffers(cfg.bufferCount);\n>  \t}\n>  \n>  \tstate_ = CameraConfigured;\n> @@ -728,14 +728,14 @@ int Camera::freeBuffers()\n>  \t\treturn -EACCES;\n>  \n>  \tfor (Stream *stream : activeStreams_) {\n> -\t\tif (!stream->bufferPool().count())\n> +\t\tif (!stream->bufferCount())\n>  \t\t\tcontinue;\n>  \n>  \t\t/*\n>  \t\t * All mappings must be destroyed before buffers can be freed\n>  \t\t * by the V4L2 device that has allocated them.\n>  \t\t */\n> -\t\tstream->bufferPool().destroyBuffers();\n> +\t\tstream->destroyBuffers();\n>  \t}\n>  \n>  \tstate_ = CameraConfigured;\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index e4efb9722f76..2de0892138a8 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -634,7 +634,7 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n>  \t * of buffers as the active ones.\n>  \t */\n>  \tif (!outStream->active_) {\n> -\t\tbufferCount = vfStream->bufferPool().count();\n> +\t\tbufferCount = vfStream->bufferCount();\n>  \t\toutStream->device_->pool->createBuffers(bufferCount);\n>  \t\tret = imgu->exportBuffers(outStream->device_,\n>  \t\t\t\t\t  outStream->device_->pool);\n> @@ -643,7 +643,7 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n>  \t}\n>  \n>  \tif (!vfStream->active_) {\n> -\t\tbufferCount = outStream->bufferPool().count();\n> +\t\tbufferCount = outStream->bufferCount();\n>  \t\tvfStream->device_->pool->createBuffers(bufferCount);\n>  \t\tret = imgu->exportBuffers(vfStream->device_,\n>  \t\t\t\t\t  vfStream->device_->pool);\n> diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\n> index d8e87c62281c..c6701e5f9921 100644\n> --- a/src/libcamera/stream.cpp\n> +++ b/src/libcamera/stream.cpp\n> @@ -408,14 +408,12 @@ Stream::Stream()\n>  }\n>  \n>  /**\n> - * \\fn Stream::bufferPool()\n> - * \\brief Retrieve the buffer pool for the stream\n> + * \\fn Stream::buffers()\n> + * \\brief Retrieve the stream's buffers\n>   *\n> - * The buffer pool handles the buffers used to capture frames at the output of\n> - * the stream. It is initially created empty and shall be populated with\n> - * buffers before being used.\n> + * \\todo\n>   *\n> - * \\return A reference to the buffer pool\n> + * \\return The list of stream's buffers\n>   */\n>  \n>  /**\n> @@ -424,6 +422,31 @@ Stream::Stream()\n>   * \\return The active configuration of the stream\n>   */\n>  \n> +/**\n> + * \\brief Create buffers for the stream\n> + *\n> + * \\todo\n> + */\n> +void Stream::createBuffers(unsigned int count)\n> +{\n> +\tbufferPool_.destroyBuffers();\n> +\n> +\tif (count == 0)\n> +\t\treturn;\n> +\n> +\tbufferPool_.createBuffers(count);\n> +}\n> +\n> +/**\n> + * \\brief Destroy buffers in the stream\n> + *\n> + * \\todo\n> + */\n> +void Stream::destroyBuffers()\n> +{\n> +\tcreateBuffers(0);\n> +}\n> +\n>  /**\n>   * \\var Stream::bufferPool_\n>   * \\brief The pool of buffers associated with the stream\n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 16b123132dd9..a0703b322c16 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -122,10 +122,8 @@ int MainWindow::startCapture()\n>  \t\treturn ret;\n>  \t}\n>  \n> -\tBufferPool &pool = stream->bufferPool();\n>  \tstd::vector<Request *> requests;\n> -\n> -\tfor (Buffer &buffer : pool.buffers()) {\n> +\tfor (Buffer &buffer : stream->buffers()) {\n>  \t\tRequest *request = camera_->createRequest();\n>  \t\tif (!request) {\n>  \t\t\tstd::cerr << \"Can't create request\" << std::endl;\n> diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> index 7ce247cc482d..a0385ec2c74d 100644\n> --- a/test/camera/capture.cpp\n> +++ b/test/camera/capture.cpp\n> @@ -76,9 +76,8 @@ protected:\n>  \t\t}\n>  \n>  \t\tStream *stream = cfg.stream();\n> -\t\tBufferPool &pool = stream->bufferPool();\n>  \t\tstd::vector<Request *> requests;\n> -\t\tfor (Buffer &buffer : pool.buffers()) {\n> +\t\tfor (Buffer &buffer : stream->buffers()) {\n>  \t\t\tRequest *request = camera_->createRequest();\n>  \t\t\tif (!request) {\n>  \t\t\t\tcout << \"Failed to create request\" << endl;\n> diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\n> index 84d2a6fab5f0..c23455b5bb21 100644\n> --- a/test/camera/statemachine.cpp\n> +++ b/test/camera/statemachine.cpp\n> @@ -211,8 +211,7 @@ protected:\n>  \t\t\treturn TestFail;\n>  \n>  \t\tStream *stream = *camera_->streams().begin();\n> -\t\tBufferPool &pool = stream->bufferPool();\n> -\t\tBuffer &buffer = pool.buffers().front();\n> +\t\tBuffer &buffer = stream->buffers().front();\n>  \t\tstd::map<Stream *, Buffer *> map = { { stream, &buffer } };\n>  \t\tif (request->setBuffers(map))\n>  \t\t\treturn TestFail;\n> -- \n> 2.21.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com\n\t[IPv6:2a00:1450:4864:20::12e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E13B60BF8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Jul 2019 00:36:17 +0200 (CEST)","by mail-lf1-x12e.google.com with SMTP id a9so9902596lff.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 01 Jul 2019 15:36:17 -0700 (PDT)","from localhost (customer-145-14-112-32.stosn.net. [145.14.112.32])\n\tby smtp.gmail.com with ESMTPSA id\n\tj23sm2754411lfb.93.2019.07.01.15.36.15\n\t(version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256);\n\tMon, 01 Jul 2019 15:36:15 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=QdnMYC1xvjwcxcf72ez5pNBnVZ2n4+eZbONxw7QNeQo=;\n\tb=WqAjE/YJJ5IEQ+uHa+Q6rW/PCItF9d6QgLTGxBsXznkIyAA9KAh+OGiaFhclXfVZLe\n\t20CqHkcSJXpClqs9EnCv0EEuwuFmYz/Azky6s8e3XLd7z4u95XWPjNzy3H4JZ/afD3Rf\n\tgse31zDR9Ee/5qOvD4wtljx6Ceq2ciaQ1DCDl+vPOU4NLMcNQRXARw2QLfRvAKv8gjRk\n\tu7QC5SRdxrcJg5zbvGvCICWPO9Fg3CyrJzJZw7vFEShTklyYEfImmaXsCzpLqwRx1pge\n\td0xHFVqQ46dE8/bVUjDvgcDPzSD6XwC2YuwdFUI08pzcn2jA+79ykVGu+qcBYkO9BgtN\n\teFNQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=QdnMYC1xvjwcxcf72ez5pNBnVZ2n4+eZbONxw7QNeQo=;\n\tb=Yh0N8NqM3GdOnAdoq2UKdG3jjPbwxvVCG4UQZsyW1qF/Thyj80Jyfw4q0nPseCJYCZ\n\tA5Y0O3hpVXYD8vSo0QJOuxhmq7S3vUkAtMPCaC7wAUwUn3u8YWW8s4UHm/q6mEqaKALj\n\tCfEnNdViQaFDGNW+AbYi1zUh5fED9Tv348RmaGjdmvpjSQn+rTBtaCGNohTIQ3qOLG3f\n\tfd7LtDdMyB4AZIVo6ffADBi1b+69Y2xZ26Ido2zl3V5GjccSTTNkVNo50byGwzj78540\n\tDfPNRFjBvrarEnbMKJmQxilg0eTD9PLWuQjRh1kEb4LfA6iSlsTw6Y6dvxzOgo6Hhcra\n\tH1HA==","X-Gm-Message-State":"APjAAAV4gk3uTij7NiyYHXaCvWHQpKDklG4ls0xRhuazgaf4Prp8sqF6\n\tisUg1qqm/wfhZ6k1bBKXVP3eIJob1X8=","X-Google-Smtp-Source":"APXvYqzRVqefsMcDtwOtQh5ci2B18ZFjEsve60v9Kd++fD9P7Rdpu0YuvKtEXSJAuEROQghkPNx9lQ==","X-Received":"by 2002:a05:6512:30a:: with SMTP id\n\tt10mr12607564lfp.22.1562020576570; \n\tMon, 01 Jul 2019 15:36:16 -0700 (PDT)","Date":"Tue, 2 Jul 2019 00:36:14 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190701223614.GC11004@bigcity.dyn.berto.se>","References":"<20190630181049.9548-1-jacopo@jmondi.org>\n\t<20190630181049.9548-3-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190630181049.9548-3-jacopo@jmondi.org>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [RFC 2/8] libcamera: stream: Provide\n\taccessors to buffers","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Mon, 01 Jul 2019 22:36:17 -0000"}},{"id":2116,"web_url":"https://patchwork.libcamera.org/comment/2116/","msgid":"<20190702071833.t5k2hvkjcpikutfm@uno.localdomain>","date":"2019-07-02T07:18:33","subject":"Re: [libcamera-devel] [RFC 2/8] libcamera: stream: Provide\n\taccessors to buffers","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Tue, Jul 02, 2019 at 12:36:14AM +0200, Niklas Söderlund wrote:\n> Hi Jacopo,\n>\n> Thanks for your work.\n>\n> On 2019-06-30 20:10:43 +0200, Jacopo Mondi wrote:\n> > All interactions with the Stream's buffers currently go through the\n> > BufferPool. In order to shorten accessing the buffers array, and\n> > restrict access to the Stream's internal buffer pool, provide operations\n> > to access the buffers, create and destriy them.\n>\n> s/destriy/destroy/\n>\n> >\n> > It is still possible to access the pool for pipeline handlers to\n> > populate it by exporting buffers from a video device to the pool.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  include/libcamera/stream.h           | 12 ++++++++++\n> >  src/cam/capture.cpp                  |  4 ++--\n> >  src/libcamera/camera.cpp             |  6 ++---\n> >  src/libcamera/pipeline/ipu3/ipu3.cpp |  4 ++--\n> >  src/libcamera/stream.cpp             | 35 +++++++++++++++++++++++-----\n> >  src/qcam/main_window.cpp             |  4 +---\n> >  test/camera/capture.cpp              |  3 +--\n> >  test/camera/statemachine.cpp         |  3 +--\n> >  8 files changed, 51 insertions(+), 20 deletions(-)\n> >\n> > diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\n> > index 5b4fea324ce4..fa7d6ba4987c 100644\n> > --- a/include/libcamera/stream.h\n> > +++ b/include/libcamera/stream.h\n> > @@ -66,12 +66,24 @@ class Stream\n> >  {\n> >  public:\n> >  \tStream();\n> > +\t/*\n> > +\t * FIXME:\n> > +\t * If I could find a way to export buffers in pipeline handlers\n> > +\t * without accessing the pool with\n> > +\t * \tvideo_->exportBuffers(&stream->bufferPool());\n> > +\t * we could remove access to the internal pool completely.\n> > +\t */\n>\n> I see no real harm in exposing these functions but if you really wish to\n> hide them could you not do something like,\n\nI think not exposing the buffer pool to applications is a good thing.\nProvide operations to deal with memory allocation/destruction would\nmake handling buffers a stream-centric operation and in the next patch\nin this series you can see how in those wrapper operations we can do\nthings like mapping/unmapping.\n\n>\n>         int importBuffers(V4L2VideoDevice *video)\n\nint Stream::importBuffers()  you mean ? I considered that, but to me\nwhat happen is that \"the memory reserved in the video device is made\naccessible to the Stream\", so I would either use export or even map as\nverbs. Import is not nice if you ask me, as it might overlap with the\n'importing external buffers' idea. What do you think?\n\n>         {\n>             return video->exportBuffers(&bufferPool());\n>         }\n>\n> >  \tBufferPool &bufferPool() { return bufferPool_; }\n> > +\tstd::vector<Buffer> &buffers() { return bufferPool_.buffers(); }\n> > +\tunsigned int bufferCount() const { return bufferPool_.count(); }\n> >  \tconst StreamConfiguration &configuration() const { return configuration_; }\n> >\n> >  protected:\n> >  \tfriend class Camera;\n> >\n> > +\tvoid createBuffers(unsigned int count);\n> > +\tvoid destroyBuffers();\n> > +\n> >  \tBufferPool bufferPool_;\n> >  \tStreamConfiguration configuration_;\n> >  };\n> > diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> > index 6b842d73390d..1bcc9c7e9cf4 100644\n> > --- a/src/cam/capture.cpp\n> > +++ b/src/cam/capture.cpp\n> > @@ -76,7 +76,7 @@ int Capture::capture(EventLoop *loop)\n> >  \tunsigned int nbuffers = UINT_MAX;\n> >  \tfor (StreamConfiguration &cfg : *config_) {\n> >  \t\tStream *stream = cfg.stream();\n> > -\t\tnbuffers = std::min(nbuffers, stream->bufferPool().count());\n> > +\t\tnbuffers = std::min(nbuffers, stream->bufferCount());\n> >  \t}\n> >\n> >  \t/*\n> > @@ -95,7 +95,7 @@ int Capture::capture(EventLoop *loop)\n> >  \t\tstd::map<Stream *, Buffer *> map;\n> >  \t\tfor (StreamConfiguration &cfg : *config_) {\n> >  \t\t\tStream *stream = cfg.stream();\n> > -\t\t\tmap[stream] = &stream->bufferPool().buffers()[i];\n> > +\t\t\tmap[stream] = &stream->buffers()[i];\n> >  \t\t}\n> >\n> >  \t\tret = request->setBuffers(map);\n> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > index 617ea99cdf71..023ae53e5f9d 100644\n> > --- a/src/libcamera/camera.cpp\n> > +++ b/src/libcamera/camera.cpp\n> > @@ -671,7 +671,7 @@ int Camera::configure(CameraConfiguration *config)\n> >  \t\t * Allocate buffer objects in the pool.\n> >  \t\t * Memory will be allocated and assigned later.\n> >  \t\t */\n> > -\t\tstream->bufferPool().createBuffers(cfg.bufferCount);\n> > +\t\tstream->createBuffers(cfg.bufferCount);\n> >  \t}\n> >\n> >  \tstate_ = CameraConfigured;\n> > @@ -728,14 +728,14 @@ int Camera::freeBuffers()\n> >  \t\treturn -EACCES;\n> >\n> >  \tfor (Stream *stream : activeStreams_) {\n> > -\t\tif (!stream->bufferPool().count())\n> > +\t\tif (!stream->bufferCount())\n> >  \t\t\tcontinue;\n> >\n> >  \t\t/*\n> >  \t\t * All mappings must be destroyed before buffers can be freed\n> >  \t\t * by the V4L2 device that has allocated them.\n> >  \t\t */\n> > -\t\tstream->bufferPool().destroyBuffers();\n> > +\t\tstream->destroyBuffers();\n> >  \t}\n> >\n> >  \tstate_ = CameraConfigured;\n> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > index e4efb9722f76..2de0892138a8 100644\n> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > @@ -634,7 +634,7 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n> >  \t * of buffers as the active ones.\n> >  \t */\n> >  \tif (!outStream->active_) {\n> > -\t\tbufferCount = vfStream->bufferPool().count();\n> > +\t\tbufferCount = vfStream->bufferCount();\n> >  \t\toutStream->device_->pool->createBuffers(bufferCount);\n> >  \t\tret = imgu->exportBuffers(outStream->device_,\n> >  \t\t\t\t\t  outStream->device_->pool);\n> > @@ -643,7 +643,7 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n> >  \t}\n> >\n> >  \tif (!vfStream->active_) {\n> > -\t\tbufferCount = outStream->bufferPool().count();\n> > +\t\tbufferCount = outStream->bufferCount();\n> >  \t\tvfStream->device_->pool->createBuffers(bufferCount);\n> >  \t\tret = imgu->exportBuffers(vfStream->device_,\n> >  \t\t\t\t\t  vfStream->device_->pool);\n> > diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\n> > index d8e87c62281c..c6701e5f9921 100644\n> > --- a/src/libcamera/stream.cpp\n> > +++ b/src/libcamera/stream.cpp\n> > @@ -408,14 +408,12 @@ Stream::Stream()\n> >  }\n> >\n> >  /**\n> > - * \\fn Stream::bufferPool()\n> > - * \\brief Retrieve the buffer pool for the stream\n> > + * \\fn Stream::buffers()\n> > + * \\brief Retrieve the stream's buffers\n> >   *\n> > - * The buffer pool handles the buffers used to capture frames at the output of\n> > - * the stream. It is initially created empty and shall be populated with\n> > - * buffers before being used.\n> > + * \\todo\n> >   *\n> > - * \\return A reference to the buffer pool\n> > + * \\return The list of stream's buffers\n> >   */\n> >\n> >  /**\n> > @@ -424,6 +422,31 @@ Stream::Stream()\n> >   * \\return The active configuration of the stream\n> >   */\n> >\n> > +/**\n> > + * \\brief Create buffers for the stream\n> > + *\n> > + * \\todo\n> > + */\n> > +void Stream::createBuffers(unsigned int count)\n> > +{\n> > +\tbufferPool_.destroyBuffers();\n> > +\n> > +\tif (count == 0)\n> > +\t\treturn;\n> > +\n> > +\tbufferPool_.createBuffers(count);\n> > +}\n> > +\n> > +/**\n> > + * \\brief Destroy buffers in the stream\n> > + *\n> > + * \\todo\n> > + */\n> > +void Stream::destroyBuffers()\n> > +{\n> > +\tcreateBuffers(0);\n> > +}\n> > +\n> >  /**\n> >   * \\var Stream::bufferPool_\n> >   * \\brief The pool of buffers associated with the stream\n> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> > index 16b123132dd9..a0703b322c16 100644\n> > --- a/src/qcam/main_window.cpp\n> > +++ b/src/qcam/main_window.cpp\n> > @@ -122,10 +122,8 @@ int MainWindow::startCapture()\n> >  \t\treturn ret;\n> >  \t}\n> >\n> > -\tBufferPool &pool = stream->bufferPool();\n> >  \tstd::vector<Request *> requests;\n> > -\n> > -\tfor (Buffer &buffer : pool.buffers()) {\n> > +\tfor (Buffer &buffer : stream->buffers()) {\n> >  \t\tRequest *request = camera_->createRequest();\n> >  \t\tif (!request) {\n> >  \t\t\tstd::cerr << \"Can't create request\" << std::endl;\n> > diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> > index 7ce247cc482d..a0385ec2c74d 100644\n> > --- a/test/camera/capture.cpp\n> > +++ b/test/camera/capture.cpp\n> > @@ -76,9 +76,8 @@ protected:\n> >  \t\t}\n> >\n> >  \t\tStream *stream = cfg.stream();\n> > -\t\tBufferPool &pool = stream->bufferPool();\n> >  \t\tstd::vector<Request *> requests;\n> > -\t\tfor (Buffer &buffer : pool.buffers()) {\n> > +\t\tfor (Buffer &buffer : stream->buffers()) {\n> >  \t\t\tRequest *request = camera_->createRequest();\n> >  \t\t\tif (!request) {\n> >  \t\t\t\tcout << \"Failed to create request\" << endl;\n> > diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\n> > index 84d2a6fab5f0..c23455b5bb21 100644\n> > --- a/test/camera/statemachine.cpp\n> > +++ b/test/camera/statemachine.cpp\n> > @@ -211,8 +211,7 @@ protected:\n> >  \t\t\treturn TestFail;\n> >\n> >  \t\tStream *stream = *camera_->streams().begin();\n> > -\t\tBufferPool &pool = stream->bufferPool();\n> > -\t\tBuffer &buffer = pool.buffers().front();\n> > +\t\tBuffer &buffer = stream->buffers().front();\n> >  \t\tstd::map<Stream *, Buffer *> map = { { stream, &buffer } };\n> >  \t\tif (request->setBuffers(map))\n> >  \t\t\treturn TestFail;\n> > --\n> > 2.21.0\n> >\n> > _______________________________________________\n> > libcamera-devel mailing list\n> > libcamera-devel@lists.libcamera.org\n> > https://lists.libcamera.org/listinfo/libcamera-devel\n>\n> --\n> Regards,\n> Niklas Söderlund","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0CC3660C01\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Jul 2019 09:17:18 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 8DB7120000C;\n\tTue,  2 Jul 2019 07:17:17 +0000 (UTC)"],"Date":"Tue, 2 Jul 2019 09:18:33 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190702071833.t5k2hvkjcpikutfm@uno.localdomain>","References":"<20190630181049.9548-1-jacopo@jmondi.org>\n\t<20190630181049.9548-3-jacopo@jmondi.org>\n\t<20190701223614.GC11004@bigcity.dyn.berto.se>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"4k6r4apiwctkanhy\"","Content-Disposition":"inline","In-Reply-To":"<20190701223614.GC11004@bigcity.dyn.berto.se>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [RFC 2/8] libcamera: stream: Provide\n\taccessors to buffers","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Tue, 02 Jul 2019 07:17:18 -0000"}}]