From cedf96d8ca40ada435dd985f64307261b5c4fcc0 Mon Sep 17 00:00:00 2001 From: Rob Walch Date: Wed, 3 Jul 2024 14:33:36 -0700 Subject: [PATCH] Make sure `reduceMaxBufferLength` can reach a min length of fragment duration resulting in buffer full error (#6539) Resolves #6535 --- src/controller/base-stream-controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controller/base-stream-controller.ts b/src/controller/base-stream-controller.ts index 4d366db2d46..dfbc8e2b2c4 100644 --- a/src/controller/base-stream-controller.ts +++ b/src/controller/base-stream-controller.ts @@ -1029,12 +1029,13 @@ export default class BaseStreamController protected reduceMaxBufferLength(threshold: number, fragDuration: number) { const config = this.config; const minLength = Math.max( - Math.min(threshold, config.maxBufferLength), + Math.min(threshold - fragDuration, config.maxBufferLength), fragDuration, ); const reducedLength = Math.max( threshold - fragDuration * 3, config.maxMaxBufferLength / 2, + minLength, ); if (reducedLength >= minLength) { // reduce max buffer length as it might be too high. we do this to avoid loop flushing ...