Fix overflow in sound mixing.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5612 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2020-01-23 18:57:48 +00:00
parent a3d6a3fdec
commit 08547509e3

View file

@ -550,12 +550,12 @@ static void SND_PaintChannel16_O2I1 (channel_t *ch, sfxcache_t *sc, int starttim
if (rate != (1<<PITCHSHIFT)) if (rate != (1<<PITCHSHIFT))
{ {
signed short data; signed int data;
sfx = (signed short *)sc->data; sfx = (signed short *)sc->data;
for (i=0 ; i<count ; i++) for (i=0 ; i<count ; i++)
{ {
int frac = pos&((1<<PITCHSHIFT)-1); int frac = pos&((1<<PITCHSHIFT)-1);
data = sfx[pos>>PITCHSHIFT] * ((1<<PITCHSHIFT)-1-frac) + sfx[(pos>>PITCHSHIFT)+1] * frac; data = sfx[pos>>PITCHSHIFT] * ((1<<PITCHSHIFT)-frac) + sfx[(pos>>PITCHSHIFT)+1] * frac;
pos += rate; pos += rate;
paintbuffer[starttime+i].s[0] += (leftvol * data)>>(PITCHSHIFT+8); paintbuffer[starttime+i].s[0] += (leftvol * data)>>(PITCHSHIFT+8);
paintbuffer[starttime+i].s[1] += (rightvol * data)>>(PITCHSHIFT+8); paintbuffer[starttime+i].s[1] += (rightvol * data)>>(PITCHSHIFT+8);