I have had a bit of an adventure with the sound system.  It is now
hopefully drawing to a satisfactory close.  Here is an update.

What initially drew my ire was that with Java7 I could not run the
test suite without either running out of memory or getting a crash
somewhere in tritonus.  I had seen memory exhaustion before with
Java6, albeit rarely, but perhaps we were a bit marginal there, and
some extra overhead in Java7 was pushing it over.  I certainly did not
want to increase the memory available to the test suite, we want it to
fail if there is trouble.  Fortunately there was an obvious case of
excess resource preloading in the sound test.  Also as we do not
really need all the images preloaded when testing, I repaired the
"headless" mode, fixed the place where it was ineffectively set in
the test suite, and discouraged preloading in headless mode.  Tests
now ran, but tritonus still fails on occasion.  I committed this today
(svn.9921) after it survived a week without causing problems.

As previously discussed I now looked at using JOgg/JOrbis directly to
do our own audio decoding.  The JCraft people provide an example
JOrbisPlayer (GPL) which works... except on short files, like our
illegal.ogg.  Debugging that lead to a completely rewritten standalone
Java Ogg player that buffers its ogg packets correctly and thus does
not skip the first few seconds of a file.

``This should be easy to insert into FreeCol''... a statement that
lead to a week of fail.  Java sound is rather fragile, and there are a
surprising number of ways to fail.  Some failures were productive---
the ogg player grew into a proper AudioInputStream, but all along I
kept getting weirdly distorted output.

Yesterday evening I got to the point where it all worked except for
one case.  Not always, but most of the time, the initial long
introduction track (intro.ogg) would play seemingly at high speed.  It
was just that one, everything else worked fine (verified by slowing
down the SoundTest so you could hear them all).  I tried re-encoding
it, slowing it down, etc, etc.  Finally I dumped the raw audio data to
a file in parallel with the write to the sound output, and played that
file back from the command line with sox: it was fine.

In the end, Google came through, albeit after several false alarms.
It turns out that there are bugs in the libjsoundalsa.so library.
Ubuntu users had reported mysterious distortions would go away if they
hunted it down and removed/renamed/disabled it[1].  Doing that gave me
100% reliable sound, thus far at least.  Better yet, putting the
library back but instead explicitly selecting the PulseAudio mixer in
the audio options also worked.  This goes a bit against the grain
given PulseAudio's buggy past, but it did the trick today.  What would
be nice now is to have the auto-select option prefer it on my system.

Obviously I still need to do a fair bit more robustness testing, and
now I wonder if this really worth pushing into FreeCol.  It would be
nice to drop the tritonus dependency, but while it may sometimes mess
up the test suite on my machine, tritonus at least does not trigger the
libjsoundalsa problem[2] (do macs use alsa?).  Otherwise, I can see
several rounds of user education before everyone learns not to use the
java-alsa-mixers.

Cheers,
Mike Pope

[1] Its in
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.3.x86_64/jre/lib/amd64/libjsoundalsa.so
on my machine.

[2] Although I am not clear if it is failing to play short files,
another thing to check.

Attachment: signature.asc
Description: This is a digitally signed message part.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Freecol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freecol-developers

Reply via email to