From 90599440dcac8116fe369654716c38b84efffc5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 8 Jun 2023 20:24:52 +0200 Subject: [PATCH] fix: Avoid unnecessary timestampOffset updates when using HLS segments mode (#5270) With this change, we are changing the minimum timestampOffsetDifference to 0.1 to prevent unnecessary timestampOffset updates --- lib/media/media_source_engine.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index 92e4ef7d4c..bf680b874c 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -691,7 +691,7 @@ shaka.media.MediaSourceEngine = class { Math.round(metadataTimestamp.data) / 1000; const timestampOffsetDifference = Math.abs(timestampOffset - calculatedTimestampOffset); - if (timestampOffsetDifference >= 0.01 || seeked || adaptation) { + if (timestampOffsetDifference >= 0.1 || seeked || adaptation) { timestampOffset = calculatedTimestampOffset; this.enqueueOperation_(contentType, () => this.abort_(contentType)); @@ -741,7 +741,7 @@ shaka.media.MediaSourceEngine = class { const calculatedTimestampOffset = reference.startTime - startTime; const timestampOffsetDifference = Math.abs(timestampOffset - calculatedTimestampOffset); - if (timestampOffsetDifference >= 0.01 || seeked || adaptation) { + if (timestampOffsetDifference >= 0.1 || seeked || adaptation) { timestampOffset = calculatedTimestampOffset; this.enqueueOperation_(contentType, () => this.abort_(contentType)); this.enqueueOperation_( @@ -757,7 +757,7 @@ shaka.media.MediaSourceEngine = class { const calculatedTimestampOffset = reference.startTime - startTime; const timestampOffsetDifference = Math.abs(timestampOffset - calculatedTimestampOffset); - if (timestampOffsetDifference >= 0.01 || seeked || adaptation) { + if (timestampOffsetDifference >= 0.1 || seeked || adaptation) { timestampOffset = calculatedTimestampOffset; // The SourceBuffer timestampOffset may or may not be set yet, // so this is the timestamp offset that would eventually compute