summaryrefslogtreecommitdiffstats
path: root/sys/v4l2/v4l2_calls.c
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-03-01 19:55:26 +0100
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-03-01 19:55:26 +0100
commitb6755a70004a445a475e6c4b1c2d289e908cf2a9 (patch)
treed6e4111b21d477cdfdbc4e3f84af1ead54ec2550 /sys/v4l2/v4l2_calls.c
parent7087da96dc850a931f7fca4c036fb0a2c58f04ac (diff)
Wait for a frame to become available before capturing it
Use GstPoll to wait for the fd of the video device to become readable before trying to capture a frame. This speeds up stopping v4l2src a lot as it no longer has to wait for the next frame, especially when capturing with low framerates or when the video device just never generates a frame (which seems a common issue for uvcvideo devices) Fixes bug #563574.
Diffstat (limited to 'sys/v4l2/v4l2_calls.c')
-rw-r--r--sys/v4l2/v4l2_calls.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
index a6b4b7dc..b1875a88 100644
--- a/sys/v4l2/v4l2_calls.c
+++ b/sys/v4l2/v4l2_calls.c
@@ -400,6 +400,7 @@ gst_v4l2_open (GstV4l2Object * v4l2object)
{
struct stat st;
int libv4l2_fd;
+ GstPollFD pollfd = GST_POLL_FD_INIT;
GST_DEBUG_OBJECT (v4l2object->element, "Trying to open device %s",
v4l2object->videodev);
@@ -453,6 +454,10 @@ gst_v4l2_open (GstV4l2Object * v4l2object)
"Opened device '%s' (%s) successfully",
v4l2object->vcap.card, v4l2object->videodev);
+ pollfd.fd = v4l2object->video_fd;
+ gst_poll_add_fd (v4l2object->poll, &pollfd);
+ gst_poll_fd_ctl_read (v4l2object->poll, &pollfd, TRUE);
+
return TRUE;
/* ERRORS */
@@ -508,6 +513,7 @@ error:
gboolean
gst_v4l2_close (GstV4l2Object * v4l2object)
{
+ GstPollFD pollfd = GST_POLL_FD_INIT;
GST_DEBUG_OBJECT (v4l2object->element, "Trying to close %s",
v4l2object->videodev);
@@ -516,6 +522,8 @@ gst_v4l2_close (GstV4l2Object * v4l2object)
/* close device */
v4l2_close (v4l2object->video_fd);
+ pollfd.fd = v4l2object->video_fd;
+ gst_poll_remove_fd (v4l2object->poll, &pollfd);
v4l2object->video_fd = -1;
/* empty lists */