GNOME Bugzilla – Bug 690197
alsasrc: gets stuck in infinite loop if usb audio device is disconnected while being used
Last modified: 2018-01-22 11:33:04 UTC
Created attachment 231539 [details] logs i am facing problem using alsasrc . i have a pipeline with alsasrc device=<> ! alsasink , when i disconnect my device , my system goes to wait indefinetly and never comes out of *set_state() to NULL funcion. Attaching the logs for further reference. After debugging found alsasrc is locking in read function even if read gives error. help me on if i do some wrong.
and my thread blocks in :
+ Trace 231295
Thread 1 (Thread 0xb3053780 (LWP 396))
I haven't looked at the log or code, but this issue does sound familiar, it might be fixed in git / 1.0. Could you test whether you can still reproduce this with GStreamer 1.x ?
is Application using 10.36 can use 1.0 without any changes ?
Hi Tim , currently on our system we can't upgrade to 1.0 , please help be with which patch or branch might fixed the problem , i can merge them to gst 10.36 and test.
I was thinking of bug #614545 actually, but should be fixed already. For what it's worth, you can install 1.0 in parallel with 0.10 for testing purposes. The two versions won't affect each other. I can reproduce this bug with git master.
commit 3d5a78e67a70194f3724b0d0c4f213681283eecf Author: Tim-Philipp Müller <tim@centricular.net> Date: Sat Dec 15 19:36:56 2012 +0000 alsa: post error message when audio device disappears Don't loop forever if an USB audio device gets disconnected while in use. Post an error message instead. This is not enough yet though, we still need to make the base class and/or the ring buffer bail out. https://bugzilla.gnome.org/show_bug.cgi?id=690197 This is not enough yet though.
commit df6031f7c656489f665d01fb629315cf50f09536 Author: Tim-Philipp Müller <tim@centricular.net> Date: Mon Dec 17 20:32:52 2012 +0000 alsasrc: return negative value on read error Otherwise baseaudiosrc won't go into the error code path. https://bugzilla.gnome.org/show_bug.cgi?id=690197 commit 68f366a8d37e5fb71106869b41911a749382143c Author: Tim-Philipp Müller <tim@centricular.net> Date: Mon Dec 17 20:28:12 2012 +0000 audiobasesrc: bail out if subclass posts an error Use new ringbuffer ERROR state to make all the various threads bail out correctly when the subclass posts an error. It's a bit iffy to communicate this properly between the different bits of code. https://bugzilla.gnome.org/show_bug.cgi?id=690197 commit 4f49c7a33ba32cf1b30c4023570b241c24babd1a Author: Tim-Philipp Müller <tim@centricular.net> Date: Mon Dec 17 20:26:33 2012 +0000 audioringbuffer: add GST_AUDIO_RING_BUFFER_STATE_ERROR state API: GST_AUDIO_RING_BUFFER_STATE_ERROR https://bugzilla.gnome.org/show_bug.cgi?id=690197 Not trivial to backport to 0.10 I'm afraid, since there's no GstElementClass::post_message function there. You'd have to take the code from the == MESSAGE ERROR block in post_message, and put it before/after the GST_ELEMENT_ERROR call in device_disconnected: in alsasrc or so. Good luck!
Created attachment 232102 [details] [review] [0.10] gstreamer-core
I back ported wih post_message in GstElementClass and still its getting stuck in infinite loop. Diff , attached for modification.
Created attachment 232103 [details] [review] [0.10] gst-plugins-base
Hangs in :
+ Trace 231314
Thread 1 (LWP 832)
0.10 is not maintained any longer, sorry. Please test with git master (1.1.0) and see if the issue is fixed there first.
after trying with master stil hang is seen.
Please attach a GST_DEBUG=*audio*:6,*alsa*:6,*src*:6 debug log and a stack trace of all threads with full debugging symbols, as requested on IRC.
http://paste.ubuntu.com/5685825/
Logs with fakesink. http://paste.kde.org/717782/
i found read() function is blocking , though device is opened in non_block mode but when prepare_read() it make it to block and it hangs if there is no data to be filled so will there be any problem if i change alsasrc_prepare() to prepare read in non_block mode ? Patch is as below. http://paste.kde.org/718544/