@@ -21,6 +21,7 @@ Capture::Capture(std::shared_ptr<Camera> camera)
Capture::~Capture()
{
stop();
+ unconfigure();
}
void Capture::configure(libcamera::Span<const libcamera::StreamRole> roles)
@@ -50,6 +51,20 @@ void Capture::configure(libcamera::Span<const libcamera::StreamRole> roles)
ASSERT_EQ(config->validate(), CameraConfiguration::Valid);
ASSERT_EQ(camera_->configure(config.get()), 0);
+ const auto bufferCount = config->at(0).bufferCount;
+
+ for (const auto &cfg : *config) {
+ Stream *stream = cfg.stream();
+
+ ASSERT_GE(allocator_.allocate(stream), 0)
+ << "Failed to allocate buffers";
+
+ ASSERT_EQ(allocator_.buffers(stream).size(), bufferCount)
+ << "Mismatching buffer count";
+ }
+
+ ASSERT_TRUE(allocator_.allocated());
+
config_ = std::move(config);
}
@@ -112,7 +127,7 @@ void Capture::start()
{
assert(config_);
assert(!config_->empty());
- assert(!allocator_.allocated());
+ assert(allocator_.allocated());
assert(requests_.empty());
const auto bufferCount = config_->at(0).bufferCount;
@@ -132,9 +147,6 @@ void Capture::start()
for (const auto &cfg : *config_) {
Stream *stream = cfg.stream();
- int count = allocator_.allocate(stream);
- ASSERT_GE(count, 0) << "Failed to allocate buffers";
-
const auto &buffers = allocator_.buffers(stream);
ASSERT_EQ(buffers.size(), bufferCount) << "Mismatching buffer count";
@@ -144,8 +156,6 @@ void Capture::start()
}
}
- ASSERT_TRUE(allocator_.allocated());
-
camera_->requestCompleted.connect(this, &Capture::requestComplete);
ASSERT_EQ(camera_->start(), 0) << "Failed to start camera";
@@ -161,6 +171,12 @@ void Capture::stop()
camera_->requestCompleted.disconnect(this);
requests_.clear();
+}
+
+void Capture::unconfigure()
+{
+ if (!config_ || !allocator_.allocated())
+ return;
for (const auto &cfg : *config_) {
EXPECT_EQ(allocator_.free(cfg.stream()), 0)
@@ -28,6 +28,7 @@ private:
void start();
void stop();
+ void unconfigure();
int queueRequest(libcamera::Request *request);
void requestComplete(libcamera::Request *request);
Most pipeline handlers release buffers when a camera is stopped. However, the raspberry pi pipelines do not do that. Hence they are incompatible with the current model and all "CaptureStartStop" tests fail because lc-compliance allocates buffers before starting and releases them after stopping. Fix this by allocating buffers after the camera is configured, and do not release them after stopping. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- src/apps/lc-compliance/helpers/capture.cpp | 28 +++++++++++++++++----- src/apps/lc-compliance/helpers/capture.h | 1 + 2 files changed, 23 insertions(+), 6 deletions(-)