Skip to content

Commit

Permalink
fix: Avoid clear buffer when select the same audio track (#6959)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Jul 2, 2024
1 parent b2ee25e commit 5645045
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -4735,9 +4735,9 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
Math.abs((a.video.width || 0) - (b.video.width || 0));
}
};
// Find the variant whose size is closest to the active variant. This
// ensures we stay at about the same resolution when just changing the
// language/role.
// Find the variant whose size is closest to the active variant. This
// ensures we stay at about the same resolution when just changing the
// language/role.
const active = this.streamingEngine_.getCurrentVariant();
const set =
this.currentAdaptationSetCriteria_.create(this.manifest_.variants);
Expand All @@ -4748,6 +4748,10 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
bestVariant = curVariant;
}
}
if (bestVariant == active) {
shaka.log.debug('Audio already selected.');
return;
}
if (bestVariant) {
const track = shaka.util.StreamUtils.variantToTrack(bestVariant);
this.selectVariantTrack(track, /* clearBuffer= */ true, safeMargin);
Expand Down

0 comments on commit 5645045

Please sign in to comment.