[libcamera-devel] [PATCH v2 2/3] gstreamer: Add GstLibcameraSrcState::clearRequests method

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Dec 7 00:25:40 CET 2023


Hi Jaslo,

Thank you for the patch.

On Thu, Nov 30, 2023 at 04:43:09PM +0100, Jaslo Ziska via libcamera-devel wrote:
> Add a clearRequests method to GstLibcameraSrcState which clears the

s/method/function/ (the C++ language has functions, not methods)

> GstLibcameraSrcState::completedRequests_ queue.
> 
> Use this new method in gst_libcamera_src_task_leave instead of doing it

Same here.

> manually.
> 
> Signed-off-by: Jaslo Ziska <jaslo at ziska.de>

This change by itself doesn't seem like a major improvement, but its
usage in patch 3/3 makes it worth it.

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
>  src/gstreamer/gstlibcamerasrc.cpp | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index e57ba52f..d448a750 100644
> --- a/src/gstreamer/gstlibcamerasrc.cpp
> +++ b/src/gstreamer/gstlibcamerasrc.cpp
> @@ -133,6 +133,7 @@ struct GstLibcameraSrcState {
>  	int queueRequest();
>  	void requestCompleted(Request *request);
>  	int processRequest();
> +	void clearRequests();
>  };
>  
>  struct _GstLibcameraSrc {
> @@ -318,6 +319,12 @@ int GstLibcameraSrcState::processRequest()
>  	return err;
>  }
>  
> +void GstLibcameraSrcState::clearRequests()
> +{
> +	GLibLocker locker(&lock_);
> +	completedRequests_ = {};
> +}
> +
>  static bool
>  gst_libcamera_src_open(GstLibcameraSrc *self)
>  {
> @@ -629,11 +636,7 @@ gst_libcamera_src_task_leave([[maybe_unused]] GstTask *task,
>  	GST_DEBUG_OBJECT(self, "Streaming thread is about to stop");
>  
>  	state->cam_->stop();
> -
> -	{
> -		GLibLocker locker(&state->lock_);
> -		state->completedRequests_ = {};
> -	}
> +	state->clearRequests();
>  
>  	{
>  		GLibRecLocker locker(&self->stream_lock);

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list