rtpbin: fix shutdown crash in rtpbin
authorHavard Graff <havard.graff@gmail.com>
Thu, 19 Dec 2019 22:48:09 +0000 (23:48 +0100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 20 Dec 2019 08:27:07 +0000 (08:27 +0000)
commit8b96d8ee8d35f31d34a0df3caa5fb88011785a79
tree855af48c10b41f02ba4aea7b8d2d4da851a746b4
parent4155c59cc4757abdfa23c53ebd7ecef666ab3673
rtpbin: fix shutdown crash in rtpbin

The key is to make sure the jitterbuffer is set to NULL *before* the
ptdemux.

The race that existed would basically happen when ptdemux had reached
READY, and the jitterbuffer would then push a buffer, triggering a new
pad with a new payloadtype being added and ghosted to the rtpbin itself.

However, the srcpad of the ptdemux would now be inactive, and all the
sticky-event pushed on it would be swallowed, not allowing any to reach
the ghost-pad. Then the buffer in-flight would come to the ghostpad,
and we would assert that a buffer arrived before the necessary
events.

By simply re-ordering the state-changes, we ensure that there will be
no buffer racing into the ptdemux while its state is being changed,
and the problem disappears completely.

Notice also that there is not point in disconnecting the signals on the
ptdemux before this point, since we need the push-thread to settle
down before we can do this in a non-racy way.
gst/rtpmanager/gstrtpbin.c
tests/check/elements/rtpbin.c