diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2019-04-09 20:41:40 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2019-04-18 15:36:37 +0200 |
commit | e671485989cc308998db98ba17fc35224aaf5e14 (patch) | |
tree | ef65b7f3c24b3e9c0c6fedf16de6561f00040f83 /src/libcamera/request.cpp | |
parent | 571d16b539df355a572a98bcbbdc2f9f1844a24d (diff) |
libcamera: camera: Validate Request before queueing it
Extend the Request::prepare() operation to validate the request before
preparing it. Return an error if the request is invalid, which for now
is limited to ensuring that the request contains at least one buffer.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/request.cpp')
-rw-r--r-- | src/libcamera/request.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index e5c25d2c..95818a26 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -115,10 +115,20 @@ Buffer *Request::findBuffer(Stream *stream) const */ /** - * \brief Prepare the resources for the completion handler + * \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; pending_.insert(buffer); |