Skip to content

streamsynchronizer: Fix deadlock when streams have been flushed before others start

Yacine Bandou requested to merge ybandou/gstreamer:user/yacine/fix_deadlock into main

To simplify the description, I'm assuming we only have two streams: video and audio.

For the video stream, we have the following events :

  • STREAM_START => stream->wait set to true
  • NEW_SEGMENT(1) => blocked waiting in gst_stream_synchronizer_wait
  • FLUSH_START => unblocked
  • FLUSH_STOP => stream->wait reset to false
  • NEW_SEGMENT(2) => not waiting, since stream->wait is false

Then for the audio stream, we have the following events :

  • STREAM_START => stream->wait set to true
  • NEW_SEGMENT(2) => blocked waiting in gst_stream_synchronizer_wait for ever.

Note: The first NEW_SEGMENT event and the FLUSH_START, FLUSH_STOP events of the audio stream are dropped before being received by the streamsynchronizer element, because the decodebin audio pad src is not yet linked to the playsink audio pad sink.

To fix this deadlock, we don't reset stream->wait to false in the FLUSH_STOP event when it is not waiting for the EOS of the other streams.

Edited by Yacine Bandou

Merge request reports