[libcamera-devel] [PATCH 1/6] qcam: Tie FrameBufferAllocator to stream life

Kieran Bingham kieran.bingham at ideasonboard.com
Thu Feb 6 16:04:59 CET 2020


The FrameBufferAllocator must be deleted and reconstructed before performing
any reconfiguration of the stream.

Construct the allocator at startCapture, and destroy it during stopCapture so
that we can successfully stop and restart the stream.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 src/qcam/main_window.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index df51fa888342..38bc04a23b86 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -37,7 +37,6 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
 
 	ret = openCamera(cm);
 	if (!ret) {
-		allocator_ = FrameBufferAllocator::create(camera_);
 		ret = startCapture();
 	}
 
@@ -50,7 +49,6 @@ MainWindow::~MainWindow()
 {
 	if (camera_) {
 		stopCapture();
-		delete allocator_;
 		camera_->release();
 		camera_.reset();
 	}
@@ -171,6 +169,7 @@ int MainWindow::startCapture()
 
 	adjustSize();
 
+	allocator_ = FrameBufferAllocator::create(camera_);
 	ret = allocator_->allocate(stream);
 	if (ret < 0) {
 		std::cerr << "Failed to allocate capture buffers" << std::endl;
@@ -255,6 +254,8 @@ void MainWindow::stopCapture()
 	}
 	mappedBuffers_.clear();
 
+	delete allocator_;
+
 	isCapturing_ = false;
 
 	config_.reset();
-- 
2.20.1



More information about the libcamera-devel mailing list