Skip to content

Commit

Permalink
v4l2src: attempt to set the current camera format after open is called
Browse files Browse the repository at this point in the history
To test if the device is actually being hold by another process or not.
  • Loading branch information
tbeloqui committed Dec 1, 2023
1 parent 8156c71 commit 2c8f6d9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,21 @@ gst_v4l2src_change_state (GstElement * element, GstStateChange transition)
gst_v4l2_error (v4l2src, &error);
return GST_STATE_CHANGE_FAILURE;
}

/* the device might still busy even after open() succeds, so try also to
set the format, it will return an EBUSY error if the device is
already acquired by another process */
GstCaps *caps = gst_v4l2_object_get_caps (obj, NULL);
caps = gst_caps_make_writable (caps);
gboolean set_format = gst_v4l2src_set_format (v4l2src, caps, &error);
gst_caps_unref (caps);

if (!set_format) {
gst_v4l2_error (v4l2src, &error);
gst_v4l2_object_close (obj);
return GST_STATE_CHANGE_FAILURE;
}

break;
default:
break;
Expand Down

0 comments on commit 2c8f6d9

Please sign in to comment.