mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 12:32:29 +00:00
v4l2: Enable copy when no known allocation params
When there is no allocation parameters in the query, enable copy threshold. When this threshold is reached, the buffer pool will start copying when the pool reaches a critical level. If the driver supports CREATE_BUFS, this will be used instead.
This commit is contained in:
parent
dfb0ec6d4d
commit
6afd1c5d57
3 changed files with 26 additions and 7 deletions
|
@ -686,15 +686,11 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool)
|
|||
* falling back to copy if the pipeline needed more buffers. This also
|
||||
* prevent having to do REQBUFS(N)/REQBUFS(0) everytime configure is
|
||||
* called. */
|
||||
if (count != min_buffers) {
|
||||
GST_WARNING_OBJECT (pool, "using %u buffers instead of %u",
|
||||
count, min_buffers);
|
||||
if (count != min_buffers || pool->enable_copy_threshold) {
|
||||
GST_WARNING_OBJECT (pool,
|
||||
"Uncertain or not enough buffers, enabling copy threshold");
|
||||
min_buffers = count;
|
||||
copy_threshold = min_latency;
|
||||
|
||||
/* The initial minimum could be provide either by GstBufferPool or
|
||||
* driver needs. */
|
||||
min_buffers = count;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1863,3 +1859,11 @@ gst_v4l2_buffer_pool_set_other_pool (GstV4l2BufferPool * pool,
|
|||
gst_object_unref (pool->other_pool);
|
||||
pool->other_pool = gst_object_ref (other_pool);
|
||||
}
|
||||
|
||||
void
|
||||
gst_v4l2_buffer_pool_copy_at_threshold (GstV4l2BufferPool * pool, gboolean copy)
|
||||
{
|
||||
GST_OBJECT_LOCK (pool);
|
||||
pool->enable_copy_threshold = copy;
|
||||
GST_OBJECT_UNLOCK (pool);
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ struct _GstV4l2BufferPool
|
|||
GstVideoInfo caps_info; /* Default video information */
|
||||
|
||||
gboolean add_videometa; /* set if video meta should be added */
|
||||
gboolean enable_copy_threshold; /* If copy_threshold should be set */
|
||||
|
||||
guint min_latency; /* number of buffers we will hold */
|
||||
guint max_latency; /* number of buffers we can hold */
|
||||
|
@ -103,6 +104,8 @@ GstFlowReturn gst_v4l2_buffer_pool_process (GstV4l2BufferPool * bpool, Gst
|
|||
|
||||
void gst_v4l2_buffer_pool_set_other_pool (GstV4l2BufferPool * pool,
|
||||
GstBufferPool * other_pool);
|
||||
void gst_v4l2_buffer_pool_copy_at_threshold (GstV4l2BufferPool * pool,
|
||||
gboolean copy);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -3306,6 +3306,18 @@ gst_v4l2_object_decide_allocation (GstV4l2Object * obj, GstQuery * query)
|
|||
* driver and 1 more, so we don't endup up with everything downstream or
|
||||
* held by the decoder. */
|
||||
own_min = min + obj->min_buffers + 1;
|
||||
|
||||
/* If no allocation parameters where provided, allow for a little more
|
||||
* buffers and enable copy threshold */
|
||||
if (!update) {
|
||||
own_min += 3;
|
||||
gst_v4l2_buffer_pool_copy_at_threshold (GST_V4L2_BUFFER_POOL (pool),
|
||||
TRUE);
|
||||
} else {
|
||||
gst_v4l2_buffer_pool_copy_at_threshold (GST_V4L2_BUFFER_POOL (pool),
|
||||
FALSE);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* In this case we'll have to configure two buffer pool. For our buffer
|
||||
* pool, we'll need what the driver one, and one more, so we can dequeu */
|
||||
|
|
Loading…
Reference in a new issue