Skip to content

Commit

Permalink
fix: Fix init segment equality in Segment Prefetch (#6537)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed May 6, 2024
1 parent ab26de4 commit ce7cef4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/media/segment_prefetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ shaka.media.SegmentPrefetch = class {
}

// init segments are ignored from the prefetch limit
if (!this.initSegmentPrefetchMap_.has(initSegmentReference)) {
const initSegments = Array.from(this.initSegmentPrefetchMap_.keys());
const someReference = initSegments.some((reference) => {
return shaka.media.InitSegmentReference.equal(
reference, initSegmentReference);
});
if (!someReference) {
const segmentPrefetchOperation =
new shaka.media.SegmentPrefetchOperation(this.fetchDispatcher_);
segmentPrefetchOperation.dispatchFetch(
Expand Down Expand Up @@ -270,9 +275,11 @@ shaka.media.SegmentPrefetch = class {
const segmentReferences = Array.from(this.segmentPrefetchMap_.keys());
for (const initSegmentReference of this.initSegmentPrefetchMap_.keys()) {
// if no segment references this init segment, we should remove it.
if (!segmentReferences.some(
(segmentReference) =>
segmentReference.initSegmentReference === initSegmentReference)) {
const someReference = segmentReferences.some((segmentReference) => {
return shaka.media.InitSegmentReference.equal(
segmentReference.initSegmentReference, initSegmentReference);
});
if (!someReference) {
this.abortPrefetchedSegment_(initSegmentReference);
}
}
Expand Down

0 comments on commit ce7cef4

Please sign in to comment.