HI everybody,
I’ve been playing javax.sound.sampled.Clips like this:
public void play(final String key) {
//new Thread() { @Override public void run() {
Clip clip = clips.get(key);
if (clip!=null) {
clip.stop();
clip.setFramePosition(0);
clip.start();
}
//}}.start();
}
I’m testing on a Core 2 Duo, 4GHz, so the machine is plenty fast. My game is running at 30 fps, and I’m noticing a big performance difference when using a 32-bit JRE vs. a 64-bit one.
I’m currently playing a sound each time the user presses a key. If the user holds down the key, that sound plays repeatedly, as quickly as possible. When running on a 32-bit JRE, this works fine, and the game stays at a solid 30 fps. When running on a 64-bit JRE, however, performance drops to 15 fps. I tested with a 1.5 and 1.6 JRE for both levels of bitness, and the result is the same.
Any idea what’s causing this? Am I doing something wrong? I notice that when I run the sound effect in a thread (using the commented out lines), I don’t have this performance drop in 64-bit. Is this a bad workaround - launching (possibly) 30 threads per second, albeit short-lived threads?