mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-03 03:31:28 +03:00
Load sounds on demand (saves ~200mb RAM on startup)
This commit is contained in:
@@ -105,20 +105,12 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
@Override
|
||||
public Sound loadSync(AssetManager manager, String fileName, Fi file, SoundParameter parameter){
|
||||
if(parameter != null && parameter.sound != null){
|
||||
mainExecutor.submit(() -> parameter.sound.load(file));
|
||||
parameter.sound.loadLazy(file);
|
||||
|
||||
return parameter.sound;
|
||||
}else{
|
||||
Sound sound = new Sound();
|
||||
|
||||
mainExecutor.submit(() -> {
|
||||
try{
|
||||
sound.load(file);
|
||||
}catch(Throwable t){
|
||||
Log.err("Error loading sound: " + file, t);
|
||||
}
|
||||
});
|
||||
|
||||
sound.loadLazy(file);
|
||||
return sound;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class Vars implements Loadable{
|
||||
public static Locale[] locales;
|
||||
|
||||
//the main executor will only have at most [cores] number of threads active
|
||||
public static ExecutorService mainExecutor = Threads.executor("Main Executor", OS.cores);
|
||||
public static ExecutorService mainExecutor = Core.executor;
|
||||
|
||||
public static FileTree tree = new FileTree();
|
||||
public static Net net;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class SoundPriority{
|
||||
sameGroup(shootArc, shootPulsar);
|
||||
|
||||
for(var sound : Core.assets.getAll(Sound.class, new Seq<>())){
|
||||
sound.setMinConcurrentInterrupt(Math.min(0.25f, sound.getLength() * 0.5f));
|
||||
sound.setMinConcurrentInterruptFraction(0.25f, 0.5f);
|
||||
}
|
||||
|
||||
mechStepSmall.setMinConcurrentInterrupt(0.5f);
|
||||
|
||||
@@ -579,9 +579,8 @@ public class Renderer implements ApplicationListener{
|
||||
ui.showInfo("@screenshot.invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
|
||||
FrameBuffer buffer = new FrameBuffer(w, h);
|
||||
|
||||
drawWeather = false;
|
||||
|
||||
+1
-1
@@ -26,4 +26,4 @@ org.gradle.caching=true
|
||||
org.gradle.internal.http.socketTimeout=100000
|
||||
org.gradle.internal.http.connectionTimeout=100000
|
||||
android.enableR8.fullMode=false
|
||||
archash=6ea6355ee3
|
||||
archash=6e3c0bbc30
|
||||
|
||||
Reference in New Issue
Block a user