Start the next Next Up episode before finishing the previous one's bookkeeping (issue #82) - #86
Merged
Merged
Conversation
…okkeeping (issue #82) onPlaybackStateChanged(STATE_ENDED) ran a chain of sequential, awaited DB/DataStore work (clear position, mark read, check auto-delete setting, possibly delete a file) before playNextQueued() even started resolving and preparing the next episode -- none of that bookkeeping is a prerequisite for starting playback, so it was pure added silence on top of whatever buffering the next episode's own prepare() needs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PlaybackService.onPlaybackStateChanged(STATE_ENDED)ran a chain of sequential, awaited DB/DataStore work (clear enclosure position, mark read, read the auto-delete setting, possibly delete a downloaded file, clearlastPlayingItem) beforeplayNextQueued()even started resolving and preparing the next episode. None of that bookkeeping is a prerequisite for starting the next episode's playback -- it was pure added silence on top of whatever bufferingplayer.prepare()itself needs.playNextQueued()runs first; the finished episode's bookkeeping now happens after, no longer blocking the transition.playNextQueued()used to rely on the caller unconditionally clearinglastPlayingItemto null right before it ran; since that line moved,playNextQueued()now owns clearing it on every early-return path itself (queue empty, item/feed missing, resolve failure), so behavior there is unchanged.Testing (emulator, manual)
Verified end-to-end on the emulator with a real feed (This Week in Tech) and two queued episodes, using
dumpsys media_sessionpolling to get wall-clock timestamps around the transition:This is a real, verified improvement to the specific inefficiency it targets (unnecessary sequential bookkeeping ahead of playback start), not a claim that it fully eliminates the gap for streamed episodes -- fully closing that would need pre-buffering the next episode while the current one is still playing (a bigger, separate architectural change).
Test plan
./gradlew assembleDebug testDebugUnitTest lintDebugRefs #82