mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-26 10:05:08 +03:00
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>
This commit is contained in:
parent
a6b1ff2e6c
commit
9a913eb910
2 changed files with 4 additions and 4 deletions
|
@ -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. */
|
||||
|
|
|
@ -32,6 +32,7 @@ protected:
|
|||
std::shared_ptr<libcamera::Camera> camera_;
|
||||
std::unique_ptr<libcamera::FrameBufferAllocator> allocator_;
|
||||
std::unique_ptr<libcamera::CameraConfiguration> config_;
|
||||
std::vector<std::unique_ptr<libcamera::Request>> requests_;
|
||||
};
|
||||
|
||||
class SimpleCaptureBalanced : public SimpleCapture
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue