mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-16 01:00:17 +01:00
playback: take the start lock before reading the tap preference
This commit is contained in:
@@ -990,19 +990,28 @@ class PlaybackController(
|
||||
connect()
|
||||
return
|
||||
}
|
||||
scope.launch { start(entry, startPosition, behavior ?: preferences.songTapBehavior().first()) }
|
||||
scope.launch {
|
||||
startLock.withLock {
|
||||
startLocked(entry, startPosition, behavior ?: preferences.songTapBehavior().first())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun startPending(pending: PendingPlay) {
|
||||
val behavior = pending.behavior ?: preferences.songTapBehavior().first()
|
||||
start(pending.entry, pending.position, behavior)
|
||||
start(pending.entry, pending.position, pending.behavior ?: preferences.songTapBehavior().first())
|
||||
}
|
||||
|
||||
private suspend fun start(
|
||||
entry: QueueEntry,
|
||||
startPosition: Long,
|
||||
behavior: SongTapBehavior,
|
||||
) = startLock.withLock {
|
||||
) = startLock.withLock { startLocked(entry, startPosition, behavior) }
|
||||
|
||||
private suspend fun startLocked(
|
||||
entry: QueueEntry,
|
||||
startPosition: Long,
|
||||
behavior: SongTapBehavior,
|
||||
) {
|
||||
val modes = queueRepository.modes()
|
||||
val shuffle =
|
||||
when (behavior) {
|
||||
@@ -1017,7 +1026,7 @@ class PlaybackController(
|
||||
queueSourceId = entry.sourceId
|
||||
if (snapshot.size == 0L) {
|
||||
stopLocked()
|
||||
return@withLock
|
||||
return
|
||||
}
|
||||
val start = startPosition.coerceIn(0, snapshot.contextSize - 1)
|
||||
val position =
|
||||
|
||||
@@ -849,8 +849,6 @@ private fun SortNameModeDialog(
|
||||
)
|
||||
}
|
||||
|
||||
private val songTapBehaviorOptions = SongTapBehavior.entries
|
||||
|
||||
private fun songTapBehaviorLabel(
|
||||
resources: Resources,
|
||||
behavior: SongTapBehavior,
|
||||
@@ -875,7 +873,7 @@ private fun SongTapBehaviorDialog(
|
||||
text = {
|
||||
ChoiceGroup(
|
||||
header = stringResource(R.string.settings_music_options_song_tap_prompt),
|
||||
options = songTapBehaviorOptions.map { it to songTapBehaviorLabel(resources, it) },
|
||||
options = SongTapBehavior.entries.map { it to songTapBehaviorLabel(resources, it) },
|
||||
selected = draft,
|
||||
onSelect = { draft = it },
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user