If I referenced this class early in my project, the slow browsing problem disappeared. This class is supposed to be created only once, right? But isn't instantiated before the instance is referenced, so it can't have anything to do with garbage collection?
import org.lwjgl.fmod3.FMOD;
import org.lwjgl.fmod3.FMODException;
import org.lwjgl.fmod3.FSound;
import org.lwjgl.fmod3.FSoundStream;
import static org.lwjgl.fmod3.FSound.*;
public class SoundPlayer {
public static final SoundPlayer instance = new SoundPlayer();
private SoundPlayer() {
init();
}
private void init() {
try {
FMOD.create();
FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
FSOUND_Init(44100, 32, 0);
} catch (FMODException e) {
System.out.println("Error:" + FMOD.FMOD_ErrorString(FSOUND_GetError()));
e.printStackTrace();
}
}
public void play(String file) {
file = file.replaceAll("\\\\", "/");
FSoundStream stream = FSound.FSOUND_Stream_Open(file, FSound.FSOUND_NORMAL, 0, 0);
FSOUND_Stream_SetMode(stream, FSOUND_LOOP_OFF);
FSound.FSOUND_Stream_Play(1, stream);
}
public void stop() {
FSOUND_StopSound(FSOUND_ALL);
}
public static void destroy() {
FSOUND_Close();
FMOD.destroy();
}
}