summaryrefslogtreecommitdiff
path: root/src/apps/lc-compliance/simple_capture.cpp
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2022-11-29 20:00:05 +0900
committerKieran Bingham <kieran.bingham@ideasonboard.com>2022-12-09 16:02:56 +0000
commit9a913eb9107483fcea01bd0e82c21e3733a5ddb2 (patch)
treeeaf88b1a31cbfdcaf5a17cb6246e65b9679b09a4 /src/apps/lc-compliance/simple_capture.cpp
parenta6b1ff2e6caa632fe041e3eae569acb861e3353b (diff)
lc-compliance: simple_capture: Free Requests properly
In the simple capture tests, in the capture functions, the Requests were auto-deallocated by the function going out of scope after the test completed. However, before the end of the scope, the Framebuffers that the Requests referred to were manually freed. Thus when the Requests were deallocated, they tried to cancel their Framebuffers, which involve setting the status to cancelled, which obviously causes a segfault because the Framebuffers had already been freed. Fix this by moving the list of Requests to a member variable and deallocating them before deallocating the Framebuffers at stop() time. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com> Tested-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/apps/lc-compliance/simple_capture.cpp')
-rw-r--r--src/apps/lc-compliance/simple_capture.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/simple_capture.cpp
index ab5cb35c..cf4d7cf3 100644
--- a/src/apps/lc-compliance/simple_capture.cpp
+++ b/src/apps/lc-compliance/simple_capture.cpp
@@ -65,6 +65,7 @@ void SimpleCapture::stop()
camera_->requestCompleted.disconnect(this);
Stream *stream = config_->at(0).stream();
+ requests_.clear();
allocator_->free(stream);
}
@@ -95,7 +96,6 @@ void SimpleCaptureBalanced::capture(unsigned int numRequests)
captureLimit_ = numRequests;
/* Queue the recommended number of reqeuests. */
- std::vector<std::unique_ptr<libcamera::Request>> requests;
for (const std::unique_ptr<FrameBuffer> &buffer : buffers) {
std::unique_ptr<Request> request = camera_->createRequest();
ASSERT_TRUE(request) << "Can't create request";
@@ -104,7 +104,7 @@ void SimpleCaptureBalanced::capture(unsigned int numRequests)
ASSERT_EQ(queueRequest(request.get()), 0) << "Failed to queue request";
- requests.push_back(std::move(request));
+ requests_.push_back(std::move(request));
}
/* Run capture session. */
@@ -156,7 +156,6 @@ void SimpleCaptureUnbalanced::capture(unsigned int numRequests)
captureLimit_ = numRequests;
/* Queue the recommended number of reqeuests. */
- std::vector<std::unique_ptr<libcamera::Request>> requests;
for (const std::unique_ptr<FrameBuffer> &buffer : buffers) {
std::unique_ptr<Request> request = camera_->createRequest();
ASSERT_TRUE(request) << "Can't create request";
@@ -165,7 +164,7 @@ void SimpleCaptureUnbalanced::capture(unsigned int numRequests)
ASSERT_EQ(camera_->queueRequest(request.get()), 0) << "Failed to queue request";
- requests.push_back(std::move(request));
+ requests_.push_back(std::move(request));
}
/* Run capture session. */