v1.0.2: added a missing sync check in music to prevent crashes
This commit is contained in:
@@ -129,15 +129,16 @@ public enum Music {
|
|||||||
private com.badlogic.gdx.audio.Music.OnCompletionListener trackLooper = new com.badlogic.gdx.audio.Music.OnCompletionListener() {
|
private com.badlogic.gdx.audio.Music.OnCompletionListener trackLooper = new com.badlogic.gdx.audio.Music.OnCompletionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCompletion(com.badlogic.gdx.audio.Music music) {
|
public void onCompletion(com.badlogic.gdx.audio.Music music) {
|
||||||
if (trackList == null || trackList.length == 0 || player.isLooping() || music != player){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//we do this in a separate thread to avoid graphics hitching while the music is prepared
|
//we do this in a separate thread to avoid graphics hitching while the music is prepared
|
||||||
//FIXME this fixes graphics stutter but there's still some audio stutter, perhaps keep more than 1 player alive?
|
//FIXME this fixes graphics stutter but there's still some audio stutter, perhaps keep more than 1 player alive?
|
||||||
new Thread(){
|
new Thread(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
synchronized (Music.INSTANCE) {
|
||||||
|
if (trackList == null || trackList.length == 0 || player.isLooping() || music != player){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Music.this.stop();
|
Music.this.stop();
|
||||||
|
|
||||||
if (trackQueue.isEmpty()) {
|
if (trackQueue.isEmpty()) {
|
||||||
@@ -155,6 +156,7 @@ public enum Music {
|
|||||||
|
|
||||||
play(trackQueue.remove(0), trackLooper);
|
play(trackQueue.remove(0), trackLooper);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user