From 1648e46f8649edd131a4b67cf86afcf7798344ea Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Fri, 30 May 2014 19:37:57 -0400 Subject: [PATCH] v4l2bufferpool: Cleanup poll method and retry on EINTR/EAGAIN https://bugzilla.gnome.org/show_bug.cgi?id=731015 --- sys/v4l2/gstv4l2bufferpool.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 1949e12900..72405df87c 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -934,22 +934,32 @@ gst_v4l2_buffer_pool_poll (GstV4l2BufferPool * pool) { gint ret; - if (pool->can_poll_device) { - GST_LOG_OBJECT (pool, "polling device"); - ret = gst_poll_wait (pool->poll, GST_CLOCK_TIME_NONE); - if (G_UNLIKELY (ret < 0)) { - if (errno == EBUSY) + if (!pool->can_poll_device) + goto done; + + GST_LOG_OBJECT (pool, "polling device"); + +again: + ret = gst_poll_wait (pool->poll, GST_CLOCK_TIME_NONE); + if (G_UNLIKELY (ret < 0)) { + switch (errno) { + case EBUSY: goto stopped; - if (errno == ENXIO) { + case EAGAIN: + case EINTR: + goto again; + case ENXIO: GST_WARNING_OBJECT (pool, - "v4l2 device doesn't support polling. Disabling"); + "v4l2 device doesn't support polling. Disabling" + " using libv4l2 in this case may cause deadlocks"); pool->can_poll_device = FALSE; - } else { - if (errno != EAGAIN && errno != EINTR) - goto select_error; - } + goto done; + default: + goto select_error; } } + +done: return GST_FLOW_OK; /* ERRORS */