GNOME Bugzilla – Bug 557763
[mpegtsmux] Deadlock @ EOS due to interleaving mechanism
Last modified: 2008-10-27 08:52:40 UTC
Please describe the problem: A deadlock occurs in certain conditions in the new mpegtsmux. The problem existed in the original flutsmux also. There is a flaw in the interleaving mechanism where the collect pads can pass EOS flushing and the mux still keep a queued buffer, resulting in the mux not issuing the EOS event and the pipeline deadlocking. Steps to reproduce: gst-launch-0.10 mpegtsmux name=mux ! fakesink audiotestsrc num-buffers=1 ! lame ! queue ! mux.sink_0 videotestsrc num-buffers=1 ! ffenc_mpeg2video ! queue ! mux.sink_1 Actual results: Setting pipeline to PAUSED ... Pipeline is PREROLLING ... Pipeline is PREROLLED ... Setting pipeline to PLAYING ... New clock: GstSystemClock [deadlocked] Expected results: Muxer issues EOS on its source pad and pipeline terminates properly. Does this happen every time? Yes its systematic, I think it occurs when audio and video have their EOS at the same moment in the stream time line. This is not a race condition issue. Other information: I've compared the code with the avimux and noticed an obvious difference. The avimux, for its interleaving purpose, only peeks at the collect pads until the oldest (or most suitable) stream is identified. Then when a stream is sure to be handled, a buffer is poped from the pad. In the mpegtsmux, streams each have a tracking structure with a GstBuffer pointer to keep the reference of all poped data. This is obviously to reduce the overhead of accessing the collect pads, however it screws up the collect mechanism for EOS handling. I have a patch to propose a fix. Its probably not the best solution but I didn't want to rewrite the whole function.
Created attachment 121273 [details] [review] Proposed fix I keep the original function pretty much intact except I do a peek instead of a pop to get the stream buffer, then I unref a poped buffer off the selected pad.
2008-10-27 Sebastian Dröge <sebastian.droege@collabora.co.uk> Patch by: vanista <vanista at gmail dot com> * gst/mpegtsmux/mpegtsmux.c: (mpegtsmux_choose_best_stream): Fix EOS logic by correctly popping the collect pad buffers only when we've chosen to use them instead of popping them always and storing them in a private queue. Before the pipeline would deadlock if all pads go EOS at the same time. Fixes bug #557763.