From be3e3ebc92d8ffba8a03483f05e7956e33726c4e Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 28 Jun 2019 10:03:02 +0200 Subject: libcamera: stream: Shorten access to the bufferPool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All interactions with the Stream's buffers currently go through the BufferPool. In order to shorten accessing the buffers array, and eventually restrict access to the Stream's internal buffer pool, provide operations to access, create and destroy buffers. It is still possible to access the pool for pipeline handlers to populate it by exporting buffers from a video device to Stream's pool. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/stream.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'src/libcamera/stream.cpp') diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 6d80646b..12067c08 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -435,19 +435,51 @@ std::unique_ptr Stream::createBuffer(unsigned int index) * \fn Stream::bufferPool() * \brief Retrieve the buffer pool for the stream * - * The buffer pool handles the buffers used to capture frames at the output of - * the stream. It is initially created empty and shall be populated with + * The buffer pool handles the memory buffers used to store frames for the + * stream. It is initially created empty and shall be populated with * buffers before being used. * * \return A reference to the buffer pool */ +/** + * \fn Stream::buffers() + * \brief Retrieve the memory buffers in the Stream's buffer pool + * \return The list of stream's memory buffers + */ + /** * \fn Stream::configuration() * \brief Retrieve the active configuration of the stream * \return The active configuration of the stream */ +/** + * \brief Create buffers for the stream + * \param[in] count The number of buffers to create + * + * Create \a count empty buffers in the Stream's buffer pool. + */ +void Stream::createBuffers(unsigned int count) +{ + destroyBuffers(); + if (count == 0) + return; + + bufferPool_.createBuffers(count); +} + +/** + * \brief Destroy buffers in the stream + * + * If no buffers have been created or if buffers have already been destroyed no + * operation is performed. + */ +void Stream::destroyBuffers() +{ + bufferPool_.destroyBuffers(); +} + /** * \var Stream::bufferPool_ * \brief The pool of buffers associated with the stream -- cgit v1.2.1