From 5a130ddd73d01ebccad07328c6dc1263275941f0 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Fri, 22 Dec 2023 16:01:42 +0200 Subject: [PATCH] gstpipewiresrc: break out of wait_started() also on STATE_UNCONNECTED When the session manager sends an error to the client, it typically also destroys the node after the error, which causes the stream to go to STATE_UNCONNECTED via proxy_removed(). In that case, make sure we exit the loop early, otherwise it will take 30 seconds to unblock gst_element_set_state() This is a revised version of the fix that was commited via !1763 and then reverted, as it was problematic. Now the code ensures that it breaks out only if the state was previously CONNECTING or higher. --- src/gst/gstpipewiresrc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c index e473338ba..d95e99620 100644 --- a/src/gst/gstpipewiresrc.c +++ b/src/gst/gstpipewiresrc.c @@ -768,7 +768,7 @@ start_error: static enum pw_stream_state wait_started (GstPipeWireSrc *this) { - enum pw_stream_state state; + enum pw_stream_state state, prev_state = PW_STREAM_STATE_UNCONNECTED; const char *error = NULL; struct timespec abstime; @@ -783,10 +783,9 @@ wait_started (GstPipeWireSrc *this) GST_DEBUG_OBJECT (this, "waiting for started signal, state now %s", pw_stream_state_as_string (state)); - if (state == PW_STREAM_STATE_ERROR) - break; - - if (this->flushing) { + if (state == PW_STREAM_STATE_ERROR || + (state == PW_STREAM_STATE_UNCONNECTED && prev_state > PW_STREAM_STATE_UNCONNECTED) || + this->flushing) { state = PW_STREAM_STATE_ERROR; break; } @@ -798,6 +797,8 @@ wait_started (GstPipeWireSrc *this) state = PW_STREAM_STATE_ERROR; break; } + + prev_state = state; } GST_DEBUG_OBJECT (this, "got started signal: %s", pw_stream_state_as_string (state));