v4l2sink: Add support for blocking dequeue.
authorRob Clark <rob@ti.com>
Sun, 4 Apr 2010 11:26:50 +0000 (06:26 -0500)
committerRob Clark <rob@ti.com>
Wed, 29 Dec 2010 17:46:40 +0000 (11:46 -0600)
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.

sys/v4l2/gstv4l2bufferpool.c
sys/v4l2/gstv4l2bufferpool.h
sys/v4l2/gstv4l2sink.c
sys/v4l2/v4l2src_calls.c

index a981c68..2d9893c 100644 (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;
index 70ab082..caad9ac 100644 (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);
 
index 0dcce39..c673a86 100644 (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);
index e33fa61..ecd54b8 100644 (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;