UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
s_main.cpp File Reference

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

#include "../client.h"
#include "s_main.h"
#include "s_local.h"
#include "s_music.h"
#include "s_sample.h"
#include "s_mix.h"
#include "s_mumble.h"

Go to the source code of this file.

Macros

#define COMPARE_VERSION(major, minor, micro)
 

Functions

static void S_Restart_f (void)
 Restart the sound subsystem so it can pick up new parameters and flush all sounds. More...
 
void S_Stop (void)
 Stop all channels. More...
 
void S_Frame (void)
 
static void S_Play_f (void)
 Plays sound fx files via console. More...
 
static int S_CompleteSounds (const char *partial, const char **match)
 
void S_Init (void)
 
void S_Shutdown (void)
 
bool S_LoadAndPlaySample (const char *s, const vec3_t origin, float attenuation, float volume)
 does what the name implies in just one function to avoid exposing s_sample_t More...
 
void S_PlayStdSample (const stdsound_t sId, const vec3_t origin, float attenuation, float volume)
 plays one of the precached samples More...
 
s_sample_tS_LoadSample (const char *soundFile)
 Loads and registers a sound file for later use. More...
 
void S_SetSampleRepeatRate (int sampleRepeatRate)
 Controls the repeat rate for the same sample. More...
 
void S_LoadSamples (void)
 Wrapper for S_PrecacheSamples to avoid exposing it via s_sample.h. More...
 

Variables

s_env_t s_env
 
cvar_tsnd_volume
 
cvar_tsnd_distance_scale
 
static cvar_tsnd_init
 
static cvar_tsnd_rate
 
static cvar_tsnd_chunkbufsize
 
memPool_tcl_soundSysPool
 
s_sample_tstdSoundPool [MAX_SOUNDIDS]
 

Detailed Description

Main control for any streaming sound output device.

Definition in file s_main.cpp.

Macro Definition Documentation

#define COMPARE_VERSION (   major,
  minor,
  micro 
)
Value:
(SDL_MIXER_MAJOR_VERSION > (major) || \
(SDL_MIXER_MAJOR_VERSION == (major) && SDL_MIXER_MINOR_VERSION > (minor)) || \
(SDL_MIXER_MAJOR_VERSION == (major) && SDL_MIXER_MINOR_VERSION == (minor) && \
SDL_MIXER_PATCHLEVEL >= (micro)))

Definition at line 34 of file s_main.cpp.

Function Documentation

static int S_CompleteSounds ( const char *  partial,
const char **  match 
)
static
bool S_LoadAndPlaySample ( const char *  s,
const vec3_t  origin,
float  attenuation,
float  volume 
)

does what the name implies in just one function to avoid exposing s_sample_t

Parameters
sname of the sample
originwhere to play it
attenuationhow to reduce volume by distance
volumewell, the volume

Definition at line 314 of file s_main.cpp.

References Q_strnull(), S_LoadSample(), and S_PlaySample().

Referenced by CL_ActorDoShoot(), CL_ActorDoThrow(), CL_ActorPlaySound(), CL_ActorShootHidden(), CL_Explode(), CL_InvReload(), CL_SoundEvent(), LE_AddProjectile(), LE_PlayFootStepSound(), LE_PlaySoundFileAndParticleForSurface(), and LET_Projectile().

s_sample_t* S_LoadSample ( const char *  soundFile)

Loads and registers a sound file for later use.

Parameters
[in]soundFileThe name of the soundfile, relative to the sounds dir

Definition at line 342 of file s_main.cpp.

References S_GetSample(), and S_LoadSampleIdx().

Referenced by S_LoadAndPlaySample(), S_PrecacheSamples(), and S_StartLocalSample().

void S_LoadSamples ( void  )

Wrapper for S_PrecacheSamples to avoid exposing it via s_sample.h.

Definition at line 359 of file s_main.cpp.

References S_PrecacheSamples().

Referenced by CL_InitAfter(), and S_Restart_f().

static void S_Play_f ( void  )
static

Plays sound fx files via console.

Definition at line 121 of file s_main.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), i, S_StartLocalSample(), and SND_VOLUME_DEFAULT.

Referenced by S_Init().

void S_PlayStdSample ( const stdsound_t  sId,
const vec3_t  origin,
float  attenuation,
float  volume 
)

plays one of the precached samples

Parameters
sIdID of the sample
originwhere to play it
attenuationhow to reduce volume by distance
volumewell, the volume

Definition at line 333 of file s_main.cpp.

References S_PlaySample().

Referenced by LE_PlaySoundFileForContents().

static void S_Restart_f ( void  )
static

Restart the sound subsystem so it can pick up new parameters and flush all sounds.

See also
S_Shutdown
S_Init

Definition at line 140 of file s_main.cpp.

References Com_Printf(), S_Init(), S_LoadSamples(), and S_Shutdown().

Referenced by S_Frame(), and S_Init().

void S_SetSampleRepeatRate ( int  sampleRepeatRate)

Controls the repeat rate for the same sample.

Parameters
[in]sampleRepeatRatemilliseconds that must have passed to play the same sample again

Definition at line 352 of file s_main.cpp.

References s_env_s::sampleRepeatRate.

Referenced by GAME_GetImportData().

void S_Shutdown ( void  )
void S_Stop ( void  )

Stop all channels.

Definition at line 58 of file s_main.cpp.

References s_env_s::channels, s_env_s::initialized, OBJZERO, and S_MumbleUnlink().

Referenced by CL_Disconnect(), and S_Shutdown().

Variable Documentation

memPool_t* cl_soundSysPool

Definition at line 48 of file s_main.cpp.

Referenced by S_LoadSampleIdx().

cvar_t* snd_chunkbufsize
static

Definition at line 46 of file s_main.cpp.

cvar_t* snd_distance_scale

Definition at line 43 of file s_main.cpp.

Referenced by S_SpatializeChannel().

cvar_t* snd_init
static

Definition at line 44 of file s_main.cpp.

cvar_t* snd_rate
static

Definition at line 45 of file s_main.cpp.

cvar_t* snd_volume

Definition at line 42 of file s_main.cpp.

Referenced by S_LoopSample(), and S_PlaySample().

s_sample_t* stdSoundPool[MAX_SOUNDIDS]

this pool is reloaded on every sound system restart

Definition at line 40 of file s_sample.cpp.