basesrc: Retry create() if we are back from pause

After a create() call, which may have returned FLUSHING or a filled buffer,
if it possible that we detect that we are now in pause. As live sourced
don't produce data in pause, drop the buffer is any and later retry creating
a buffer. This will ensure that we resume from pause while avoiding displaying
ancient frame.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4961>
This commit is contained in:
Nicolas Dufresne 2023-08-01 16:52:28 -04:00 committed by GStreamer Marge Bot
parent e506f9c23e
commit 47d79eedc9

View file

@ -2588,6 +2588,7 @@ again:
res_buf = in_buf = *buf; res_buf = in_buf = *buf;
own_res_buf = (*buf == NULL); own_res_buf = (*buf == NULL);
retry_create:
GST_LIVE_UNLOCK (src); GST_LIVE_UNLOCK (src);
ret = bclass->create (src, offset, length, &res_buf); ret = bclass->create (src, offset, length, &res_buf);
GST_LIVE_LOCK (src); GST_LIVE_LOCK (src);
@ -2596,13 +2597,18 @@ again:
if (src->is_live) { if (src->is_live) {
if (G_UNLIKELY (!src->live_running)) { if (G_UNLIKELY (!src->live_running)) {
GstFlowReturn wait_ret; GstFlowReturn wait_ret;
wait_ret = gst_base_src_wait_playing_unlocked (src);
if (wait_ret != GST_FLOW_OK) { /* no need keep old buffer while in pause */
if (ret == GST_FLOW_OK && own_res_buf) if (ret == GST_FLOW_OK && own_res_buf)
gst_buffer_unref (res_buf); gst_buffer_unref (res_buf);
wait_ret = gst_base_src_wait_playing_unlocked (src);
if (wait_ret != GST_FLOW_OK) {
ret = wait_ret; ret = wait_ret;
goto stopped; goto stopped;
} }
goto retry_create;
} }
} }