From 11276c2e1f1e5559763fa61ef23699b2a63d1a59 Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:13:22 +0000 Subject: [PATCH] playback: revert the restored session prepare Preparing the restored window on launch was meant to make the paused session reachable from Bluetooth and Automate. The follow-up on the issue shows the notification appears, but the car's play command still does not reach the app until the phone is unlocked, and the speculative prepare buffered up to 50 seconds of the restored track on every launch while claiming the media controls whenever the app opened. Removing the prepare also removes the error gate it needed, which could hide genuine playback errors while paused. Reverts #230. --- .../subtracks/playback/PlaybackController.kt | 3 +- .../playback/PlaybackControllerTest.kt | 63 +------------------ 2 files changed, 4 insertions(+), 62 deletions(-) diff --git a/app/src/main/kotlin/com/subtracks/playback/PlaybackController.kt b/app/src/main/kotlin/com/subtracks/playback/PlaybackController.kt index e41b8243..c11673f1 100644 --- a/app/src/main/kotlin/com/subtracks/playback/PlaybackController.kt +++ b/app/src/main/kotlin/com/subtracks/playback/PlaybackController.kt @@ -1070,7 +1070,6 @@ class PlaybackController( } lastSavedPositionMs = savedPositionMs loadWindow(anchor.position, autoplay = false, startPositionMs = savedPositionMs) - player?.takeIf { it.itemCount > 0 }?.ensurePrepared() } private suspend fun stop() = startLock.withLock { stopLocked() } @@ -1452,7 +1451,7 @@ class PlaybackController( } override fun onError(message: UiMessage) { - if (player?.playWhenReady == true) showMessage(message) + showMessage(message) refresh() } } diff --git a/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt b/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt index abd34bd9..a572cc93 100644 --- a/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt +++ b/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt @@ -343,75 +343,18 @@ class PlaybackControllerTest { } @Test - fun restoringAPreviousQueuePreparesTheSessionWithoutPlaying() { - seedAlbum(3, sourceId = 1) - runBlocking { queues.replace(listOf(queues.albumEntry(1, "al1"))) } - - controller.connect() - await { handle.operations.contains("prepare") } - - assertFalse(handle.operations.contains("play")) - assertFalse(handle.isIdle) - assertFalse(handle.playWhenReady) - assertFalse(controller.state.value.isPlaying) - } - - @Test - fun aPrepareFailureBeforePlaybackIsNotReported() { - seedAlbum(3, sourceId = 1) - runBlocking { queues.replace(listOf(queues.albumEntry(1, "al1"))) } - - controller.connect() - await { handle.operations.contains("prepare") } - - handle.fail(UiMessage(R.string.playback_error_network)) - assertTrue(messages.isEmpty()) - - controller.togglePlayPause() - await { handle.operations.contains("play") } - handle.fail(UiMessage(R.string.playback_error_network)) - await { messages.isNotEmpty() } - - assertEquals(1, messages.size) - } - - @Test - fun restoringAnEmptyQueueDoesNotPrepare() { - seedAlbum(3, sourceId = 1) - - controller.connect() - await { controller.ready.value } - - assertTrue(handle.items.isEmpty()) - assertFalse(handle.operations.contains("prepare")) - } - - @Test - fun restoringAnOfflineQueueWithoutDownloadsDoesNotPrepare() { - seedAlbum(3, sourceId = 1) - runBlocking { queues.replace(listOf(queues.albumEntry(1, "al1"))) } - setOffline() - - controller.connect() - await { controller.ready.value } - - assertTrue(handle.items.isEmpty()) - assertFalse(handle.operations.contains("prepare")) - } - - @Test - fun togglingPlayOnARestoredQueuePlaysThePreparedWindow() { + fun togglingPlayOnARestoredQueuePreparesBeforePlaying() { seedAlbum(5, sourceId = 1) runBlocking { queues.replace(listOf(queues.albumEntry(1, "al1"))) } controller.connect() - await { handle.operations.contains("prepare") } + await { handle.items.isNotEmpty() } handle.operations.clear() controller.togglePlayPause() await { handle.operations.contains("play") } - assertEquals(listOf("play"), handle.operations) + assertEquals(listOf("prepare", "play"), handle.operations) } @Test