v4l2sink: Add support for blocking dequeue.

We'd prefer to throttle the decoder if we run out of buffers, to keep a bound
on memory usage.  Also, for OMAP4 it is a requirement of the decoder to not
alternate between memory alloced by the display driver and malloc'd userspace
memory.
This commit is contained in:
Rob Clark 2010-04-04 06:26:50 -05:00
parent ecfbaf58a5
commit 0cec72b97e
4 changed files with 14 additions and 6 deletions

View file

@ -454,14 +454,22 @@ gst_v4l2_buffer_pool_destroy (GstV4l2BufferPool * pool)
/**
* gst_v4l2_buffer_pool_get:
* @pool: the pool
* @pool: the "this" object
* @blocking: should this call suspend until there is a buffer available
* in the buffer pool?
*
* Get an available buffer in the pool
*/
GstV4l2Buffer *
gst_v4l2_buffer_pool_get (GstV4l2BufferPool * pool)
gst_v4l2_buffer_pool_get (GstV4l2BufferPool * pool, gboolean blocking)
{
GstV4l2Buffer *buf = g_async_queue_try_pop (pool->avail_buffers);
GstV4l2Buffer *buf;
if (blocking) {
buf = g_async_queue_pop (pool->avail_buffers);
} else {
buf = g_async_queue_try_pop (pool->avail_buffers);
}
if (buf) {
GST_BUFFER_SIZE (buf) = buf->vbuffer.length;

View file

@ -82,7 +82,7 @@ void gst_v4l2_buffer_pool_destroy (GstV4l2BufferPool * pool);
GstV4l2BufferPool *gst_v4l2_buffer_pool_new (GstElement *v4l2elem, gint fd, gint num_buffers, GstCaps * caps, gboolean requeuebuf, enum v4l2_buf_type type);
GstV4l2Buffer *gst_v4l2_buffer_pool_get (GstV4l2BufferPool *pool);
GstV4l2Buffer *gst_v4l2_buffer_pool_get (GstV4l2BufferPool *pool, gboolean blocking);
gboolean gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool *pool, GstV4l2Buffer *buf);
GstV4l2Buffer *gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool *pool);

View file

@ -632,7 +632,7 @@ gst_v4l2sink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
}
}
v4l2buf = gst_v4l2_buffer_pool_get (v4l2sink->pool);
v4l2buf = gst_v4l2_buffer_pool_get (v4l2sink->pool, TRUE);
if (G_LIKELY (v4l2buf)) {
GST_DEBUG_OBJECT (v4l2sink, "allocated buffer: %p", v4l2buf);

View file

@ -68,7 +68,7 @@ gst_v4l2src_buffer_pool_activate (GstV4l2BufferPool * pool,
{
GstV4l2Buffer *buf;
while ((buf = gst_v4l2_buffer_pool_get (pool)) != NULL)
while ((buf = gst_v4l2_buffer_pool_get (pool, FALSE)) != NULL)
if (!gst_v4l2_buffer_pool_qbuf (pool, buf))
goto queue_failed;