Tighten lock in writeState
This commit is contained in:
parent
3369774158
commit
5a15f52a29
@ -407,8 +407,14 @@ public final class SongTimeline {
|
||||
{
|
||||
// Must update PlaybackService.STATE_VERSION when changing behavior
|
||||
// here.
|
||||
|
||||
ArrayList<Song> songs;
|
||||
synchronized (this) {
|
||||
ArrayList<Song> songs = mSongs;
|
||||
// Just grab a copy and release the lock soon:
|
||||
// Performing the actual IO is pretty expensive and
|
||||
// could stall UI elements accessing the timeline.
|
||||
songs = new ArrayList(mSongs);
|
||||
}
|
||||
|
||||
int size = songs.size();
|
||||
out.writeInt(size);
|
||||
@ -427,7 +433,6 @@ public final class SongTimeline {
|
||||
out.writeInt(mFinishAction);
|
||||
out.writeInt(mShuffleMode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current callback to <code>callback</code>.
|
||||
|
Loading…
x
Reference in New Issue
Block a user