diff --git a/src/controller/audio-stream-controller.ts b/src/controller/audio-stream-controller.ts index 19adf6aaf43..94252a3f35f 100644 --- a/src/controller/audio-stream-controller.ts +++ b/src/controller/audio-stream-controller.ts @@ -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() { diff --git a/src/controller/base-stream-controller.ts b/src/controller/base-stream-controller.ts index 63a56f5aecc..184b95fc583 100644 --- a/src/controller/base-stream-controller.ts +++ b/src/controller/base-stream-controller.ts @@ -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