In case something goes screwy and we come up with a bogus time to sleep waiting

on our sound to play, make sure we do at least our half second fudge, rather 
than spewing errors as we try to sleep for negative amounts of time.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@332 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2007-11-07 18:34:40 +00:00
parent e46e126604
commit ffd07764ee
@@ -597,11 +597,13 @@ public class SoundManager
int drainTime = (int) Math.ceil((totalRead * 8 * 1000) / (sampleRate * sampleSize));
// add in a fudge factor of half a second
drainTime += 500;
// subtract out time we've already spent doing things.
drainTime -= System.currentTimeMillis() - startTime;
drainTime = Math.max(0, drainTime);
// add in a fudge factor of half a second
drainTime += 500;
try {
Thread.sleep(drainTime);