From 47d79eedc96fc2e2440cb60a603c4b73024b3b05 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 1 Aug 2023 16:52:28 -0400 Subject: [PATCH] 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: --- subprojects/gstreamer/libs/gst/base/gstbasesrc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/subprojects/gstreamer/libs/gst/base/gstbasesrc.c b/subprojects/gstreamer/libs/gst/base/gstbasesrc.c index 6ac5e4d89d..f4fdc447e4 100644 --- a/subprojects/gstreamer/libs/gst/base/gstbasesrc.c +++ b/subprojects/gstreamer/libs/gst/base/gstbasesrc.c @@ -2588,6 +2588,7 @@ again: res_buf = in_buf = *buf; own_res_buf = (*buf == NULL); +retry_create: GST_LIVE_UNLOCK (src); ret = bclass->create (src, offset, length, &res_buf); GST_LIVE_LOCK (src); @@ -2596,13 +2597,18 @@ again: if (src->is_live) { if (G_UNLIKELY (!src->live_running)) { GstFlowReturn wait_ret; + + /* no need keep old buffer while in pause */ + if (ret == GST_FLOW_OK && own_res_buf) + gst_buffer_unref (res_buf); + wait_ret = gst_base_src_wait_playing_unlocked (src); if (wait_ret != GST_FLOW_OK) { - if (ret == GST_FLOW_OK && own_res_buf) - gst_buffer_unref (res_buf); ret = wait_ret; goto stopped; } + + goto retry_create; } }