Skip to content

Commit 588dde0

Browse files
mmarca-techclaude
andcommitted
playback: stop giving ExoPlayer the whole queue
Queue ownership moves from ExoPlayer into ExoPlaybackStateHolder. The player now only ever holds a window of up to 51 MediaItems centered on the current song, slid as playback advances; the full queue lives in plain heap/mapping/index fields that resolveQueue() snapshots, in the same representation RawQueue always used. Handing the player a MediaItem per queue entry was the largest single consumer behind the large-library OutOfMemoryErrors: measured at ~77MB of Java heap for a 40k-song "play from all" queue, transiently doubled on every reshuffle, on top of a library model that already runs ~100MB at that size. Playback buffers allocate from the same heap, which is why the reported traces died inside PlaylistTimeline construction and shouldContinueLoading. Measured on device with the library inflated to 40194 songs: steady heap after shuffle-all 118MB -> 53MB (baseline 47MB) transient peak 159MB -> 83MB after skips + 4 reshuffles 219MB -> 89MB Notes on the mechanics: - Queues that fit entirely in the window behave exactly as before, including native repeat handling. - On larger queues RepeatMode.ALL is emulated by letting the window wrap circularly around the queue edges, so skips and automatic advances cross the seam without the player ever repeating on its own. - Window slides append/remove at the edges only, so gapless preloading of the next song survives ordinary playback. Queue mutations rebuild the window around the current item without interrupting it. - BetterShuffleOrder and the timeline unscrambling walk existed only to read the queue back out of the player, and are deleted; the shuffle mapping is now generated and owned directly. Verified on device: shuffle-all, 30 rapid skips across the window edge, prev, and state persistence across process death all behave; the media session queue index tracked exactly through all of it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 994f8ec commit 588dde0

2 files changed

Lines changed: 339 additions & 295 deletions

File tree

app/src/main/java/org/oxycblt/auxio/playback/service/BetterShuffleOrder.kt

Lines changed: 0 additions & 144 deletions
This file was deleted.

0 commit comments

Comments
 (0)