[libcamera-devel,10/10] cam: Don't requeue requests when stopping stream

Message ID 20190228162913.6508-11-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • Rework request completion handling
Related show

Commit Message

Laurent Pinchart Feb. 28, 2019, 4:29 p.m. UTC
When stopping the stream all pending requests are cancelled, resulting
in the request completion signal being emitted with the request status
set appropriately. Check the request status in the request completion
slot and skip requeuing the request if it has been cancelled.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/cam/main.cpp | 3 +++
 1 file changed, 3 insertions(+)

Comments

Niklas Söderlund Feb. 28, 2019, 5:30 p.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2019-02-28 18:29:13 +0200, Laurent Pinchart wrote:
> When stopping the stream all pending requests are cancelled, resulting
> in the request completion signal being emitted with the request status
> set appropriately. Check the request status in the request completion
> slot and skip requeuing the request if it has been cancelled.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/cam/main.cpp | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index 4c2df583fe8e..c8e673e30c0b 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -102,6 +102,9 @@ static void requestComplete(Request *request, const std::map<Stream *, Buffer *>
>  {
>  	static uint64_t last = 0;
>  
> +	if (request->status() == Request::RequestCancelled)
> +		return;
> +
>  	Buffer *buffer = buffers.begin()->second;
>  
>  	double fps = buffer->timestamp() - last;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index 4c2df583fe8e..c8e673e30c0b 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -102,6 +102,9 @@  static void requestComplete(Request *request, const std::map<Stream *, Buffer *>
 {
 	static uint64_t last = 0;
 
+	if (request->status() == Request::RequestCancelled)
+		return;
+
 	Buffer *buffer = buffers.begin()->second;
 
 	double fps = buffer->timestamp() - last;