[libcamera-devel,v5,4/7] libcamera: request: Add empty() method

Message ID 20190415231859.9747-5-jacopo@jmondi.org
State Superseded
Headers show
Series
  • libcamera: Framework changes to prepare for multiple streams support
Related show

Commit Message

Jacopo Mondi April 15, 2019, 11:18 p.m. UTC
Add method to verify if a request has pending buffers yet to be
completed or it is empty and ready from completion.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 include/libcamera/request.h |  2 ++
 src/libcamera/request.cpp   | 11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart April 16, 2019, 11:16 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Apr 16, 2019 at 01:18:56AM +0200, Jacopo Mondi wrote:
> Add method to verify if a request has pending buffers yet to be
> completed or it is empty and ready from completion.
> 
> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  include/libcamera/request.h |  2 ++
>  src/libcamera/request.cpp   | 11 +++++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/include/libcamera/request.h b/include/libcamera/request.h
> index 0dbd425115e8..6f97aa177ae0 100644
> --- a/include/libcamera/request.h
> +++ b/include/libcamera/request.h
> @@ -37,6 +37,8 @@ public:
>  
>  	Status status() const { return status_; }
>  
> +	bool empty() const { return pending_.empty(); }

How about hasPendingBuffers() ?

> +
>  private:
>  	friend class Camera;
>  	friend class PipelineHandler;
> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
> index e0e77e972411..33055c5ac533 100644
> --- a/src/libcamera/request.cpp
> +++ b/src/libcamera/request.cpp
> @@ -106,6 +106,13 @@ Buffer *Request::findBuffer(Stream *stream) const
>   * \return The request completion status
>   */
>  
> +/**
> + * \fn Request::empty()
> + * \brief Retrieve if a request has buffers yet to be completed
> + *
> + * \return True if no buffer is pending for completion, false otherwise
> + */
> +
>  /**
>   * \brief Prepare the resources for the completion handler
>   */
> @@ -127,7 +134,7 @@ int Request::prepare()
>   */
>  void Request::complete(Status status)
>  {
> -	ASSERT(pending_.empty());
> +	ASSERT(empty());
>  	status_ = status;
>  }
>  
> @@ -149,7 +156,7 @@ bool Request::completeBuffer(Buffer *buffer)
>  	int ret = pending_.erase(buffer);
>  	ASSERT(ret == 1);
>  
> -	return pending_.empty();
> +	return empty();
>  }
>  
>  } /* namespace libcamera */

Patch

diff --git a/include/libcamera/request.h b/include/libcamera/request.h
index 0dbd425115e8..6f97aa177ae0 100644
--- a/include/libcamera/request.h
+++ b/include/libcamera/request.h
@@ -37,6 +37,8 @@  public:
 
 	Status status() const { return status_; }
 
+	bool empty() const { return pending_.empty(); }
+
 private:
 	friend class Camera;
 	friend class PipelineHandler;
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index e0e77e972411..33055c5ac533 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -106,6 +106,13 @@  Buffer *Request::findBuffer(Stream *stream) const
  * \return The request completion status
  */
 
+/**
+ * \fn Request::empty()
+ * \brief Retrieve if a request has buffers yet to be completed
+ *
+ * \return True if no buffer is pending for completion, false otherwise
+ */
+
 /**
  * \brief Prepare the resources for the completion handler
  */
@@ -127,7 +134,7 @@  int Request::prepare()
  */
 void Request::complete(Status status)
 {
-	ASSERT(pending_.empty());
+	ASSERT(empty());
 	status_ = status;
 }
 
@@ -149,7 +156,7 @@  bool Request::completeBuffer(Buffer *buffer)
 	int ret = pending_.erase(buffer);
 	ASSERT(ret == 1);
 
-	return pending_.empty();
+	return empty();
 }
 
 } /* namespace libcamera */