urisourcebin: Only expose pads once activation has completed
authorEdward Hervey <edward@centricular.com>
Thu, 27 Oct 2022 09:47:56 +0000 (11:47 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 16 Nov 2022 14:01:46 +0000 (14:01 +0000)
commitb6584defd034108afa133c114d0158440b4b1be8
tree66821e4c7af57a052a2bbcd4f05e3d3c9d91fc1a
parenta347846698fd60a71b0bba8ec45e898bf58f0874
urisourcebin: Only expose pads once activation has completed

The following problem could happen:
* Thread 1 : urisourcebin gets activated from READY->PAUSED
* Thread 2 : some element causes a pad to be added to urisourcebin , which gets
linked downstream, which decides to activate upstream to pull-based.
  * That requires "activating" the pads from PUSH to NONE, and then from NONE to PULL
* Thread 1 : the base class state change handlers checks if all pads are
activated

The issue is that since going form PUSH to PULL requires going through NONE,
there is a window during which:
* Thread 1 : The pad was set to NONE (before being set to PULL)
* Thread 2 : The base class activates that pad (to PUSH)
* Thread 1 : The attempt to "activate" to PULL fails (silently or not)

This is very racy, so in order to avoid that, we make sure that we only add pads
once the transition from READY->PAUSED in the parent classes is done.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c