mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 13:51:53 +09:00
sound engine is no longer a singleton
This commit is contained in:
@@ -927,7 +927,7 @@ public class App implements ApplicationListener {
|
||||
}
|
||||
|
||||
if (audioMixerInitialised) {
|
||||
AudioMixer.INSTANCE.dispose();
|
||||
audioMixer.dispose();
|
||||
}
|
||||
|
||||
if (currentScreen != null) {
|
||||
@@ -1052,6 +1052,9 @@ public class App implements ApplicationListener {
|
||||
|
||||
private static Boolean audioMixerInitialised = false;
|
||||
|
||||
public static AudioMixer audioMixer;
|
||||
public static int audioBufferSize;
|
||||
|
||||
/**
|
||||
* Init stuffs which needs GL context
|
||||
*/
|
||||
@@ -1203,9 +1206,10 @@ public class App implements ApplicationListener {
|
||||
}
|
||||
|
||||
|
||||
AudioMixer.INSTANCE.getMasterVolume();
|
||||
audioBufferSize = getConfigInt("audio_buffer_size");
|
||||
audioMixer = new AudioMixer(audioBufferSize);
|
||||
audioMixerInitialised = true;
|
||||
audioManagerThread = new Thread(new AudioManagerRunnable(), "TerrarumAudioManager");
|
||||
audioManagerThread = new Thread(new AudioManagerRunnable(audioMixer), "TerrarumAudioManager");
|
||||
audioManagerThread.setPriority(MAX_PRIORITY); // higher = more predictable; audio delay is very noticeable so it gets high priority
|
||||
audioManagerThread.start();
|
||||
|
||||
@@ -1230,6 +1234,17 @@ public class App implements ApplicationListener {
|
||||
printdbg(this, "PostInit done; took "+tms+" seconds");
|
||||
}
|
||||
|
||||
public static void renewAudioProcessor(int bufferSize) {
|
||||
audioManagerThread.interrupt();
|
||||
audioMixer.dispose();
|
||||
|
||||
audioBufferSize = bufferSize;
|
||||
audioMixer = new AudioMixer(audioBufferSize);
|
||||
audioManagerThread = new Thread(new AudioManagerRunnable(audioMixer), "TerrarumAudioManager");
|
||||
audioManagerThread.setPriority(MAX_PRIORITY); // higher = more predictable; audio delay is very noticeable so it gets high priority
|
||||
audioManagerThread.start();
|
||||
}
|
||||
|
||||
|
||||
private void setCameraPosition(float newX, float newY) {
|
||||
camera.position.set((-newX + scr.getWidth() / 2), (-newY + scr.getHeight() / 2), 0f); // deliberate integer division
|
||||
|
||||
Reference in New Issue
Block a user