summaryrefslogtreecommitdiffstats
path: root/sys/v4l2/v4l2src_calls.c
diff options
context:
space:
mode:
authorEdgard Lima <edgard.lima@indt.org.br>2007-11-15 12:22:10 +0000
committerEdgard Lima <edgard.lima@indt.org.br>2007-11-15 12:22:10 +0000
commit66ca1b2280a918d3bd7c7ce09ec22d485be34666 (patch)
treeae256a076c31d42542f63cd4656e1e137f77eadc /sys/v4l2/v4l2src_calls.c
parent62d8456eb715a3cb849ca0f14d2182fe5229ddf4 (diff)
Always copy buffers by default (handle safer with bugged drivers) and added a property to make it possible to use mma...
Original commit message from CVS: Always copy buffers by default (handle safer with bugged drivers) and added a property to make it possible to use mmap effectively (no copy if possible) when application wants to. Fixes: #480557.
Diffstat (limited to 'sys/v4l2/v4l2src_calls.c')
-rw-r--r--sys/v4l2/v4l2src_calls.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c
index 0b03c999..e2a07ea9 100644
--- a/sys/v4l2/v4l2src_calls.c
+++ b/sys/v4l2/v4l2src_calls.c
@@ -954,26 +954,16 @@ gst_v4l2src_grab_frame (GstV4l2Src * v4l2src, GstBuffer ** buf)
}
}
- do {
+ g_mutex_lock (v4l2src->pool->lock);
- g_mutex_lock (v4l2src->pool->lock);
+ index = buffer.index;
- index = buffer.index;
-
- /* get our GstBuffer with that index from the pool, if the buffer was
- * outstanding we have a serious problem. */
- pool_buffer = GST_BUFFER (v4l2src->pool->buffers[index]);
-
- if (pool_buffer == NULL) {
- g_mutex_unlock (v4l2src->pool->lock);
- g_usleep (20000); /* wait 20 miliseconds */
- /* FIXME: we need a exit condition here */
- } else {
- break;
- }
-
- } while (TRUE);
+ /* get our GstBuffer with that index from the pool, if the buffer was
+ * outstanding we have a serious problem. */
+ pool_buffer = GST_BUFFER (v4l2src->pool->buffers[index]);
+ if (pool_buffer == NULL)
+ goto no_buffer;
GST_LOG_OBJECT (v4l2src, "grabbed buffer %p at index %d", pool_buffer, index);
@@ -982,7 +972,8 @@ gst_v4l2src_grab_frame (GstV4l2Src * v4l2src, GstBuffer ** buf)
v4l2src->pool->num_live_buffers++;
/* if we are handing out the last buffer in the pool, we need to make a
* copy and bring the buffer back in the pool. */
- need_copy = v4l2src->pool->num_live_buffers == v4l2src->pool->buffer_count;
+ need_copy = v4l2src->always_copy
+ || (v4l2src->pool->num_live_buffers == v4l2src->pool->buffer_count);
g_mutex_unlock (v4l2src->pool->lock);
@@ -1020,6 +1011,7 @@ gst_v4l2src_grab_frame (GstV4l2Src * v4l2src, GstBuffer ** buf)
if (G_UNLIKELY (need_copy)) {
*buf = gst_buffer_copy (pool_buffer);
+ GST_BUFFER_FLAG_UNSET (*buf, GST_BUFFER_FLAG_READONLY);
/* this will requeue */
gst_buffer_unref (pool_buffer);
} else {
@@ -1059,7 +1051,7 @@ too_many_trials:
NUM_TRIALS, v4l2src->v4l2object->videodev, g_strerror (errno)));
return GST_FLOW_ERROR;
}
-#if 0
+no_buffer:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, FAILED,
(_("Failed trying to get video frames from device '%s'."),
@@ -1068,7 +1060,6 @@ too_many_trials:
g_mutex_unlock (v4l2src->pool->lock);
return GST_FLOW_ERROR;
}
-#endif
/*
qbuf_failed:
{