#include "quakedef.h"
-int cache_full_cycle;
-
byte *S_Alloc (int size);
/*
int samplefrac, fracstep;
sfxcache_t *sc;
- sc = Cache_Check (&sfx->cache);
+ sc = sfx->sfxcache;
if (!sc)
return;
sfxcache_t *sc;
// see if still in memory
- sc = Cache_Check (&s->cache);
- if (sc)
- return sc;
+ if (s->sfxcache)
+ return s->sfxcache;
//Con_Printf ("S_LoadSound: %x\n", (int)stackbuf);
// load it in
// Con_Printf ("loading %s\n",namebuffer);
- data = COM_LoadMallocFile(namebuffer, false);
+ data = COM_LoadFile(namebuffer, false);
if (!data)
{
if (info.channels < 1 || info.channels > 2)
{
Con_Printf ("%s has an unsupported number of channels (%i)\n",s->name, info.channels);
- qfree(data);
+ Mem_Free(data);
return NULL;
}
/*
}
*/
- stepscale = (float)info.rate / shm->speed;
+ stepscale = (float)info.rate / shm->speed;
len = info.samples / stepscale;
len = len * info.width * info.channels;
- sc = Cache_Alloc ( &s->cache, len + sizeof(sfxcache_t), s->name);
+ // FIXME: add S_UnloadSounds or something?
+ Mem_FreePool(&s->mempool);
+ s->mempool = Mem_AllocPool(s->name);
+ sc = s->sfxcache = Mem_Alloc(s->mempool, len + sizeof(sfxcache_t));
if (!sc)
{
- qfree(data);
+ Mem_Free(data);
return NULL;
}
-
+
sc->length = info.samples;
sc->loopstart = info.loopstart;
sc->speed = info.rate;
ResampleSfx (s, sc->speed, data + info.dataofs, s->name);
- qfree(data);
+ Mem_Free(data);
return sc;
}