v4l2bufferpool: Only resurrect the right amount of buffers
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2bufferpool.c
index 6a3f5ea..f4daa93 100644 (file)
@@ -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;