summaryrefslogtreecommitdiff
path: root/test/camera/capture.cpp
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2020-09-23 19:05:41 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2020-10-12 11:32:40 +0900
commitc753223ad6b90550fae31aedd79fbedc13da2e75 (patch)
tree957c83eb734fbfc633fd3a0a39c8339695323fe4 /test/camera/capture.cpp
parent05cdef27ab766a199a256c73ef4b338ce4f4dac5 (diff)
libcamera, android, cam, gstreamer, qcam, v4l2: Reuse Request
Allow reuse of the Request object by implementing reuse(). This means the applications now have the responsibility of freeing the Request objects, so make all libcamera users (cam, qcam, v4l2-compat, gstreamer, android) do so. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'test/camera/capture.cpp')
-rw-r--r--test/camera/capture.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp
index 51bbd258..c0770801 100644
--- a/test/camera/capture.cpp
+++ b/test/camera/capture.cpp
@@ -52,7 +52,7 @@ protected:
const Stream *stream = buffers.begin()->first;
FrameBuffer *buffer = buffers.begin()->second;
- request = camera_->createRequest();
+ request->reuse();
request->addBuffer(stream, buffer);
camera_->queueRequest(request);
}
@@ -98,9 +98,8 @@ protected:
if (ret < 0)
return TestFail;
- std::vector<Request *> requests;
for (const std::unique_ptr<FrameBuffer> &buffer : allocator_->buffers(stream)) {
- Request *request = camera_->createRequest();
+ std::unique_ptr<Request> request = camera_->createRequest();
if (!request) {
cout << "Failed to create request" << endl;
return TestFail;
@@ -111,7 +110,7 @@ protected:
return TestFail;
}
- requests.push_back(request);
+ requests_.push_back(std::move(request));
}
completeRequestsCount_ = 0;
@@ -125,8 +124,8 @@ protected:
return TestFail;
}
- for (Request *request : requests) {
- if (camera_->queueRequest(request)) {
+ for (std::unique_ptr<Request> &request : requests_) {
+ if (camera_->queueRequest(request.get())) {
cout << "Failed to queue request" << endl;
return TestFail;
}
@@ -161,6 +160,8 @@ protected:
return TestPass;
}
+ std::vector<std::unique_ptr<Request>> requests_;
+
std::unique_ptr<CameraConfiguration> config_;
FrameBufferAllocator *allocator_;
};