playback: make state db sync

Add synchronized calls to PlaybackStateDatabase to resolve future race
conditions.
This commit is contained in:
OxygenCobalt 2022-06-23 15:27:41 -06:00
parent d5c0ccfce0
commit 149da883fe
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 26 additions and 25 deletions

View file

@ -188,6 +188,7 @@ class PlaybackStateDatabase(context: Context) :
fun write(state: SavedState) {
requireBackgroundThread()
synchronized(this) {
val song = state.queue.getOrNull(state.index)
if (song != null) {
@ -216,6 +217,7 @@ class PlaybackStateDatabase(context: Context) :
logD("Wrote state to database")
}
}
private fun writeRawState(rawState: RawState?) {
writableDatabase.transaction {

View file

@ -15,7 +15,6 @@
app:liftOnScroll="true"
app:liftOnScrollTargetViewId="@id/detail_recycler">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/detail_toolbar"
style="@style/Widget.Auxio.Toolbar.Icon.Actions" />