From c00d4cae3c265e097bf2dde52e18ec741d6460c3 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 19 Jul 2017 22:03:29 -0400 Subject: [PATCH] v4l2object: Fix try/s_fmt errors According to the spec,TRY_FMT cannot return EBUSY, though it can return EINVAL if it was not possible to update the format to something supported. https://bugzilla.gnome.org/show_bug.cgi?id=785156 --- sys/v4l2/gstv4l2object.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 8350701073..df09632537 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -3552,9 +3552,16 @@ invalid_caps: } try_fmt_failed: { - if (errno == EBUSY) { - GST_V4L2_ERROR (error, RESOURCE, BUSY, - (_("Device '%s' is busy"), v4l2object->videodev), + if (errno == EINVAL) { + GST_V4L2_ERROR (error, RESOURCE, SETTINGS, + (_("Device '%s' has no supported format"), v4l2object->videodev), + ("Call to TRY_FMT failed for %" GST_FOURCC_FORMAT " @ %dx%d: %s", + GST_FOURCC_ARGS (pixelformat), width, height, + g_strerror (errno))); + } else { + GST_V4L2_ERROR (error, RESOURCE, FAILED, + (_("Device '%s' failed during initialization"), + v4l2object->videodev), ("Call to TRY_FMT failed for %" GST_FOURCC_FORMAT " @ %dx%d: %s", GST_FOURCC_ARGS (pixelformat), width, height, g_strerror (errno))); @@ -3569,10 +3576,16 @@ set_fmt_failed: ("Call to S_FMT failed for %" GST_FOURCC_FORMAT " @ %dx%d: %s", GST_FOURCC_ARGS (pixelformat), width, height, g_strerror (errno))); - } else { + } else if (errno == EINVAL) { GST_V4L2_ERROR (error, RESOURCE, SETTINGS, - (_("Device '%s' cannot capture at %dx%d"), - v4l2object->videodev, width, height), + (_("Device '%s' has no supported format"), v4l2object->videodev), + ("Call to S_FMT failed for %" GST_FOURCC_FORMAT " @ %dx%d: %s", + GST_FOURCC_ARGS (pixelformat), width, height, + g_strerror (errno))); + } else { + GST_V4L2_ERROR (error, RESOURCE, FAILED, + (_("Device '%s' failed during initialization"), + v4l2object->videodev), ("Call to S_FMT failed for %" GST_FOURCC_FORMAT " @ %dx%d: %s", GST_FOURCC_ARGS (pixelformat), width, height, g_strerror (errno)));