v4l2bufferpool: Cleanup poll method and retry on EINTR/EAGAIN

https://bugzilla.gnome.org/show_bug.cgi?id=731015
This commit is contained in:
Nicolas Dufresne 2014-05-30 19:37:57 -04:00
parent 303883752e
commit 1648e46f86

View File

@ -934,22 +934,32 @@ gst_v4l2_buffer_pool_poll (GstV4l2BufferPool * pool)
{ {
gint ret; gint ret;
if (pool->can_poll_device) { if (!pool->can_poll_device)
GST_LOG_OBJECT (pool, "polling device"); goto done;
ret = gst_poll_wait (pool->poll, GST_CLOCK_TIME_NONE);
if (G_UNLIKELY (ret < 0)) { GST_LOG_OBJECT (pool, "polling device");
if (errno == EBUSY)
again:
ret = gst_poll_wait (pool->poll, GST_CLOCK_TIME_NONE);
if (G_UNLIKELY (ret < 0)) {
switch (errno) {
case EBUSY:
goto stopped; goto stopped;
if (errno == ENXIO) { case EAGAIN:
case EINTR:
goto again;
case ENXIO:
GST_WARNING_OBJECT (pool, 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; pool->can_poll_device = FALSE;
} else { goto done;
if (errno != EAGAIN && errno != EINTR) default:
goto select_error; goto select_error;
}
} }
} }
done:
return GST_FLOW_OK; return GST_FLOW_OK;
/* ERRORS */ /* ERRORS */