gst: pipewiresink: don't flush bufferpool in PLAYING_TO_PAUSED

Setting bufferpool to flushing state in PAUSED state is preventing the
buffer flow if there is a seek/flush event.
Instead, set the bufferpool to flushing during the `flush-start` event
and clear it during the `flush-stop`

Deactivate/activate the stream during flush event only if the sink is
in the PLAYING state. In the PAUSED or READY state, the stream would be
inactive and we do not want to alter that
This commit is contained in:
Taruntej Kanakamalla 2025-01-17 11:49:42 +05:30
parent c62905d911
commit 86e7429039

View file

@ -953,7 +953,6 @@ gst_pipewire_sink_change_state (GstElement * element, GstStateChange transition)
pw_thread_loop_lock (this->stream->core->loop);
pw_stream_set_active(this->stream->pwstream, false);
pw_thread_loop_unlock (this->stream->core->loop);
gst_buffer_pool_set_flushing(GST_BUFFER_POOL_CAST(this->stream->pool), TRUE);
break;
default:
break;
@ -970,7 +969,6 @@ gst_pipewire_sink_change_state (GstElement * element, GstStateChange transition)
pw_thread_loop_lock (this->stream->core->loop);
pw_stream_set_active(this->stream->pwstream, true);
pw_thread_loop_unlock (this->stream->core->loop);
gst_buffer_pool_set_flushing(GST_BUFFER_POOL_CAST(this->stream->pool), FALSE);
break;
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
@ -995,13 +993,19 @@ open_failed:
static gboolean gst_pipewire_sink_event (GstBaseSink *sink, GstEvent *event) {
GstPipeWireSink *pw_sink = GST_PIPEWIRE_SINK(sink);
GstState current_state = GST_ELEMENT(sink)->current_state;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
{
GST_DEBUG_OBJECT (pw_sink, "flush-start");
pw_thread_loop_lock (pw_sink->stream->core->loop);
pw_stream_set_active(pw_sink->stream->pwstream, false);
/* The stream would be already inactive if the sink is not PLAYING */
if (current_state == GST_STATE_PLAYING)
pw_stream_set_active(pw_sink->stream->pwstream, false);
gst_buffer_pool_set_flushing(GST_BUFFER_POOL_CAST(pw_sink->stream->pool), TRUE);
pw_stream_flush(pw_sink->stream->pwstream, false);
pw_thread_loop_unlock (pw_sink->stream->core->loop);
break;
@ -1010,7 +1014,12 @@ static gboolean gst_pipewire_sink_event (GstBaseSink *sink, GstEvent *event) {
{
GST_DEBUG_OBJECT (pw_sink, "flush-stop");
pw_thread_loop_lock (pw_sink->stream->core->loop);
pw_stream_set_active(pw_sink->stream->pwstream, true);
/* The stream needs to remain inactive if the sink is not PLAYING */
if (current_state == GST_STATE_PLAYING)
pw_stream_set_active(pw_sink->stream->pwstream, true);
gst_buffer_pool_set_flushing(GST_BUFFER_POOL_CAST(pw_sink->stream->pool), FALSE);
pw_thread_loop_unlock (pw_sink->stream->core->loop);
break;
}