GNOME Bugzilla – Bug 621723
v4l2src crashes on PLAYING->READY->PLAYING
Last modified: 2010-06-16 15:49:20 UTC
I believe the issue is that in gst_v4l2src_set_caps(), if set_capture fails then we do not capture_init(), which would normally set the buffer pool non-NULL. Then trying to use the buffer pool goes boom. if (!gst_v4l2src_set_capture (v4l2src, format->pixelformat, w, h, fps_n, fps_d)) /* error already posted */ return FALSE; if (!gst_v4l2src_capture_init (v4l2src, caps)) return FALSE; It looks like this is still a problem in git though I saw the bug in 0.10.25 The set_capture fails due to: libv4l2: error setting pixformat: Device or resource busy gst_v4l2src_negotiate() does not check the return value of set_caps and so the negotiation succeeds even though set_caps failed.
+ Trace 222430
Created attachment 163837 [details] [review] v4l2src: in negotiate, check for error return from set_caps Fixes #621723 (partially) set_caps can fail if the video device is running, in that case setting its format leads to EBUSY. If set_caps fails then we will not have set up the buffer pool (it will be NULL) which leads to a crash when we try to pull buffers. If we fail the negotiate on set_caps failure, then we won't go to playing state and won't crash. This is a small improvement. Of course, a nicer fix would be to make set_caps work in the case where the format is unchanged. If the format has changed, failing is probably correct because we need to close the device (go to NULL state) in order to set caps.
Created attachment 163838 [details] [review] v4l2src: do not try to change device format if it's already correct This allows set_caps to succeed if caps change in a way that would not modify the format we're getting from the hardware. Otherwise if not in NULL state, setting caps would fail with EBUSY. With this change, in some cases it's OK to go PLAYING->READY->PLAYING rather than PLAYING->NULL->PLAYING to avoid a time-consuming close and reopen of the device. Fixes #621723
commit f06b105058e73162275b50bdba89c6791e218d03 Author: Havoc Pennington <hp@pobox.com> Date: Wed Jun 16 11:21:35 2010 -0400 v4l2src: do not try to change device format if it's already correct This allows set_caps to succeed if caps change in a way that would not modify the format we're getting from the hardware. Otherwise if not in NULL state, setting caps would fail with EBUSY. With this change, in some cases it's OK to go PLAYING->READY->PLAYING rather than PLAYING->NULL->PLAYING to avoid a time-consuming close and reopen of the device. Fixes #621723 commit 9b9f9d0a2a93365e2577c5bad8591f82bbf9e6d0 Author: Havoc Pennington <hp@pobox.com> Date: Wed Jun 16 11:09:17 2010 -0400 v4l2src: in negotiate, check for error return from set_caps Fixes #621723 (partially)