From 1565b9635b830c33591c664dc0baad78d3a7ce9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 8 Jun 2021 17:27:55 +0300 Subject: [PATCH] appsrc: When dropping buffers before handling the initial segment use the latest input segment Part-of: --- gst-libs/gst/app/gstappsrc.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gst-libs/gst/app/gstappsrc.c b/gst-libs/gst/app/gstappsrc.c index c7a0a4d..457220d 100644 --- a/gst-libs/gst/app/gstappsrc.c +++ b/gst-libs/gst/app/gstappsrc.c @@ -1391,18 +1391,22 @@ gst_app_src_update_queued_pop (GstAppSrc * appsrc, GstMiniObject * item, priv->queued_buffers -= n_buffers; /* Update time level if working on a TIME segment */ - if (priv->current_segment.format == GST_FORMAT_TIME + if ((priv->current_segment.format == GST_FORMAT_TIME + || (priv->current_segment.format == GST_FORMAT_UNDEFINED + && priv->last_segment.format == GST_FORMAT_TIME)) && end_buffer_ts != GST_CLOCK_TIME_NONE) { + const GstSegment *segment = + priv->current_segment.format == + GST_FORMAT_TIME ? &priv->current_segment : &priv->last_segment; + /* Clip to the current segment boundaries */ - if (priv->current_segment.stop != -1 - && end_buffer_ts > priv->current_segment.stop) - end_buffer_ts = priv->current_segment.stop; - else if (priv->current_segment.start > end_buffer_ts) - end_buffer_ts = priv->current_segment.start; + if (segment->stop != -1 && end_buffer_ts > segment->stop) + end_buffer_ts = segment->stop; + else if (segment->start > end_buffer_ts) + end_buffer_ts = segment->start; priv->last_out_running_time = - gst_segment_to_running_time (&priv->current_segment, - GST_FORMAT_TIME, end_buffer_ts); + gst_segment_to_running_time (segment, GST_FORMAT_TIME, end_buffer_ts); GST_TRACE_OBJECT (appsrc, "Last in running time %" GST_TIME_FORMAT ", last out running time %" -- 2.7.4