From ffd07764ee1e221f5def03fa68d57ca656513dff Mon Sep 17 00:00:00 2001 From: Dave Hoover Date: Wed, 7 Nov 2007 18:34:40 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/media/sound/SoundManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/java/com/threerings/media/sound/SoundManager.java b/src/java/com/threerings/media/sound/SoundManager.java index cb6992f3..c39d01b7 100644 --- a/src/java/com/threerings/media/sound/SoundManager.java +++ b/src/java/com/threerings/media/sound/SoundManager.java @@ -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);