summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2007-08-03 22:17:15 +0000
committerSimon Howard2007-08-03 22:17:15 +0000
commit770fb3d7c7c23bc9b101ebbf314b142a440f6637 (patch)
tree0fa2baec919e14e7876ddc4bd03112de93270afd /src
parent5f4628dcc6400e64f62ad7c3afaac2046f8b1e9a (diff)
downloadchocolate-doom-770fb3d7c7c23bc9b101ebbf314b142a440f6637.tar.gz
chocolate-doom-770fb3d7c7c23bc9b101ebbf314b142a440f6637.tar.bz2
chocolate-doom-770fb3d7c7c23bc9b101ebbf314b142a440f6637.zip
Fix 'pop' at the end of sound effects caused by an audio conversion bug.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 943
Diffstat (limited to 'src')
-rw-r--r--src/i_sdlsound.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index 8e10a932..70f45470 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -199,12 +199,18 @@ static boolean CacheSFX(int sound)
// If the header specifies that the length of the sound is greater than
// the length of the lump itself, this is an invalid sound lump
- if (length - 8 > lumplen)
+ if (length > lumplen - 8)
{
return false;
}
- expanded_length = (uint32_t) ((((uint64_t) length) * 4 * mixer_freq) / samplerate);
+ // Sample rate conversion
+
+ expanded_length = (uint32_t) ((((uint64_t) length) * mixer_freq) / samplerate);
+
+ // Double up twice: 8 -> 16 bit and mono -> stereo
+
+ expanded_length *= 4;
sound_chunks[sound].allocated = 1;
sound_chunks[sound].alen = expanded_length;
@@ -214,7 +220,7 @@ static boolean CacheSFX(int sound)
ExpandSoundData(data + 8,
samplerate,
- length - 8,
+ length,
&sound_chunks[sound]);
// don't need the original lump any more