webrtcsink: Fix a race starting the signaller

1. Working scenario:

T1 -> Caps event (all caps have been received)
T1     -> Start discovering
T2 -> Change state to Playing
T2        -> The signaller is not started as:
                - Sink current_state() == Paused as it will be set to
                  playing after the change_state vmethod returns
                - Discovery is not done anyway
T1 -> Discovery is done
        => The signaller is started, and **everything works well**.

2. Failing scenario:

T1 -> Caps event (all caps have been received)
T1     -> Start discovering
T1 -> Discovery is done
T1        -> The signaller is not started as:
                - Current state == Paused (it will be set to playing
                  after the change_state vmethod returns)
                - Discovery is not done anyway
T2 -> Change state to Playing
T2        -> The signaller is not started as:
                - Sink current_state == Paused  as it will be set to
                  playing after the we return from the change_state
                  vmethod

In that case the signaller never starts.
This commit is contained in:
Thibault Saunier 2022-04-19 15:38:53 +00:00 committed by Mathieu Duponchelle
parent 03430a9571
commit f11260aeb5

View file

@ -913,7 +913,7 @@ impl State {
fn maybe_start_signaller(&mut self, element: &super::WebRTCSink) { fn maybe_start_signaller(&mut self, element: &super::WebRTCSink) {
if self.signaller_state == SignallerState::Stopped if self.signaller_state == SignallerState::Stopped
&& element.current_state() == gst::State::Playing && element.current_state() >= gst::State::Paused
&& self.codec_discovery_done && self.codec_discovery_done
{ {
if let Err(err) = self.signaller.start(element) { if let Err(err) = self.signaller.start(element) {