From 76f3b391626ed3e629da60e408de16c0da85496f Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Mon, 28 Sep 2026 09:49:33 +0000 Subject: [PATCH] Revert "stop estimating a length for Ogg-based transcodes" This reverts commit aeb08bf628cc98f81bd3084bce1a2a5da0a2e762. --- .../main/kotlin/com/subtracks/data/source/StreamLength.kt | 6 ------ .../kotlin/com/subtracks/data/source/StreamLengthTest.kt | 7 ------- 2 files changed, 13 deletions(-) diff --git a/app/src/main/kotlin/com/subtracks/data/source/StreamLength.kt b/app/src/main/kotlin/com/subtracks/data/source/StreamLength.kt index 38490225..5f7e6452 100644 --- a/app/src/main/kotlin/com/subtracks/data/source/StreamLength.kt +++ b/app/src/main/kotlin/com/subtracks/data/source/StreamLength.kt @@ -10,18 +10,12 @@ private const val LOSSLESS_CEILING_BPS = 9_216_000L private const val OVERHEAD_BYTES = 256L * 1024L private val LOSSLESS_FORMATS = setOf("flac", "wav", "alac") -// Ogg-based streams seek by binary-searching for the last page from the end of the file, so a -// length estimate that overshoots makes the player read past the real data and the server answers -// 416 (POSITION_OUT_OF_RANGE). These get no estimate and seek only within what is buffered. -private val END_SEEKING_FORMATS = setOf("opus", "ogg", "vorbis") - fun declaredStreamLength( durationMs: Long?, quality: StreamQuality, ): Long? { if (durationMs == null || durationMs <= 0) return null if (!quality.transcodes) return null - if (quality.format?.lowercase() in END_SEEKING_FORMATS) return null val bps = when { quality.format?.lowercase() in LOSSLESS_FORMATS -> LOSSLESS_CEILING_BPS diff --git a/app/src/test/kotlin/com/subtracks/data/source/StreamLengthTest.kt b/app/src/test/kotlin/com/subtracks/data/source/StreamLengthTest.kt index 07f3c03b..ea4991d1 100644 --- a/app/src/test/kotlin/com/subtracks/data/source/StreamLengthTest.kt +++ b/app/src/test/kotlin/com/subtracks/data/source/StreamLengthTest.kt @@ -39,13 +39,6 @@ class StreamLengthTest { assertTrue(cdQuality >= 320 * 1_411_200 / 8) } - @Test - fun oggBasedFormatsGetNoEstimateBecauseSeekingReadsFromTheEnd() { - assertNull(declaredStreamLength(180_000, StreamQuality(128, "opus"))) - assertNull(declaredStreamLength(180_000, StreamQuality(128, "ogg"))) - assertNull(declaredStreamLength(180_000, StreamQuality(128, "vorbis"))) - } - @Test fun theLengthSuffixRoundTripsThroughTheFragment() { val uri = "http://host/rest/stream.view?id=s1" + streamLengthSuffix(1_234_567)