MCPcopy Create free account
hub / github.com/JACoders/OpenJK / SND_malloc

Function SND_malloc

code/client/snd_dma.cpp:5043–5060  ·  view source on GitHub ↗

currently passing in sfx as a param in case I want to do something with it later.

Source from the content-addressed store, hash-verified

5041// currently passing in sfx as a param in case I want to do something with it later.
5042//
5043byte *SND_malloc(int iSize, sfx_t *sfx)
5044{
5045 byte *pData = (byte *) Z_Malloc(iSize, TAG_SND_RAWDATA, qfalse); // don't bother asking for zeroed mem
5046
5047 // if "s_soundpoolmegs" is < 0, then the -ve of the value is the maximum amount of sounds we're allowed to have loaded...
5048 //
5049 if (s_soundpoolmegs && s_soundpoolmegs->integer < 0)
5050 {
5051 while ( (Z_MemSize(TAG_SND_RAWDATA) + Z_MemSize(TAG_SND_MP3STREAMHDR)) > ((-s_soundpoolmegs->integer) * 1024 * 1024))
5052 {
5053 int iBytesFreed = SND_FreeOldestSound(sfx);
5054 if (iBytesFreed == 0)
5055 break; // sanity
5056 }
5057 }
5058
5059 return pData;
5060}
5061
5062
5063// called once-only in EXE lifetime...

Callers 3

S_DefaultSoundFunction · 0.70
MP3Stream_InitFromFileFunction · 0.70
ResampleSfxFunction · 0.70

Calls 3

SND_FreeOldestSoundFunction · 0.70
Z_MallocFunction · 0.50
Z_MemSizeFunction · 0.50

Tested by

no test coverage detected