[libcamera-devel] [PATCH] gstreamer: Be pedantic on srcpads access

Vedant Paranjape vedantparanjape160201 at gmail.com
Thu Jun 30 12:17:30 CEST 2022


Hello Umang,

Thanks for the patch. here's the rb tag with Laurent's suggestion on
commit message, since multi pads is already supported.

Reviewed-by: Vedant Paranjape <vedantparanjape160201 at gmail.com>


On Wed, Jun 29, 2022 at 2:56 PM Umang Jain <umang.jain at ideasonboard.com> wrote:
>
> While the "src" pad is added to the element, it is accessed
> via a index number. If multiple pads are added(in future)
> and tracked in state->srcpads_, the index might need re-adjusting.
>
> Use the std::vector::back() instead of index, which corresponds
> to std::vector::push_back() for tracking of pads. It also slightly
> helps with readability.
>
> No functional changes intended.
>
> Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
> ---
>  src/gstreamer/gstlibcamerasrc.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index 46fd02d2..4813ab96 100644
> --- a/src/gstreamer/gstlibcamerasrc.cpp
> +++ b/src/gstreamer/gstlibcamerasrc.cpp
> @@ -631,7 +631,7 @@ gst_libcamera_src_init(GstLibcameraSrc *self)
>         gst_task_set_lock(self->task, &self->stream_lock);
>
>         state->srcpads_.push_back(gst_pad_new_from_template(templ, "src"));
> -       gst_element_add_pad(GST_ELEMENT(self), state->srcpads_[0]);
> +       gst_element_add_pad(GST_ELEMENT(self), state->srcpads_.back());
>
>         /* C-style friend. */
>         state->src_ = self;
> --
> 2.31.1
>


More information about the libcamera-devel mailing list