[Scummvm-cvs-logs] CVS: scummvm/backends/midi emumidi.h,1.2,1.3
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Tue Oct 19 01:48:04 CEST 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2 function.cpp,1.67,1.68
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.312,2.313 script_v100he.cpp,2.25,2.26 script_v2.cpp,2.253,2.254 script_v5.cpp,1.266,1.267 script_v6.cpp,1.417,1.418 script_v6he.cpp,2.138,2.139 script_v72he.cpp,2.181,2.182 script_v7he.cpp,2.117,2.118 script_v8.cpp,2.277,2.278 script_v80he.cpp,2.62,2.63 script_v90he.cpp,2.105,2.106
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/backends/midi
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28357
Modified Files:
emumidi.h
Log Message:
Made the calculation of _samples_per_tick a bit less prone to arithmetic
overflow. It failed if the output rate was 44100 Hz. (It didn't use to, but
somewhere along the line an unsigned value was changed to a signed. This
seemed like a better fix, though.)
Index: emumidi.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/midi/emumidi.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- emumidi.h 17 Oct 2004 19:34:43 -0000 1.2
+++ emumidi.h 19 Oct 2004 08:47:10 -0000 1.3
@@ -54,7 +54,14 @@
int open() {
_isOpen = true;
- _samples_per_tick = (getRate() << FIXP_SHIFT) / BASE_FREQ;
+
+ int d = getRate() / BASE_FREQ;
+ int r = getRate() % BASE_FREQ;
+
+ // This is equivalent to (getRate() << FIXP_SHIFT) / BASE_FREQ
+ // but less prone to arithmetic overflow.
+
+ _samples_per_tick = (d << FIXP_SHIFT) + (r << FIXP_SHIFT) / BASE_FREQ;
return 0;
}
@@ -71,11 +78,12 @@
const int stereoFactor = isStereo() ? 2 : 1;
int len = numSamples / stereoFactor;
int step;
-
+
do {
step = len;
if (step > (_next_tick >> FIXP_SHIFT))
step = (_next_tick >> FIXP_SHIFT);
+
generate_samples(data, step);
_next_tick -= step << FIXP_SHIFT;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2 function.cpp,1.67,1.68
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.312,2.313 script_v100he.cpp,2.25,2.26 script_v2.cpp,2.253,2.254 script_v5.cpp,1.266,1.267 script_v6.cpp,1.417,1.418 script_v6he.cpp,2.138,2.139 script_v72he.cpp,2.181,2.182 script_v7he.cpp,2.117,2.118 script_v8.cpp,2.277,2.278 script_v80he.cpp,2.62,2.63 script_v90he.cpp,2.105,2.106
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list