New JEmu2, please help testing strange probs

http://www.gagaplay.com/jemu2/jemu2.jnlp

So here’s the thing:
Apart from some other new features, I’ve made some heavy changes in the emulation core related to sound and timing.
I’ve included support for System.nanoTime (which can be switched off), and I’ve done some changes in the sound emulation core which should eliminate some (minor) sound pops and cracks present in the previous versions.

  1. The timing problem
    Per default, JEmu2 uses the most accurate timer available, which can be either LWJGL’s timer, or System.nanoTime (if available on your version of java). The latter can be disabled using the Options menu.
    On java 1.4, everything works fine. On java 5.0 and 6.0, when you disable the nanoTime implementation (which results in defaulting to LWJGL), timing can be waaaay off or sometimes JEmu2 won’t even start (black screen). This is on my desktop, but I’ve seen it work without problems on another computers too. If I output timing values to the log, it seems to work fine but it doesn’t.
    Could you please test the following: Run JEmu2 with preferrably a 50Hz game (for example MSX Nemesis1,2 or 3), press F9, and check if the FPS is correct (should be 50, on my PC it varies around 32). Test with both nanoTimer enabled and disabled, and if possible on Java 1.4, 5.0 and 6.0.

  2. The sound problem
    Using the new timing implementation, sound updating should be more accurate, minimizing the chance of pops and cracks.
    On java 1.4, no problems. On java 5 and 6, it works great using nanoTime at first with less latency and silky smooth sound (sounds better than 1.4 which still has the occasional pop due to less precise timing).
    Until you let it run for some time… After a minute or so, sounds starts breaking up until it’s completely distorted as if sound is not updated for a lot of the times. If I log the sound line’s buffer status, there seem to be no buffer underruns of overruns, so again everything seems fine, but still it sounds like crap. Well, to make it worse, on my machine it SOMETIMES works okay!
    Test for example MSX SD-Snatcher, just let it run without touching a key (just let the intro with the music roll). At about halfway the demo (sometimes earlier, sometimes later), sounds starts to go wrong on my machine running on java 5.0 or 6.0.

If someone could do some tests using the above info and let me know the results, that would be great!

A little update: The LWJGL timer definitely returns wrong numbers in some cases in java 5.0 and up. On my machine this leads to buffer overflows in the JavaSound (which btw is not noticable in the logging), which in turn leads to JavaSound blocking everything.
I found that when I disable the dynamic buffering feature in this version of JEmu2, most problems are gone except that, well… My nice new dynamic audio buffering feature doesn’t work anymore :stuck_out_tongue: (So if a game runs too slow, you’ll get buffer underruns again).

So for the time being I’ll upload this version so in case you were testing, please wait until I upload a ‘private’ version. Thanks!

[EDIT] Use this link to test: http://www.gagaplay.com/jemu2/jemu2b.jnlp