From 03febb5048d0612157fad0ddadeaaeed924aadf0 Mon Sep 17 00:00:00 2001 From: Yacine Bandou Date: Mon, 29 Apr 2024 12:15:20 +0200 Subject: [PATCH] streamsynchronizer: Fix deadlock when streams have been flushed before others start 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. Part-of: --- .../gst-plugins-base/gst/playback/gststreamsynchronizer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/playback/gststreamsynchronizer.c b/subprojects/gst-plugins-base/gst/playback/gststreamsynchronizer.c index b3e964f47b..d1d77c4dc7 100644 --- a/subprojects/gst-plugins-base/gst/playback/gststreamsynchronizer.c +++ b/subprojects/gst-plugins-base/gst/playback/gststreamsynchronizer.c @@ -581,10 +581,12 @@ gst_stream_synchronizer_handle_flush_stop (GstStreamSynchronizer * self, gst_segment_init (&stream->segment, GST_FORMAT_UNDEFINED); } - stream->is_eos = FALSE; + if (stream->is_eos) { + stream->wait = FALSE; + stream->is_eos = FALSE; + } stream->eos_sent = FALSE; stream->flushing = FALSE; - stream->wait = FALSE; g_cond_broadcast (&stream->stream_finish_cond); if (reset_time) {