From: Nicolas Dufresne Date: Fri, 26 Jun 2020 18:48:14 +0000 (-0400) Subject: v4l2bufferpool: Only resurrect the right amount of buffers X-Git-Tag: accepted/tizen/unified/20210127.024855^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fgst-plugins-good.git;a=commitdiff_plain;h=fd65ebb9745d2ba91772e96e6dac80e117d0cc85 v4l2bufferpool: Only resurrect the right amount of buffers On streamon, we need to resurrect (queue back) some buffers, as during flushign seek we'd endup with an empty queued. We initially started with resurrecting as many as we could without blocking, but that miss-behaved with dynamic CREATE_BUFS, causing the pool to grow dramatically. This was limited by the number of allocated buffers, but this still tried to resurrect too many buffers for the first run, as activating the pool will queued buffers. In this patch, we calculte the missing detal in the queue and only try and resurrect that amount of buffers. Change-Id: I3257c66f4049c55fa714ed639eeb56053b805277 Part-of: Signed-off-by: Jeongmo Yang --- diff --git a/packaging/gst-plugins-good.spec b/packaging/gst-plugins-good.spec index b2c52b9..9e7e945 100644 --- a/packaging/gst-plugins-good.spec +++ b/packaging/gst-plugins-good.spec @@ -3,7 +3,7 @@ Name: gst-plugins-good Version: 1.16.2 -Release: 15 +Release: 16 License: LGPL-2.1+ Summary: GStreamer Streaming-Media Framework Plug-Ins Url: http://gstreamer.freedesktop.org/ diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 6a3f5ea..f4daa93 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -717,18 +717,21 @@ gst_v4l2_buffer_pool_streamon (GstV4l2BufferPool * pool) case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_DMABUF: case GST_V4L2_IO_DMABUF_IMPORT: -#ifndef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER if (!V4L2_TYPE_IS_OUTPUT (pool->obj->type)) { - guint i; + guint num_queued; + guint i, n = 0; + + num_queued = g_atomic_int_get (&pool->num_queued); + if (num_queued < pool->num_allocated) + n = pool->num_allocated - num_queued; /* For captures, we need to enqueue buffers before we start streaming, * so the driver don't underflow immediatly. As we have put then back * into the base class queue, resurrect them, then releasing will queue * them back. */ - for (i = 0; i < pool->num_allocated; i++) + for (i = 0; i < n; i++) gst_v4l2_buffer_pool_resurrect_buffer (pool); } -#endif /* TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER */ if (obj->ioctl (pool->video_fd, VIDIOC_STREAMON, &obj->type) < 0) goto streamon_failed;