From patchwork Thu Feb 28 16:29:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 661 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C5762610B7 for ; Thu, 28 Feb 2019 17:29:27 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6878067 for ; Thu, 28 Feb 2019 17:29:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1551371367; bh=Z3eX5qXbTA306L8rPhCv+xNc6a2yWaBd65cagntz7hc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=u5Cc0/YcXOsiM0eKpiJ6omXsRj8kzOdHYDnyh7Qse/xH/m1BCAvCeU3i7bW0NXUE0 n/bttSMxb4A6YJUnlGZN75ztLbS1enEHWIw3u/SNe2niSZK8YZ/xaGZrG/gqcYb943 RKyuEzAGhlu/v7ILZnzJcJrzvPUPD7aFgxuGVeM0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Feb 2019 18:29:11 +0200 Message-Id: <20190228162913.6508-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190228162913.6508-1-laurent.pinchart@ideasonboard.com> References: <20190228162913.6508-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 08/10] libcamera: request: Add request completion status X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Feb 2019 16:29:28 -0000 Add a new field to the Request class to report its completion status, and a new complete() method to update the status. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/request.h | 12 +++++++++++ src/libcamera/request.cpp | 40 ++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/include/libcamera/request.h b/include/libcamera/request.h index ef081177309f..0b75f9d9bd19 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -18,9 +18,16 @@ class Buffer; class Camera; class Stream; + class Request { public: + enum Status { + RequestPending, + RequestComplete, + RequestCancelled, + }; + explicit Request(Camera *camera); Request(const Request &) = delete; Request &operator=(const Request &) = delete; @@ -28,15 +35,20 @@ public: int setBuffers(const std::map &streamMap); Buffer *findBuffer(Stream *stream) const; + Status status() const { return status_; } + private: friend class Camera; int prepare(); + void complete(Status status); void bufferCompleted(Buffer *buffer); Camera *camera_; std::map bufferMap_; std::unordered_set pending_; + + Status status_; }; } /* namespace libcamera */ diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index d76db24de0e2..cb170930fbb6 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -23,6 +23,17 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Request) +/** + * \enum Request::Status + * Request completion status + * \var Request::RequestPending + * The request hasn't completed yet + * \var Request::RequestComplete + * The request has completed + * \var Request::RequestCancelled + * The request has been cancelled due to capture stop + */ + /** * \class Request * \brief A frame capture request @@ -36,7 +47,7 @@ LOG_DEFINE_CATEGORY(Request) * \param[in] camera The camera that creates the request */ Request::Request(Camera *camera) - : camera_(camera) + : camera_(camera), status_(RequestPending) { } @@ -82,6 +93,19 @@ Buffer *Request::findBuffer(Stream *stream) const return it->second; } +/** + * \fn Request::status() + * \brief Retrieve the request completion status + * + * The request status indicates whether the request has completed successfully + * or with an error. When requests are created and before they complete the + * request status is set to RequestPending, and is updated at completion time + * to RequestComplete. If a request is cancelled at capture stop before it has + * completed, its status is set to RequestCancelled. + * + * \return The request completion status + */ + /** * \brief Prepare the resources for the completion handler */ @@ -96,6 +120,18 @@ int Request::prepare() return 0; } +/** + * \brief Complete a queued request + * \param[in] status The request completion status + * + * Mark the request as complete by updating its status to \a status. + */ +void Request::complete(Status status) +{ + ASSERT(pending_.empty()); + status_ = status; +} + /** * \brief Slot for the buffer completed signal * @@ -117,6 +153,8 @@ void Request::bufferCompleted(Buffer *buffer) if (!pending_.empty()) return; + complete(RequestComplete); + std::map buffers(std::move(bufferMap_)); camera_->requestCompleted.emit(this, buffers); delete this;