mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-09 13:30:06 -05:00
gst: handle blocking in the _render() function
When we do any other blocking in the render function, we should unblock and call _wait_preroll() when we go to PAUSED. We can have this situation when all the buffers are queued in the pw_stream and we get a new _render() call. We can't get more buffers from the pool and so we must block and wait. When we go to PAUSED we need to unlock and go to _wait_preroll(). Implement this by setting a pool paused flag that is set when the sink goes to paused, we can then return a special value that does the wait_preroll(). See !2248
This commit is contained in:
parent
85c5d65c97
commit
c7ccc5abca
3 changed files with 34 additions and 3 deletions
|
|
@ -873,8 +873,15 @@ gst_pipewire_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
|
|||
|
||||
pw_thread_loop_unlock (pwsink->stream->core->loop);
|
||||
|
||||
if ((res = gst_buffer_pool_acquire_buffer (GST_BUFFER_POOL_CAST (pwsink->stream->pool),
|
||||
&b, ¶ms)) != GST_FLOW_OK)
|
||||
res = gst_buffer_pool_acquire_buffer (GST_BUFFER_POOL_CAST (pwsink->stream->pool),
|
||||
&b, ¶ms);
|
||||
if (res == GST_FLOW_CUSTOM_ERROR_1) {
|
||||
res = gst_base_sink_wait_preroll (bsink);
|
||||
if (res != GST_FLOW_OK)
|
||||
goto done;
|
||||
continue;
|
||||
}
|
||||
if (res != GST_FLOW_OK)
|
||||
goto done;
|
||||
|
||||
gst_buffer_map (b, &info, GST_MAP_WRITE);
|
||||
|
|
@ -946,9 +953,11 @@ 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_pipewire_pool_set_paused(this->stream->pool, TRUE);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||
/* stop play ASAP by corking */
|
||||
gst_pipewire_pool_set_paused(this->stream->pool, TRUE);
|
||||
pw_thread_loop_lock (this->stream->core->loop);
|
||||
pw_stream_set_active(this->stream->pwstream, false);
|
||||
pw_thread_loop_unlock (this->stream->core->loop);
|
||||
|
|
@ -965,6 +974,7 @@ gst_pipewire_sink_change_state (GstElement * element, GstStateChange transition)
|
|||
* from paused state to playing state which will wait until buffer pool is ready.
|
||||
* Guarantee to finish preoll if needed to active buffer pool before uncorking and
|
||||
* starting play */
|
||||
gst_pipewire_pool_set_paused(this->stream->pool, FALSE);
|
||||
pw_thread_loop_lock (this->stream->core->loop);
|
||||
pw_stream_set_active(this->stream->pwstream, true);
|
||||
pw_thread_loop_unlock (this->stream->core->loop);
|
||||
|
|
@ -1027,4 +1037,4 @@ static gboolean gst_pipewire_sink_event (GstBaseSink *sink, GstEvent *event) {
|
|||
}
|
||||
|
||||
return GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue