From 7598824b9848f55c2fc267886b8d7aae811709e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Thu, 2 Jan 2025 16:59:17 +0100 Subject: [PATCH 1/3] test: Fix GAP in Safari test --- test/test/assets/hls-text-offset/playlist-video.m3u8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test/assets/hls-text-offset/playlist-video.m3u8 b/test/test/assets/hls-text-offset/playlist-video.m3u8 index 2dd785ef1e..036a3fe7aa 100644 --- a/test/test/assets/hls-text-offset/playlist-video.m3u8 +++ b/test/test/assets/hls-text-offset/playlist-video.m3u8 @@ -7,7 +7,7 @@ video-069.ts #EXTINF:2.000000 video-070.ts -#EXTINF:1.583000 +#EXTINF:1.445000 video-071.ts #EXT-X-DISCONTINUITY #EXTINF:0.917000 From 16b2aa90a0c3178e4f199add653eebbccff53d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Thu, 2 Jan 2025 17:15:13 +0100 Subject: [PATCH 2/3] Another fix :) --- lib/media/media_source_engine.js | 6 ++++++ test/test/assets/hls-text-offset/playlist-video.m3u8 | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index 47fc7b5e56..cd19875207 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -1599,6 +1599,12 @@ shaka.media.MediaSourceEngine = class { return; } + // Avoid changing timestampOffset when the difference is less than 100 ms + // from the end of the current buffer. + if (Math.abs(this.bufferEnd(contentType) - timestampOffset) < 0.1) { + return; + } + // Queue an abort() to help MSE splice together overlapping segments. // We set appendWindowEnd when we change periods in DASH content, and the // period transition may result in overlap. diff --git a/test/test/assets/hls-text-offset/playlist-video.m3u8 b/test/test/assets/hls-text-offset/playlist-video.m3u8 index 036a3fe7aa..2dd785ef1e 100644 --- a/test/test/assets/hls-text-offset/playlist-video.m3u8 +++ b/test/test/assets/hls-text-offset/playlist-video.m3u8 @@ -7,7 +7,7 @@ video-069.ts #EXTINF:2.000000 video-070.ts -#EXTINF:1.445000 +#EXTINF:1.583000 video-071.ts #EXT-X-DISCONTINUITY #EXTINF:0.917000 From 4a7f88a79d68e023b0b35dc8d0fdd828e43e9198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Thu, 2 Jan 2025 17:18:52 +0100 Subject: [PATCH 3/3] Fix lint --- lib/media/media_source_engine.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index cd19875207..6280472e4d 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -1601,7 +1601,8 @@ shaka.media.MediaSourceEngine = class { // Avoid changing timestampOffset when the difference is less than 100 ms // from the end of the current buffer. - if (Math.abs(this.bufferEnd(contentType) - timestampOffset) < 0.1) { + const bufferEnd = this.bufferEnd(contentType); + if (bufferEnd && Math.abs(bufferEnd - timestampOffset) < 0.1) { return; }