From 50b99979e1dccee31208d4bd03d8480a77ece666 Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Sat, 26 Sep 2026 20:07:44 +0000 Subject: [PATCH] drop the first-play pre-buffering It made no perceivable difference to the first-play hitch, so it only cost buffering audio at launch that the user may never play. loadWindow prepares when it plays again, and the two tests go back to their original assertions. --- .../com/subtracks/playback/PlaybackController.kt | 6 ++++-- .../com/subtracks/playback/PlaybackControllerTest.kt | 10 +++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/subtracks/playback/PlaybackController.kt b/app/src/main/kotlin/com/subtracks/playback/PlaybackController.kt index d1251537..4b74bf3a 100644 --- a/app/src/main/kotlin/com/subtracks/playback/PlaybackController.kt +++ b/app/src/main/kotlin/com/subtracks/playback/PlaybackController.kt @@ -705,8 +705,10 @@ class PlaybackController( updating = true player.setWindow(window.map { it.item.toQueueItem() }, startIndex, startPositionMs) updating = false - player.prepare() - if (autoplay) player.play() + if (autoplay) { + player.prepare() + player.play() + } refresh(position) } diff --git a/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt b/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt index 43d945e5..c2edddba 100644 --- a/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt +++ b/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt @@ -145,20 +145,18 @@ class PlaybackControllerTest { } @Test - fun aRestoredQueueIsPreparedBeforeTheFirstPlay() { + fun togglingPlayOnARestoredQueuePreparesBeforePlaying() { seedAlbum(5, sourceId = 1) runBlocking { queues.replace(listOf(queues.albumEntry(1, "al1"))) } controller.connect() await { handle.items.isNotEmpty() } - await { handle.operations.contains("prepare") } - handle.operations.clear() controller.togglePlayPause() await { handle.operations.contains("play") } - assertEquals(listOf("play"), handle.operations) + assertEquals(listOf("prepare", "play"), handle.operations) } @Test @@ -1081,9 +1079,7 @@ class PlaybackControllerTest { assertEquals(33_000L, handle.positionMs) assertFalse(handle.playWhenReady) - val reload = handle.operations.drop(before) - assertTrue("a reload must re-prepare, or the next play pays for it", reload.any { it == "prepare" }) - assertTrue(reload.none { it == "play" }) + assertTrue(handle.operations.drop(before).none { it.startsWith("prepare") || it.startsWith("play") }) } @Test