playback: fix crash w/add to queue

Again, a two-fold problem:
- Was not properly giving the right StateAck to the state holder
- ShuffleOrder not properly handling the index given when adding to
queue internally

Resolves #727.
This commit is contained in:
Alexander Capehart 2024-02-26 16:08:44 -07:00
parent 44b7a435d1
commit 691ed202e5
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 6 additions and 2 deletions

View file

@ -492,7 +492,7 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
} else { } else {
val stateHolder = stateHolder ?: return val stateHolder = stateHolder ?: return
logD("Adding ${songs.size} songs to end of queue") logD("Adding ${songs.size} songs to end of queue")
stateHolder.addToQueue(songs, StateAck.AddToQueue(stateMirror.index + 1, songs.size)) stateHolder.addToQueue(songs, StateAck.AddToQueue(queue.size, songs.size))
} }
} }

View file

@ -69,7 +69,11 @@ class BetterShuffleOrder(private val shuffled: IntArray) : ShuffleOrder {
} }
val newShuffled = IntArray(shuffled.size + insertionCount) val newShuffled = IntArray(shuffled.size + insertionCount)
val pivot = indexInShuffled[insertionIndex] val pivot: Int = if (insertionIndex < shuffled.size) {
indexInShuffled[insertionIndex]
} else {
indexInShuffled.size
}
for (i in shuffled.indices) { for (i in shuffled.indices) {
var currentIndex = shuffled[i] var currentIndex = shuffled[i]
if (currentIndex > insertionIndex) { if (currentIndex > insertionIndex) {