mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 06:16:36 +00:00
v4l2bufferpool: Don't ref queued output buffer
This partly revert to the old 1.2 behavior. Instead of keeping a reference to the output buffer queued, we simply release them but don't forward it to GstBufferPool. This way, the buffer pool don't need to be flushed to be stopped. https://bugzilla.gnome.org/show_bug.cgi?id=742074
This commit is contained in:
parent
a4b961e275
commit
bbcfd594e4
1 changed files with 14 additions and 10 deletions
|
@ -835,8 +835,8 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
|
||||||
pool->buffers[i] = NULL;
|
pool->buffers[i] = NULL;
|
||||||
|
|
||||||
if (V4L2_TYPE_IS_OUTPUT (pool->obj->type))
|
if (V4L2_TYPE_IS_OUTPUT (pool->obj->type))
|
||||||
gst_buffer_unref (buffer);
|
gst_v4l2_buffer_pool_release_buffer (bpool, buffer);
|
||||||
else
|
else /* Don't re-enqueue capture buffer on stop */
|
||||||
pclass->release_buffer (bpool, buffer);
|
pclass->release_buffer (bpool, buffer);
|
||||||
|
|
||||||
g_atomic_int_add (&pool->num_queued, -1);
|
g_atomic_int_add (&pool->num_queued, -1);
|
||||||
|
@ -921,9 +921,7 @@ gst_v4l2_buffer_pool_flush_stop (GstBufferPool * bpool)
|
||||||
gst_mini_object_set_qdata (GST_MINI_OBJECT (buffer),
|
gst_mini_object_set_qdata (GST_MINI_OBJECT (buffer),
|
||||||
GST_V4L2_IMPORT_QUARK, NULL, NULL);
|
GST_V4L2_IMPORT_QUARK, NULL, NULL);
|
||||||
|
|
||||||
if (V4L2_TYPE_IS_OUTPUT (obj->type))
|
if (buffer->pool == NULL)
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
else
|
|
||||||
gst_v4l2_buffer_pool_release_buffer (bpool, buffer);
|
gst_v4l2_buffer_pool_release_buffer (bpool, buffer);
|
||||||
|
|
||||||
g_atomic_int_add (&pool->num_queued, -1);
|
g_atomic_int_add (&pool->num_queued, -1);
|
||||||
|
@ -1330,8 +1328,10 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
|
||||||
/* playback, put the buffer back in the queue to refill later. */
|
/* playback, put the buffer back in the queue to refill later. */
|
||||||
pclass->release_buffer (bpool, buffer);
|
pclass->release_buffer (bpool, buffer);
|
||||||
} else {
|
} else {
|
||||||
/* We keep a ref on queued buffer, so this should never happen */
|
/* the buffer is queued in the device but maybe not played yet. We just
|
||||||
g_assert_not_reached ();
|
* leave it there and not make it available for future calls to acquire
|
||||||
|
* for now. The buffer will be dequeued and reused later. */
|
||||||
|
GST_LOG_OBJECT (pool, "buffer %u is queued", index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1766,7 +1766,7 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer ** buf)
|
||||||
/* don't check return value because qbuf would have failed */
|
/* don't check return value because qbuf would have failed */
|
||||||
gst_v4l2_is_buffer_valid (to_queue, &group);
|
gst_v4l2_is_buffer_valid (to_queue, &group);
|
||||||
|
|
||||||
/* qbuf has taken the ref of the to_queue buffer but we are no in
|
/* qbuf has stored to_queue buffer but we are not in
|
||||||
* streaming state, so the flush logic won't be performed.
|
* streaming state, so the flush logic won't be performed.
|
||||||
* To avoid leaks, flush the allocator and restore the queued
|
* To avoid leaks, flush the allocator and restore the queued
|
||||||
* buffer as non-queued */
|
* buffer as non-queued */
|
||||||
|
@ -1781,15 +1781,19 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer ** buf)
|
||||||
goto start_failed;
|
goto start_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove our ref, we will still hold this buffer in acquire as needed,
|
||||||
|
* otherwise the pool will think it is outstanding and will refuse to stop. */
|
||||||
|
gst_buffer_unref (to_queue);
|
||||||
|
|
||||||
if (g_atomic_int_get (&pool->num_queued) >= pool->min_latency) {
|
if (g_atomic_int_get (&pool->num_queued) >= pool->min_latency) {
|
||||||
GstBuffer *out;
|
GstBuffer *out;
|
||||||
/* all buffers are queued, try to dequeue one and release it back
|
/* all buffers are queued, try to dequeue one and release it back
|
||||||
* into the pool so that _acquire can get to it again. */
|
* into the pool so that _acquire can get to it again. */
|
||||||
ret = gst_v4l2_buffer_pool_dqbuf (pool, &out);
|
ret = gst_v4l2_buffer_pool_dqbuf (pool, &out);
|
||||||
if (ret == GST_FLOW_OK)
|
if (ret == GST_FLOW_OK && out->pool == NULL)
|
||||||
/* release the rendered buffer back into the pool. This wakes up any
|
/* release the rendered buffer back into the pool. This wakes up any
|
||||||
* thread waiting for a buffer in _acquire(). */
|
* thread waiting for a buffer in _acquire(). */
|
||||||
gst_buffer_unref (out);
|
gst_v4l2_buffer_pool_release_buffer (bpool, out);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue