refactor: move synchronized keyword in funtion header
This commit is contained in:
parent
f351429049
commit
a429198833
1 changed files with 28 additions and 38 deletions
|
|
@ -497,24 +497,20 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
playSongAt(queueManager.getNextPosition(force));
|
playSongAt(queueManager.getNextPosition(force));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openTrackAndPrepareNextAt(int position) {
|
private synchronized void openTrackAndPrepareNextAt(int position) {
|
||||||
synchronized (this) {
|
queueManager.position = position;
|
||||||
queueManager.position = position;
|
|
||||||
|
|
||||||
openCurrent();
|
openCurrent();
|
||||||
playback.start();
|
playback.start();
|
||||||
|
|
||||||
notifyChange(META_CHANGED);
|
notifyChange(META_CHANGED);
|
||||||
notHandledMetaChangedForCurrentTrack = false;
|
notHandledMetaChangedForCurrentTrack = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openCurrent() {
|
private synchronized void openCurrent() {
|
||||||
synchronized (this) {
|
if (queueManager.getCurrentSong() == null) return;
|
||||||
if (queueManager.getCurrentSong() == null) return;
|
|
||||||
|
|
||||||
playback.setDataSource(queueManager.getCurrentSong());
|
playback.setDataSource(queueManager.getCurrentSong());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareNext() {
|
private void prepareNext() {
|
||||||
|
|
@ -522,13 +518,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
playerHandler.obtainMessage(PREPARE_NEXT).sendToTarget();
|
playerHandler.obtainMessage(PREPARE_NEXT).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareNextImpl() {
|
private synchronized void prepareNextImpl() {
|
||||||
synchronized (this) {
|
if (queueManager.getCurrentSong() == null) return;
|
||||||
if (queueManager.getCurrentSong() == null) return;
|
|
||||||
|
|
||||||
queueManager.nextPosition = queueManager.getNextPosition(false);
|
queueManager.nextPosition = queueManager.getNextPosition(false);
|
||||||
playback.queueDataSource(queueManager.getSongAt(queueManager.nextPosition));
|
playback.queueDataSource(queueManager.getSongAt(queueManager.nextPosition));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initNotification() {
|
public void initNotification() {
|
||||||
|
|
@ -656,20 +650,18 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void play() {
|
public synchronized void play() {
|
||||||
synchronized (this) {
|
if (!playback.isPlaying()) {
|
||||||
if (!playback.isPlaying()) {
|
if (!playback.isReady()) {
|
||||||
if (!playback.isReady()) {
|
playSongAt(queueManager.position);
|
||||||
playSongAt(queueManager.position);
|
} else {
|
||||||
} else {
|
playback.start();
|
||||||
playback.start();
|
if (notHandledMetaChangedForCurrentTrack) {
|
||||||
if (notHandledMetaChangedForCurrentTrack) {
|
handleChangeInternal(META_CHANGED);
|
||||||
handleChangeInternal(META_CHANGED);
|
notHandledMetaChangedForCurrentTrack = false;
|
||||||
notHandledMetaChangedForCurrentTrack = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyChange(STATE_CHANGED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notifyChange(STATE_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -694,12 +686,10 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
return playback.getDuration();
|
return playback.getDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int seek(int millis) {
|
public synchronized int seek(int millis) {
|
||||||
synchronized (this) {
|
playback.setProgress(millis);
|
||||||
playback.setProgress(millis);
|
throttledSeekHandler.notifySeek();
|
||||||
throttledSeekHandler.notifySeek();
|
return millis;
|
||||||
return millis;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyChange(@NonNull final String what) {
|
private void notifyChange(@NonNull final String what) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue