Calculate the drain time using a long as a decent sized clip can overflow an int

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@609 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Charlie Groves
2008-08-05 20:28:15 +00:00
parent db0e6f93e1
commit 7386c62a68
@@ -657,7 +657,7 @@ public class SoundManager
} catch (IOException e) {
// this shouldn't ever ever happen because the stream
// we're given is from a reliable source
log.warning("Error reading clip data! [e=" + e + "].");
log.warning("Error reading clip data!", e);
return;
}
@@ -689,7 +689,8 @@ public class SoundManager
sampleSize = 16;
}
int drainTime = (int) Math.ceil((totalRead * 8 * 1000) / (sampleRate * sampleSize));
// Calculate the numerator as a long as a decent sized clip * 8000 can overflow an int
int drainTime = (int) Math.ceil((totalRead * 8 * 1000L) / (sampleRate * sampleSize));
// subtract out time we've already spent doing things.
drainTime -= System.currentTimeMillis() - startTime;