adaptivedemux2: stream: Set period has_next_period flag before EOS

Before sending EOS, update the period's has_next_period
flag and/or create the next period. This closes a race
where the output loop might receive the EOS event
and either push it downstream (causing premature EOS),
or receive it and try and switch to the next period
before that period is completely set up.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2838>
This commit is contained in:
Jan Schmidt 2022-07-12 01:55:54 +10:00 committed by Tim-Philipp Müller
parent 1863082efa
commit de7e2c9b6b

View file

@ -1518,6 +1518,19 @@ gst_adaptive_demux2_stream_end_of_manifest (GstAdaptiveDemux2Stream * stream)
GST_DEBUG_OBJECT (stream, "Combined flow %s", gst_flow_get_name (combined));
if (gst_adaptive_demux_has_next_period (demux)) {
if (combined == GST_FLOW_EOS) {
GST_DEBUG_OBJECT (stream, "Next period available, advancing");
gst_adaptive_demux_advance_period (demux);
} else {
/* Ensure the 'has_next_period' flag is set on the period before
* pushing EOS to the stream, so that the output loop knows not
* to actually output the event */
GST_DEBUG_OBJECT (stream, "Marking current period has a next one");
demux->input_period->has_next_period = TRUE;
}
}
if (demux->priv->outputs) {
GstEvent *eos = gst_event_new_eos ();
@ -1530,11 +1543,6 @@ gst_adaptive_demux2_stream_end_of_manifest (GstAdaptiveDemux2Stream * stream)
GST_ERROR_OBJECT (demux, "Can't push EOS on non-exposed pad");
gst_adaptive_demux2_stream_error (stream);
}
if (combined == GST_FLOW_EOS && gst_adaptive_demux_has_next_period (demux)) {
GST_DEBUG_OBJECT (stream, "Next period available, advancing");
gst_adaptive_demux_advance_period (demux);
}
}
static gboolean