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>
This commit is contained in:
@@ -74,6 +74,8 @@ RequestWrap::~RequestWrap()
|
||||
if (item.second)
|
||||
gst_buffer_unref(item.second);
|
||||
}
|
||||
|
||||
delete request_;
|
||||
}
|
||||
|
||||
void RequestWrap::attachBuffer(GstBuffer *buffer)
|
||||
@@ -266,8 +268,8 @@ gst_libcamera_src_task_run(gpointer user_data)
|
||||
GstLibcameraSrc *self = GST_LIBCAMERA_SRC(user_data);
|
||||
GstLibcameraSrcState *state = self->state;
|
||||
|
||||
Request *request = state->cam_->createRequest();
|
||||
auto wrap = std::make_unique<RequestWrap>(request);
|
||||
std::unique_ptr<Request> request = state->cam_->createRequest();
|
||||
auto wrap = std::make_unique<RequestWrap>(request.get());
|
||||
for (GstPad *srcpad : state->srcpads_) {
|
||||
GstLibcameraPool *pool = gst_libcamera_pad_get_pool(srcpad);
|
||||
GstBuffer *buffer;
|
||||
@@ -280,8 +282,7 @@ gst_libcamera_src_task_run(gpointer user_data)
|
||||
* RequestWrap does not take ownership, and we won't be
|
||||
* queueing this one due to lack of buffers.
|
||||
*/
|
||||
delete request;
|
||||
request = nullptr;
|
||||
request.reset();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -291,8 +292,11 @@ gst_libcamera_src_task_run(gpointer user_data)
|
||||
if (request) {
|
||||
GLibLocker lock(GST_OBJECT(self));
|
||||
GST_TRACE_OBJECT(self, "Requesting buffers");
|
||||
state->cam_->queueRequest(request);
|
||||
state->cam_->queueRequest(request.get());
|
||||
state->requests_.push(std::move(wrap));
|
||||
|
||||
/* The request will be deleted in the completion handler. */
|
||||
request.release();
|
||||
}
|
||||
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
Reference in New Issue
Block a user