adaptivedemux2: Fix early seeking

When seeking is handled by the collection posting thread, there is a possibility
that some leftover data will be pushed by the stream thread.

Properly detect and reject those early segments (and buffers) by comparing it to
the main segment seqnum

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3914>
This commit is contained in:
Edward Hervey 2023-02-08 12:02:45 +01:00 committed by GStreamer Marge Bot
parent c98f5c2bf4
commit 39c8b060f4

View file

@ -504,6 +504,18 @@ _track_sink_chain_function (GstPad * pad, GstObject * parent,
TRACKS_LOCK (demux);
/* Discard buffers that are received outside of a valid segment. This can
* happen if a flushing seek (which resets the track segment seqnums) was
* received but the stream is still providing buffers before returning.
*/
if (track->input_segment_seqnum == GST_SEQNUM_INVALID) {
GST_DEBUG_OBJECT (pad,
"Dropping buffer because we do not have a valid input segment");
gst_buffer_unref (buffer);
TRACKS_UNLOCK (demux);
return GST_FLOW_OK;
}
ts = GST_BUFFER_DTS_OR_PTS (buffer);
/* Buffers coming out of parsebin *should* always be timestamped (it's the
@ -653,6 +665,14 @@ _track_sink_event_function (GstPad * pad, GstObject * parent, GstEvent * event)
return TRUE;
}
if (seg_seqnum != demux->priv->segment_seqnum) {
GST_DEBUG_OBJECT (pad, "Ignoring non-current segment");
gst_event_unref (event);
TRACKS_UNLOCK (demux);
return TRUE;
}
track->input_segment_seqnum = seg_seqnum;
gst_event_copy_segment (event, &track->input_segment);
if (track->input_segment.rate >= 0)