summaryrefslogtreecommitdiff
path: root/src/gstreamer/gstlibcamerasrc.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 /src/gstreamer/gstlibcamerasrc.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 'src/gstreamer/gstlibcamerasrc.cpp')
-rw-r--r--src/gstreamer/gstlibcamerasrc.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 1bfc2e2f..5001083a 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -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;