playback: make state db sync
Add synchronized calls to PlaybackStateDatabase to resolve future race conditions.
This commit is contained in:
@@ -188,6 +188,7 @@ class PlaybackStateDatabase(context: Context) :
|
|||||||
fun write(state: SavedState) {
|
fun write(state: SavedState) {
|
||||||
requireBackgroundThread()
|
requireBackgroundThread()
|
||||||
|
|
||||||
|
synchronized(this) {
|
||||||
val song = state.queue.getOrNull(state.index)
|
val song = state.queue.getOrNull(state.index)
|
||||||
|
|
||||||
if (song != null) {
|
if (song != null) {
|
||||||
@@ -216,6 +217,7 @@ class PlaybackStateDatabase(context: Context) :
|
|||||||
|
|
||||||
logD("Wrote state to database")
|
logD("Wrote state to database")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun writeRawState(rawState: RawState?) {
|
private fun writeRawState(rawState: RawState?) {
|
||||||
writableDatabase.transaction {
|
writableDatabase.transaction {
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
app:liftOnScroll="true"
|
app:liftOnScroll="true"
|
||||||
app:liftOnScrollTargetViewId="@id/detail_recycler">
|
app:liftOnScrollTargetViewId="@id/detail_recycler">
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
android:id="@+id/detail_toolbar"
|
android:id="@+id/detail_toolbar"
|
||||||
style="@style/Widget.Auxio.Toolbar.Icon.Actions" />
|
style="@style/Widget.Auxio.Toolbar.Icon.Actions" />
|
||||||
|
|||||||
Reference in New Issue
Block a user