Skip to content

Commit

Permalink
BLADERUNNER: Switch to doubles in AudStream::getLength() calculations
Browse files Browse the repository at this point in the history
Since we have everything in samples, and we have 44kHz, we easily
get overflows. Use doubles for calculating the length in
milliseconds more accurately.
  • Loading branch information
sev- committed Mar 27, 2018
1 parent 5d8ff05 commit 5416e64
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion engines/bladerunner/aud_stream.cpp
Expand Up @@ -133,7 +133,12 @@ int AudStream::getLength() const {
if (_flags & 2) { // stereo
bytesPerSecond *= 2;
}
return (1000 * _sizeDecompressed) / bytesPerSecond;

// since everything is 44100, we easily get overflows with ints
// thus we must use doubles
double res = (double)_sizeDecompressed * 1000.0 / (double)bytesPerSecond;

return (int32)res;
}

} // End of namespace BladeRunner

0 comments on commit 5416e64

Please sign in to comment.