Skip to content

Commit

Permalink
Fix back buffer not being flushed when backBufferLength is set to 0 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiller02 authored Oct 21, 2024
1 parent d25ad97 commit 7afdcff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/controller/buffer-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ transfer tracks: ${JSON.stringify(transferredTracks, (key, value) => (key === 'i
? config.liveBackBufferLength
: config.backBufferLength;

if (Number.isFinite(backBufferLength) && backBufferLength > 0) {
if (Number.isFinite(backBufferLength) && backBufferLength >= 0) {
const maxBackBufferLength = Math.max(backBufferLength, targetDuration);
const targetBackBufferPosition =
Math.floor(currentTime / targetDuration) * targetDuration -
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/controller/buffer-controller-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,14 @@ describe('BufferController with attached media', function () {
expect(triggerSpy).to.not.have.been.calledWith(Events.BUFFER_FLUSHING);
});

it('should execute a remove operation if backBufferLength is set to 0', function () {
hls.config.backBufferLength = 0;
evokeTrimBuffers(hls);
expect(triggerSpy.withArgs(Events.BUFFER_FLUSHING)).to.have.callCount(
2,
);
});

it('should execute a remove operation if flushing a valid backBuffer range', function () {
evokeTrimBuffers(hls);
expect(triggerSpy.withArgs(Events.BUFFER_FLUSHING)).to.have.callCount(
Expand Down

0 comments on commit 7afdcff

Please sign in to comment.