mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
fix an out-by-one error caused by over-optimisation of floats.
This commit is contained in:
parent
8e254e4071
commit
59dba829f2
1 changed files with 6 additions and 2 deletions
|
@ -56,10 +56,12 @@ SND_GetCache (long samples, int rate, int inwidth, int channels,
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
int width;
|
int width;
|
||||||
|
float stepscale;
|
||||||
sfxcache_t *sc;
|
sfxcache_t *sc;
|
||||||
|
|
||||||
width = snd_loadas8bit->int_val ? 1 : 2;
|
width = snd_loadas8bit->int_val ? 1 : 2;
|
||||||
size = samples / ((float) rate / shm->speed);
|
stepscale = (float) rate / shm->speed; // usually 0.5, 1, or 2
|
||||||
|
size = samples / stepscale;
|
||||||
size *= width * channels;
|
size *= width * channels;
|
||||||
sc = allocator (&sfx->cache, size + sizeof (sfxcache_t), sfx->name);
|
sc = allocator (&sfx->cache, size + sizeof (sfxcache_t), sfx->name);
|
||||||
if (!sc)
|
if (!sc)
|
||||||
|
@ -175,7 +177,9 @@ SND_ResampleSfx (sfxcache_t *sc, byte * data)
|
||||||
if (sc->loopstart != -1)
|
if (sc->loopstart != -1)
|
||||||
sc->loopstart = sc->loopstart / stepscale;
|
sc->loopstart = sc->loopstart / stepscale;
|
||||||
if (memcmp (sc->data + sc->bytes, "\xde\xad\xbe\xef", 4))
|
if (memcmp (sc->data + sc->bytes, "\xde\xad\xbe\xef", 4))
|
||||||
Sys_Error ("SND_ResampleSfx screwed the pooch");
|
Sys_Error ("SND_ResampleSfx screwed the pooch: %02x%02x%02x%02x",
|
||||||
|
sc->data[sc->bytes + 0], sc->data[sc->bytes + 1],
|
||||||
|
sc->data[sc->bytes + 2], sc->data[sc->bytes + 3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sfxcache_t *
|
sfxcache_t *
|
||||||
|
|
Loading…
Reference in a new issue