Message ID | 20190228162913.6508-9-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your patch. On 2019-02-28 18:29:11 +0200, Laurent Pinchart wrote: > 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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > 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<Stream *, Buffer *> &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<Stream *, Buffer *> bufferMap_; > std::unordered_set<Buffer *> 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<Stream *, Buffer *> buffers(std::move(bufferMap_)); > camera_->requestCompleted.emit(this, buffers); > delete this; > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
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<Stream *, Buffer *> &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<Stream *, Buffer *> bufferMap_; std::unordered_set<Buffer *> 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<Stream *, Buffer *> buffers(std::move(bufferMap_)); camera_->requestCompleted.emit(this, buffers); delete this;
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 <laurent.pinchart@ideasonboard.com> --- include/libcamera/request.h | 12 +++++++++++ src/libcamera/request.cpp | 40 ++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-)