hlsdemux2: Cancel preload before fetching something else

When submitting a request for fragment or header that doesn't match any preload,
make sure there's not an ongoing preload for that data type, to avoid parallel
downloads using up bandwidth.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
This commit is contained in:
Jan Schmidt 2022-10-14 22:01:55 +11:00 committed by GStreamer Marge Bot
parent 70bfeff35d
commit cbb9cfe987

View file

@ -2374,6 +2374,18 @@ gst_hls_demux_stream_submit_request (GstAdaptiveDemux2Stream * stream,
if (gst_hls_demux_preloader_provide_request (hlsdemux_stream->preloader,
download_req))
return GST_FLOW_OK;
/* We're about to request something, but it wasn't the active preload,
* so make sure that's been stopped / cancelled so we're not downloading
* two things in parallel. This usually means the playlist refresh
* took too long and the preload became obsolete */
if (stream->downloading_header) {
gst_hls_demux_preloader_cancel (hlsdemux_stream->preloader,
M3U8_PRELOAD_HINT_MAP);
} else {
gst_hls_demux_preloader_cancel (hlsdemux_stream->preloader,
M3U8_PRELOAD_HINT_PART);
}
}
return