GNOME Bugzilla – Bug 777354
v4l2src: Doesn't Stop After Device Removed
Last modified: 2017-03-05 15:12:10 UTC
Versions: 1.10.2 and 10.8.3 (probably versions after as well) Pipeline: gst-launch-1.0 v4l2src device=/dev/video0 ! fakesink Problem: When the usb device providing the video for /dev/video0 is unplugged, gstreamer doesn't crash or detect the device has been unplugged and stop. This causes the device, when plugged back in, to re-enumerate as another device instead of having the same path as before. This is not a problem when using older versions of gstreamer/v4l2. I have tried it on 1.2 and 1.4, both work as expected.
With both GStreamer 1.10.2 and master, I see the following on unplugging the USB webcam: Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstSystemClock ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not read from resource. Additional debug info: ../subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c(1058): gst_v4l2_buffer_pool_poll (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: poll error 1: Invalid argument (22) Execution ended after 0:00:02.480060856 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ...
Can you provide a trace of when it keeps running for you ? Use a pipeline similar to this one and attach the gst.log file please. GST_DEBUG="2,v4l2*:6" gst-launch-1.0 v4l2src ! fakesink 2> gst.log
Created attachment 344077 [details] dmesg log
Created attachment 344078 [details] gst log
sudo GST_DEBUG="2,v4l2*:6" gst-launch-1.0 v4l2src device=/dev/video0 ! fakesink 2> gst.log Produced the results above. 1) started the above command as well as logged dmesg 2) unplugged device 3) waited ~10 sec and plugged back in 4) killed gst instance with ctrl-c Let me know if you need any additional information. Thanks!
Comment on attachment 344077 [details] dmesg log Something in the driver cleanup didn't go well. [ 277.301723] sysfs group ffffffffb7ad04a0 not found for kobject 'media0'
And GStreamer endup waiting fro more then 20 seconds (before CTRL+C) for the driver to give sign of life inside gst_v4l2_buffer_pool_poll(). This all looks like a nasty kernel bug to me. Nothing we can do from usespace point of view. Maybe try with another V4L2 client, to see what happens ?
We are looking at video0 not media0, though i guess they might be the same device. I have unfortunately tried the version of v4l2 that comes with ubuntu 16 lts and the newest stable build of it from their website directly with the same results. Would you have any other suggestions? Thanks!
(In reply to Casey Zahorik from comment #8) > We are looking at video0 not media0, though i guess they might be the same /dev/media0 in your case is most likely the topology of the UCV Driver. Try: sudo media-ctl -p /dev/media0 To see the topology. Most likely the entity 1 will match /dev/video0. The error in the log gives me the impression the kernel fails somehow, leaking a reference or something, which leads to the topology still being active. > device. I have unfortunately tried the version of v4l2 that comes with > ubuntu 16 lts and the newest stable build of it from their website directly > with the same results. Would you have any other suggestions? Thanks! You may try with vlc or mplayer, to see what happens. But I have doubt there is anything wrong with GStreamer here. vlc v4l2:// mplayer tv://
Marking as not a GStreamer bug, as there is indication that the kernel is at fault here.