// Remove the least recently used sound effect from memory static bool buffer_evict() { int i; int candinate = -1; int candinate_value = trap_Milliseconds(); for( i = 0; i < MAX_SFX; i++ ) { if( knownSfx[i].filename[0] == '\0' || !knownSfx[i].inMemory || knownSfx[i].isLocked ) continue; if( knownSfx[i].used < candinate_value ) { candinate = i; candinate_value = knownSfx[i].used; } } if( candinate != -1 ) { return S_UnloadBuffer( &knownSfx[candinate] ); } return false; }
void S_ShutdownBuffers( void ) { int i; if( !buffers_inited ) return; for( i = 0; i < MAX_SFX; i++ ) S_UnloadBuffer( &knownSfx[i] ); memset( knownSfx, 0, sizeof( knownSfx ) ); buffers_inited = false; }
/* * S_HandleFreeSfxCmd */ static unsigned S_HandleFreeSfxCmd( const sndCmdFreeSfx_t *cmd ) { //Com_Printf("S_HandleFreeSfxCmd\n"); S_UnloadBuffer( S_GetBufferById( cmd->sfx ) ); return sizeof( *cmd ); }