UFO: Alien Invasion
Loading...
Searching...
No Matches
s_sample.cpp File Reference

Main control for any streaming sound output device. More...

#include "s_sample.h"
#include "s_main.h"
#include "../../common/filesys.h"
#include "../../common/common.h"
Include dependency graph for s_sample.cpp:

Go to the source code of this file.

Macros

#define SAMPLE_HASH_SIZE   64
#define SAMPLE_MAX_COUNT   1000

Functions

static s_sample_t * S_FindByName (const char *name)
 Searches the hash for a given sound file.
static Mix_Chunk * S_LoadSampleChunk (const char *sound)
int S_LoadSampleIdx (const char *soundFile)
 Loads and registers a sound file for later use.
s_sample_t * S_GetSample (const int soundIdx)
void S_FreeSamples (void)
void S_PrecacheSamples (void)

Variables

static s_sample_t * sampleHash [SAMPLE_HASH_SIZE]
static s_sample_t * sampleIndex [SAMPLE_MAX_COUNT]
static int sampleIndexLast = 0
s_sample_t * stdSoundPool [MAX_SOUNDIDS]

Detailed Description

Main control for any streaming sound output device.

Definition in file s_sample.cpp.

Macro Definition Documentation

◆ SAMPLE_HASH_SIZE

#define SAMPLE_HASH_SIZE   64

Definition at line 31 of file s_sample.cpp.

Referenced by S_FindByName(), S_FreeSamples(), and S_LoadSampleIdx().

◆ SAMPLE_MAX_COUNT

#define SAMPLE_MAX_COUNT   1000

Definition at line 35 of file s_sample.cpp.

Function Documentation

◆ S_FindByName()

s_sample_t * S_FindByName ( const char * name)
static

Searches the hash for a given sound file.

Parameters
nameThe soundfile (relative to the sound dir and without extension)
Returns
nullptr if not yet loaded

Definition at line 47 of file s_sample.cpp.

References Com_HashKey(), s_sample_t::hashNext, name, Q_streq, S_FindByName(), SAMPLE_HASH_SIZE, and sampleHash.

Referenced by S_FindByName(), and S_LoadSampleIdx().

◆ S_FreeSamples()

void S_FreeSamples ( void )

◆ S_GetSample()

s_sample_t * S_GetSample ( const int soundIdx)

Definition at line 132 of file s_sample.cpp.

References S_GetSample(), sampleIndex, and sampleIndexLast.

Referenced by S_Frame(), S_GetSample(), and S_LoadSample().

◆ S_LoadSampleChunk()

Mix_Chunk * S_LoadSampleChunk ( const char * sound)
static

◆ S_LoadSampleIdx()

int S_LoadSampleIdx ( const char * soundFile)

Loads and registers a sound file for later use.

Parameters
[in]soundFileThe name of the soundfile, relative to the sounds dir
Returns
The index of the loaded sample or 0
See also
S_LoadSound

Definition at line 105 of file s_sample.cpp.

References s_sample_t::chunk, cl_soundSysPool, Com_HashKey(), Com_StripExtension(), s_sample_t::hashNext, s_sample_t::index, s_env_t::initialized, MAX_QPATH, Mem_PoolAllocType, Mem_PoolStrDup, name, s_sample_t::name, s_env, S_FindByName(), S_LoadSampleChunk(), S_LoadSampleIdx(), SAMPLE_HASH_SIZE, sampleHash, sampleIndex, and sampleIndexLast.

Referenced by LE_AddAmbientSound(), S_LoadSample(), and S_LoadSampleIdx().

◆ S_PrecacheSamples()

void S_PrecacheSamples ( void )

Variable Documentation

◆ sampleHash

s_sample_t* sampleHash[SAMPLE_HASH_SIZE]
static

Definition at line 32 of file s_sample.cpp.

Referenced by S_FindByName(), S_FreeSamples(), and S_LoadSampleIdx().

◆ sampleIndex

s_sample_t* sampleIndex[SAMPLE_MAX_COUNT]
static

Definition at line 36 of file s_sample.cpp.

Referenced by S_FreeSamples(), S_GetSample(), and S_LoadSampleIdx().

◆ sampleIndexLast

int sampleIndexLast = 0
static

Definition at line 37 of file s_sample.cpp.

Referenced by S_GetSample(), and S_LoadSampleIdx().

◆ stdSoundPool

s_sample_t* stdSoundPool[MAX_SOUNDIDS]

this pool is reloaded on every sound system restart

Definition at line 40 of file s_sample.cpp.

Referenced by S_PlayStdSample(), and S_PrecacheSamples().