[libcamera-devel,v2,09/16] libcamera: Stop using Stream::bufferPool to get the number of buffers

Message ID 20190713172351.25452-10-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • Add support for external buffers
Related show

Commit Message

Laurent Pinchart July 13, 2019, 5:23 p.m. UTC
The cam and qcam applications, as well as the camera capture test case,
access the Stream::bufferPool in order to know how many requests to
initially queue. As part of an effort to remove access to the buffer
pool from applications, use the buffer count from the stream
configuration instead.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/cam/capture.cpp      | 6 ++----
 src/qcam/main_window.cpp | 3 +--
 test/camera/capture.cpp  | 3 +--
 3 files changed, 4 insertions(+), 8 deletions(-)

Comments

Niklas Söderlund July 14, 2019, 10:47 a.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2019-07-13 20:23:44 +0300, Laurent Pinchart wrote:
> The cam and qcam applications, as well as the camera capture test case,
> access the Stream::bufferPool in order to know how many requests to
> initially queue. As part of an effort to remove access to the buffer
> pool from applications, use the buffer count from the stream
> configuration instead.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

> ---
>  src/cam/capture.cpp      | 6 ++----
>  src/qcam/main_window.cpp | 3 +--
>  test/camera/capture.cpp  | 3 +--
>  3 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
> index 1cf59063c93b..66ec1abaa5ac 100644
> --- a/src/cam/capture.cpp
> +++ b/src/cam/capture.cpp
> @@ -74,10 +74,8 @@ int Capture::capture(EventLoop *loop)
>  
>  	/* Identify the stream with the least number of buffers. */
>  	unsigned int nbuffers = UINT_MAX;
> -	for (StreamConfiguration &cfg : *config_) {
> -		Stream *stream = cfg.stream();
> -		nbuffers = std::min(nbuffers, stream->bufferPool().count());
> -	}
> +	for (StreamConfiguration &cfg : *config_)
> +		nbuffers = std::min(nbuffers, cfg.bufferCount);
>  
>  	/*
>  	 * TODO: make cam tool smarter to support still capture by for
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 6ecf30e33bcf..7023e1158fb6 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -140,9 +140,8 @@ int MainWindow::startCapture()
>  		return ret;
>  	}
>  
> -	BufferPool &pool = stream->bufferPool();
>  	std::vector<Request *> requests;
> -	for (unsigned int i = 0; i < pool.count(); ++i) {
> +	for (unsigned int i = 0; i < cfg.bufferCount; ++i) {
>  		Request *request = camera_->createRequest();
>  		if (!request) {
>  			std::cerr << "Can't create request" << std::endl;
> diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp
> index ff1cbd6cbac0..e6bf7a8d9ebb 100644
> --- a/test/camera/capture.cpp
> +++ b/test/camera/capture.cpp
> @@ -80,9 +80,8 @@ protected:
>  		}
>  
>  		Stream *stream = cfg.stream();
> -		BufferPool &pool = stream->bufferPool();
>  		std::vector<Request *> requests;
> -		for (unsigned int i = 0; i < pool.count(); ++i) {
> +		for (unsigned int i = 0; i < cfg.bufferCount; ++i) {
>  			Request *request = camera_->createRequest();
>  			if (!request) {
>  				cout << "Failed to create request" << endl;
> -- 
> 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/capture.cpp b/src/cam/capture.cpp
index 1cf59063c93b..66ec1abaa5ac 100644
--- a/src/cam/capture.cpp
+++ b/src/cam/capture.cpp
@@ -74,10 +74,8 @@  int Capture::capture(EventLoop *loop)
 
 	/* Identify the stream with the least number of buffers. */
 	unsigned int nbuffers = UINT_MAX;
-	for (StreamConfiguration &cfg : *config_) {
-		Stream *stream = cfg.stream();
-		nbuffers = std::min(nbuffers, stream->bufferPool().count());
-	}
+	for (StreamConfiguration &cfg : *config_)
+		nbuffers = std::min(nbuffers, cfg.bufferCount);
 
 	/*
 	 * TODO: make cam tool smarter to support still capture by for
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 6ecf30e33bcf..7023e1158fb6 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -140,9 +140,8 @@  int MainWindow::startCapture()
 		return ret;
 	}
 
-	BufferPool &pool = stream->bufferPool();
 	std::vector<Request *> requests;
-	for (unsigned int i = 0; i < pool.count(); ++i) {
+	for (unsigned int i = 0; i < cfg.bufferCount; ++i) {
 		Request *request = camera_->createRequest();
 		if (!request) {
 			std::cerr << "Can't create request" << std::endl;
diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp
index ff1cbd6cbac0..e6bf7a8d9ebb 100644
--- a/test/camera/capture.cpp
+++ b/test/camera/capture.cpp
@@ -80,9 +80,8 @@  protected:
 		}
 
 		Stream *stream = cfg.stream();
-		BufferPool &pool = stream->bufferPool();
 		std::vector<Request *> requests;
-		for (unsigned int i = 0; i < pool.count(); ++i) {
+		for (unsigned int i = 0; i < cfg.bufferCount; ++i) {
 			Request *request = camera_->createRequest();
 			if (!request) {
 				cout << "Failed to create request" << endl;