address review: share the test helpers, guard AppModuleTest cleanup

Use cancelAndJoinBlocking in the repo tests and AppModuleTest instead of hand-rolled runBlocking joins, put AppModuleTest's cleanup in a finally so a failed join cannot leave Main overridden and Koin started, and collapse the five polling await copies into one awaitUntil. upcomingItem now reads the queue snapshot under the lock but does the Room read outside it.
This commit is contained in:
austinried
2026-10-04 00:30:06 +00:00
parent 88b53821bd
commit 26f58b7502
11 changed files with 48 additions and 57 deletions
@@ -868,12 +868,17 @@ class PlaybackController(
thumbnail: Boolean = false,
): CoverArtRef? = sourceRepository.coverArt(item?.coverArtId, thumbnail)
suspend fun upcomingItem(): QueueItem? =
suspend fun upcomingItem(): QueueItem? {
var current: QueueSnapshot? = null
var position: Long? = null
startLock.withLock {
val snap = snapshot ?: return@withLock null
val position = currentPosition() ?: return@withLock null
queueRepository.itemAt(snap, position + 1)?.toQueueItem()
current = snapshot
position = currentPosition()
}
val snapshot = current ?: return null
val at = position ?: return null
return queueRepository.itemAt(snapshot, at + 1)?.toQueueItem()
}
private fun play(
entries: List<QueueEntry>,