From 856a4a25278ce5e4b64497deaa3b20c4df16fdee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Sun, 12 Jan 2020 01:10:51 +0100 Subject: libcamera: request: remove prepare() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The association of buffers to a request can be done directly in addBuffer() instead of when the request is queued to the camera. Keep the check that a request contains buffers by moving it to Camera::queueRequest() where prepare() was previously called. As a bonus we can remove a friend statement in Request. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/request.cpp | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'src/libcamera/request.cpp') diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index c14ed1a4..84a5f558 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -139,6 +139,8 @@ int Request::addBuffer(std::unique_ptr buffer) return -EEXIST; } + buffer->setRequest(this); + pending_.insert(buffer.get()); bufferMap_[stream] = buffer.release(); return 0; @@ -203,30 +205,6 @@ Buffer *Request::findBuffer(Stream *stream) const * otherwise */ -/** - * \brief Validate the request and prepare it for the completion handler - * - * Requests that contain no buffers are invalid and are rejected. - * - * \return 0 on success or a negative error code otherwise - * \retval -EINVAL The request is invalid - */ -int Request::prepare() -{ - if (bufferMap_.empty()) { - LOG(Request, Error) << "Invalid request due to missing buffers"; - return -EINVAL; - } - - for (auto const &pair : bufferMap_) { - Buffer *buffer = pair.second; - buffer->setRequest(this); - pending_.insert(buffer); - } - - return 0; -} - /** * \brief Complete a queued request * -- cgit v1.2.1