v1.0.3: fixed audio issues on desktop caused by threading addition

This commit is contained in:
Evan Debenham
2021-08-30 18:44:48 -04:00
parent e3ffc875ba
commit 30c00f95b6
@@ -131,11 +131,22 @@ public enum Music {
public void onCompletion(com.badlogic.gdx.audio.Music music) {
//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?
if (!DeviceCompat.isDesktop()) {
new Thread() {
@Override
public void run() {
synchronized (Music.INSTANCE) {
if (trackList == null || trackList.length == 0 || player.isLooping() || music != player){
playNextTrack(music);
}
}.start();
} else {
//don't use a separate thread on desktop, causes errors and makes no performance difference(?)
playNextTrack(music);
}
}
};
private synchronized void playNextTrack(com.badlogic.gdx.audio.Music music){
if (trackList == null || trackList.length == 0 || music != player || player.isLooping()){
return;
}
@@ -155,10 +166,6 @@ public enum Music {
}
play(trackQueue.remove(0), trackLooper);
}
}
}.start();
}
};
private synchronized void play(String track, com.badlogic.gdx.audio.Music.OnCompletionListener listener){