From 9da01413a161a34c27ec080092905e9c28c9ee3d Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Tue, 11 Jun 2024 09:55:00 -0400 Subject: [PATCH] gst: sink: Disable active state setting when going to PAUSED On first start, the stream is set to be active when connected. However, when the element is going to PAUSED and not subsequently to PLAYING, this is incorrect behaviour. Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4049 --- src/gst/gstpipewiresink.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c index 47c7b447a..85a78bca4 100644 --- a/src/gst/gstpipewiresink.c +++ b/src/gst/gstpipewiresink.c @@ -792,6 +792,15 @@ gst_pipewire_sink_change_state (GstElement * element, GstStateChange transition) goto open_failed; break; case GST_STATE_CHANGE_READY_TO_PAUSED: + /* the initial stream state is active, which is needed for linking and + * negotiation to happen and the bufferpool to be set up. We don't know + * if we'll go to plaing, so we deactivate the stream until that + * transition happens. This is janky, but because of how bins propagate + * state changes one transition at a time, there may not be a better way + * to do this. PAUSED -> READY -> PAUSED transitions, this is a noop */ + pw_thread_loop_lock (this->stream->core->loop); + pw_stream_set_active(this->stream->pwstream, false); + pw_thread_loop_unlock (this->stream->core->loop); break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: /* uncork and start play */