[libcamera-devel,04/21] qcam: main_window: Move request queuing to a separate function

Message ID 20200323142205.28342-5-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • qcam: Bypass format conversion when not required
Related show

Commit Message

Laurent Pinchart March 23, 2020, 2:21 p.m. UTC
Requests are requeued synchronously from the completion handler. To
prepare for delayed requeuing, move the queuing to a separate function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/qcam/main_window.cpp | 29 +++++++++++++++--------------
 src/qcam/main_window.h   |  1 +
 2 files changed, 16 insertions(+), 14 deletions(-)

Comments

Kieran Bingham March 23, 2020, 2:45 p.m. UTC | #1
Hi Laurent,

On 23/03/2020 14:21, Laurent Pinchart wrote:
> Requests are requeued synchronously from the completion handler. To
> prepare for delayed requeuing, move the queuing to a separate function.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/qcam/main_window.cpp | 29 +++++++++++++++--------------
>  src/qcam/main_window.h   |  1 +
>  2 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index e0668176e427..354a53367d0f 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -389,20 +389,7 @@ void MainWindow::requestComplete(Request *request)
>  
>  	display(buffer);
>  
> -	request = camera_->createRequest();
> -	if (!request) {
> -		std::cerr << "Can't create request" << std::endl;
> -		return;
> -	}
> -
> -	for (auto it = buffers.begin(); it != buffers.end(); ++it) {
> -		Stream *stream = it->first;
> -		FrameBuffer *buffer = it->second;
> -
> -		request->addBuffer(stream, buffer);
> -	}
> -
> -	camera_->queueRequest(request);
> +	queueRequest(buffer);
>  }
>  
>  int MainWindow::display(FrameBuffer *buffer)
> @@ -417,3 +404,17 @@ int MainWindow::display(FrameBuffer *buffer)
>  
>  	return 0;
>  }
> +
> +void MainWindow::queueRequest(FrameBuffer *buffer)
> +{
> +	Request *request = camera_->createRequest();
> +	if (!request) {
> +		std::cerr << "Can't create request" << std::endl;
> +		return;
> +	}
> +
> +	Stream *stream = config_->at(0).stream();
> +	request->addBuffer(stream, buffer);
> +
> +	camera_->queueRequest(request);
> +}
> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
> index 40aa10aaea8e..720a3393e3dc 100644
> --- a/src/qcam/main_window.h
> +++ b/src/qcam/main_window.h
> @@ -58,6 +58,7 @@ private:
>  
>  	void requestComplete(Request *request);
>  	int display(FrameBuffer *buffer);
> +	void queueRequest(FrameBuffer *buffer);
>  
>  	QString title_;
>  	QTimer titleTimer_;
>

Patch

diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index e0668176e427..354a53367d0f 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -389,20 +389,7 @@  void MainWindow::requestComplete(Request *request)
 
 	display(buffer);
 
-	request = camera_->createRequest();
-	if (!request) {
-		std::cerr << "Can't create request" << std::endl;
-		return;
-	}
-
-	for (auto it = buffers.begin(); it != buffers.end(); ++it) {
-		Stream *stream = it->first;
-		FrameBuffer *buffer = it->second;
-
-		request->addBuffer(stream, buffer);
-	}
-
-	camera_->queueRequest(request);
+	queueRequest(buffer);
 }
 
 int MainWindow::display(FrameBuffer *buffer)
@@ -417,3 +404,17 @@  int MainWindow::display(FrameBuffer *buffer)
 
 	return 0;
 }
+
+void MainWindow::queueRequest(FrameBuffer *buffer)
+{
+	Request *request = camera_->createRequest();
+	if (!request) {
+		std::cerr << "Can't create request" << std::endl;
+		return;
+	}
+
+	Stream *stream = config_->at(0).stream();
+	request->addBuffer(stream, buffer);
+
+	camera_->queueRequest(request);
+}
diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
index 40aa10aaea8e..720a3393e3dc 100644
--- a/src/qcam/main_window.h
+++ b/src/qcam/main_window.h
@@ -58,6 +58,7 @@  private:
 
 	void requestComplete(Request *request);
 	int display(FrameBuffer *buffer);
+	void queueRequest(FrameBuffer *buffer);
 
 	QString title_;
 	QTimer titleTimer_;