From 2943d92389e46addafdd81c07ba35f48c8187a48 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 2 Mar 2022 17:07:37 +0100 Subject: [PATCH] multiqueue: Fix interleave calculation for data before segment start This commit modifies the interleave calculation to allow growing when incoming data is before the segment start. The rationale is that there is no requirement whatsoever for data before the segment start to be "coherent" on all streams. For example, a demuxer could rightfully send data from the video stream from the previous keyframe (potentially quite a bit before the segment start) and the audio from just before the segment start. This will activate the same logic as growing the interleave when some streams haven't received buffers yet. Part-of: --- .../gstreamer/plugins/elements/gstmultiqueue.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/subprojects/gstreamer/plugins/elements/gstmultiqueue.c b/subprojects/gstreamer/plugins/elements/gstmultiqueue.c index 50fd839c5f..e9005202cb 100644 --- a/subprojects/gstreamer/plugins/elements/gstmultiqueue.c +++ b/subprojects/gstreamer/plugins/elements/gstmultiqueue.c @@ -1602,6 +1602,17 @@ calculate_interleave (GstMultiQueue * mq, GstSingleQueue * sq) low = oq->cached_sinktime; if (high == GST_CLOCK_STIME_NONE || oq->cached_sinktime > high) high = oq->cached_sinktime; + + /* If the input is before the segment start, consider as inactive to allow + * the interleave to grow until *all* streams have data within the segment. + * + * The reason for this is that there is no requirements for data before + * the segment start to be "aligned" and therefore interleave calculation + * can't reliably be done. For example a demuxer could provide video data + * from the previous keyframe but audio only from just before the segment + * start */ + if (oq->cached_sinktime < 0) + some_inactive = TRUE; } GST_LOG_OBJECT (mq, "queue %d , sinktime:%" GST_STIME_FORMAT " low:%" GST_STIME_FORMAT