Skip to content

Commit

Permalink
Manage appendBuffer SourceBuffer full errors correctly when audio bit…
Browse files Browse the repository at this point in the history
…rate is higher than video (#5332)

Fixes #5328
  • Loading branch information
robwalch authored Mar 24, 2023
1 parent 3e959c2 commit 651fbd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/controller/audio-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ class AudioStreamController
if (!mainBufferLength) {
return maxConfigBuffer;
}
return Math.max(maxConfigBuffer, mainBufferLength);
return Math.min(
Math.max(maxConfigBuffer, mainBufferLength),
this.config.maxMaxBufferLength
);
}

onMediaDetaching() {
Expand Down
7 changes: 4 additions & 3 deletions src/controller/base-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1481,10 +1481,11 @@ export default class BaseStreamController
);
// 0.5 : tolerance needed as some browsers stalls playback before reaching buffered end
// reduce max buf len if current position is buffered
let flushBuffer = true;
if (bufferedInfo && bufferedInfo.len > 0.5) {
flushBuffer = !this.reduceMaxBufferLength(bufferedInfo.len);
const buffered = bufferedInfo && bufferedInfo.len > 0.5;
if (buffered) {
this.reduceMaxBufferLength(bufferedInfo.len);
}
const flushBuffer = !buffered;
if (flushBuffer) {
// current position is not buffered, but browser is still complaining about buffer full error
// this happens on IE/Edge, refer to https://github.com/video-dev/hls.js/pull/708
Expand Down

0 comments on commit 651fbd5

Please sign in to comment.