From patchwork Thu Jun 30 00:02:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16443 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 96A4DBD808 for ; Thu, 30 Jun 2022 00:03:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2420B65641; Thu, 30 Jun 2022 02:03:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656547409; bh=KArOEihn7NjCMl3nOghpphHMjMcqw6JxyM+mUR+IgcA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=eTMnab/NgkL+IVnFs4ASg7p3YdFIPOfepcj5UYlmT9gWI3+Wi7c97qhqVyjtt3hu/ 8BUjfafMeoLsR3JY2KyRVBsW1jXOdP86o+siRkvZpblNmEV3fxGHajTJQ4rJlJYCRp GANNX7KGMcknewGPEj7s7bDDHKXdK4+IMNdKTgK4xFyFvqm5oZPbRfIKHVR6aB8Ggu 6vQO5XY5GEwR6wXrUZeid6FZ4qYp5yFbazF6X8HA5K+NR5XWF2C1Jye/SP1CZ9VwAi fzQKAP0et9Zcol6O2Z8iOsLK6uuWf3tGZbNYbtCOnx6zd5vSsS/AuhjrkAlpNIoGY/ yRQXPTXGxIv6g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0EB6265643 for ; Thu, 30 Jun 2022 02:03:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JvwOTLAY"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9CDDE6D1; Thu, 30 Jun 2022 02:03:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1656547397; bh=KArOEihn7NjCMl3nOghpphHMjMcqw6JxyM+mUR+IgcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JvwOTLAYiliiKgvUepWFyAhRaW6px6mXzOS6+CICfmCGBMboYdlGXwsU1apKD3g8x q4Mk5lJ0VrMB1DyyW3917F8CJAl3gbitk+67yDAFf6+R3isH7egny+DOZ6z/FmEQKB j8D6MFdv4M+eK1bH1DJiARDNfUZHRnQh62GuQXAo= To: libcamera-devel@lists.libcamera.org Date: Thu, 30 Jun 2022 03:02:46 +0300 Message-Id: <20220630000251.31295-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630000251.31295-1-laurent.pinchart@ideasonboard.com> References: <20220630000251.31295-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/12] gstreamer: Combine the two pad loops in the task run handler X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Nicolas Dufresne Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This simplifies the code, and allows removing the internal queue in the GstLibcameraPad object. Signed-off-by: Laurent Pinchart Reviewed-by: Nicolas Dufresne Reviewed-by: Umang Jain --- src/gstreamer/gstlibcamerapad.cpp | 35 ------------------------------- src/gstreamer/gstlibcamerapad.h | 6 ------ src/gstreamer/gstlibcamerasrc.cpp | 11 ++++------ 3 files changed, 4 insertions(+), 48 deletions(-) diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp index c00e81c8966e..87b4057ac101 100644 --- a/src/gstreamer/gstlibcamerapad.cpp +++ b/src/gstreamer/gstlibcamerapad.cpp @@ -18,7 +18,6 @@ struct _GstLibcameraPad { GstPad parent; StreamRole role; GstLibcameraPool *pool; - GQueue pending_buffers; GstClockTime latency; }; @@ -155,40 +154,6 @@ gst_libcamera_pad_get_stream(GstPad *pad) return nullptr; } -void -gst_libcamera_pad_queue_buffer(GstPad *pad, GstBuffer *buffer) -{ - auto *self = GST_LIBCAMERA_PAD(pad); - GLibLocker lock(GST_OBJECT(self)); - - g_queue_push_head(&self->pending_buffers, buffer); -} - -GstFlowReturn -gst_libcamera_pad_push_pending(GstPad *pad) -{ - auto *self = GST_LIBCAMERA_PAD(pad); - GstBuffer *buffer; - - { - GLibLocker lock(GST_OBJECT(self)); - buffer = GST_BUFFER(g_queue_pop_tail(&self->pending_buffers)); - } - - if (!buffer) - return GST_FLOW_OK; - - return gst_pad_push(pad, buffer); -} - -bool -gst_libcamera_pad_has_pending(GstPad *pad) -{ - auto *self = GST_LIBCAMERA_PAD(pad); - GLibLocker lock(GST_OBJECT(self)); - return self->pending_buffers.length > 0; -} - void gst_libcamera_pad_set_latency(GstPad *pad, GstClockTime latency) { diff --git a/src/gstreamer/gstlibcamerapad.h b/src/gstreamer/gstlibcamerapad.h index 207695173313..103ee57ab384 100644 --- a/src/gstreamer/gstlibcamerapad.h +++ b/src/gstreamer/gstlibcamerapad.h @@ -25,10 +25,4 @@ void gst_libcamera_pad_set_pool(GstPad *pad, GstLibcameraPool *pool); libcamera::Stream *gst_libcamera_pad_get_stream(GstPad *pad); -void gst_libcamera_pad_queue_buffer(GstPad *pad, GstBuffer *buffer); - -GstFlowReturn gst_libcamera_pad_push_pending(GstPad *pad); - -bool gst_libcamera_pad_has_pending(GstPad *pad); - void gst_libcamera_pad_set_latency(GstPad *pad, GstClockTime latency); diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 2cb915637874..8c1cd7017d98 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -311,6 +311,9 @@ gst_libcamera_src_task_run(gpointer user_data) return; } + GstFlowReturn ret = GST_FLOW_OK; + gst_flow_combiner_reset(self->flow_combiner); + for (GstPad *srcpad : state->srcpads_) { Stream *stream = gst_libcamera_pad_get_stream(srcpad); GstBuffer *buffer = wrap->detachBuffer(stream); @@ -327,13 +330,7 @@ gst_libcamera_src_task_run(gpointer user_data) GST_BUFFER_OFFSET(buffer) = fb->metadata().sequence; GST_BUFFER_OFFSET_END(buffer) = fb->metadata().sequence; - gst_libcamera_pad_queue_buffer(srcpad, buffer); - } - - GstFlowReturn ret = GST_FLOW_OK; - gst_flow_combiner_reset(self->flow_combiner); - for (GstPad *srcpad : state->srcpads_) { - ret = gst_libcamera_pad_push_pending(srcpad); + ret = gst_pad_push(srcpad, buffer); ret = gst_flow_combiner_update_pad_flow(self->flow_combiner, srcpad, ret); }