[libcamera-devel,v10,13/19] lc-compliance: Move buffer allocation to separate function
diff mbox series

Message ID 20221228223003.2265712-14-paul.elder@ideasonboard.com
State New
Headers show
Series
  • lc-compliance: Add test to queue more requests than hardware depth
Related show

Commit Message

Paul Elder Dec. 28, 2022, 10:29 p.m. UTC
From: NĂ­colas F. R. A. Prado <nfraprado@collabora.com>

Move buffer allocation to its own function and with an optional count
argument so tests can specify how many buffers to allocate. When count
is omitted, allocate MinimumRequests buffers.

Signed-off-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v9:
- rebased

Changes in v8:
- Made SimpleCapture::allocateBuffers() a single function with an optional parameter

Changes in v5:
- New
---
 src/apps/lc-compliance/capture_test.cpp   |  8 +++++++-
 src/apps/lc-compliance/simple_capture.cpp | 16 ++++++++++------
 src/apps/lc-compliance/simple_capture.h   |  1 +
 3 files changed, 18 insertions(+), 7 deletions(-)

Patch
diff mbox series

diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp
index 1dcfcf92..923395cf 100644
--- a/src/apps/lc-compliance/capture_test.cpp
+++ b/src/apps/lc-compliance/capture_test.cpp
@@ -87,6 +87,8 @@  TEST_P(SingleStream, Capture)
 
 	capture.configure(role);
 
+	capture.allocateBuffers();
+
 	capture.capture(numRequests);
 }
 
@@ -106,8 +108,10 @@  TEST_P(SingleStream, CaptureStartStop)
 
 	capture.configure(role);
 
-	for (unsigned int starts = 0; starts < numRepeats; starts++)
+	for (unsigned int starts = 0; starts < numRepeats; starts++) {
+		capture.allocateBuffers();
 		capture.capture(numRequests);
+	}
 }
 
 /*
@@ -125,6 +129,8 @@  TEST_P(SingleStream, UnbalancedStop)
 
 	capture.configure(role);
 
+	capture.allocateBuffers();
+
 	capture.capture(numRequests);
 }
 
diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/simple_capture.cpp
index be495986..1e3e816a 100644
--- a/src/apps/lc-compliance/simple_capture.cpp
+++ b/src/apps/lc-compliance/simple_capture.cpp
@@ -44,16 +44,20 @@  void SimpleCapture::configure(StreamRole role)
 	}
 }
 
-void SimpleCapture::start()
+void SimpleCapture::allocateBuffers(unsigned int count)
 {
-	unsigned int bufferCount =
-		camera_->properties().get(properties::MinimumRequests).value();
+	if (!count)
+		count = camera_->properties().get(properties::MinimumRequests).value();
+
 	Stream *stream = config_->at(0).stream();
-	int count = allocator_->allocate(stream, bufferCount);
+	int allocatedCount = allocator_->allocate(stream, count);
 
-	ASSERT_GE(count, 0) << "Failed to allocate buffers";
-	EXPECT_EQ(count, bufferCount) << "Allocated less buffers than expected";
+	ASSERT_GE(allocatedCount, 0) << "Failed to allocate buffers";
+	EXPECT_EQ(allocatedCount, count) << "Allocated less buffers than expected";
+}
 
+void SimpleCapture::start()
+{
 	camera_->requestCompleted.connect(this, &SimpleCapture::requestComplete);
 
 	ASSERT_EQ(camera_->start(), 0) << "Failed to start camera";
diff --git a/src/apps/lc-compliance/simple_capture.h b/src/apps/lc-compliance/simple_capture.h
index 2911d601..b3091547 100644
--- a/src/apps/lc-compliance/simple_capture.h
+++ b/src/apps/lc-compliance/simple_capture.h
@@ -17,6 +17,7 @@  class SimpleCapture
 {
 public:
 	void configure(libcamera::StreamRole role);
+	void allocateBuffers(unsigned int count = 0);
 
 protected:
 	SimpleCapture(std::shared_ptr<libcamera::Camera> camera);