diff --git a/src/client/sound/header/sound.h b/src/client/sound/header/sound.h index 9ad79b38..7de3d5ef 100644 --- a/src/client/sound/header/sound.h +++ b/src/client/sound/header/sound.h @@ -33,7 +33,7 @@ struct sfx_s; void S_Init(void); void S_Shutdown(void); -/* if origin is NULL, the sound will be +/* if origin is NULL, the sound will be dynamically sourced from the entity */ void S_StartSound(vec3_t origin, int entnum, int entchannel, struct sfx_s *sfx, float fvol, float attenuation, @@ -48,10 +48,9 @@ void S_Activate(qboolean active); void S_BeginRegistration(void); struct sfx_s *S_RegisterSound(char *sample); void S_EndRegistration(void); -struct sfx_s *S_FindName(char *name, qboolean create); /* the sound code makes callbacks to the client for - entitiy position information, so entities can be + entitiy position information, so entities can be dynamically re-spatialized */ void CL_GetEntitySoundOrigin(int ent, vec3_t org); void CL_GetEntitySoundVelocity(int ent, vec3_t vel); diff --git a/src/client/sound/openal.c b/src/client/sound/openal.c index 3347d745..527fe2cc 100644 --- a/src/client/sound/openal.c +++ b/src/client/sound/openal.c @@ -54,7 +54,7 @@ /* Globals */ int active_buffers; -qboolean streamPlaying; +static qboolean streamPlaying; static ALuint s_srcnums[MAX_CHANNELS - 1]; static ALuint streamSource; static int s_framecount; @@ -236,7 +236,7 @@ static void AL_Spatialize(channel_t *ch) { vec3_t origin; - vec3_t velocity; + vec3_t velocity; if ((ch->entnum == -1) || (ch->entnum == cl.playernum + 1) || !ch->dist_mult) { @@ -265,8 +265,6 @@ AL_Spatialize(channel_t *ch) return; } - - } /* @@ -548,7 +546,7 @@ AL_RawSamples(int samples, int rate, int width, int channels, (samples * width * channels), rate); active_buffers++; - /* set volume */ + /* set volume */ if (volume > 1.0f) { volume = 1.0f; @@ -574,47 +572,54 @@ AL_UnqueueRawSamples() AL_StreamDie(); } -void oal_update_underwater() +static void +AL_UpdateUnderwater() { - int i; - float gain_hf; - qboolean update = false; - ALuint filter; + int i; + float gain_hf; + qboolean update = false; + ALuint filter; - if (underwaterFilter == 0) - return; + if (underwaterFilter == 0) { + return; + } - if (s_underwater->modified) { - update = true; - s_underwater->modified = false; - snd_is_underwater_enabled = ((int)s_underwater->value != 0); - } + if (s_underwater->modified) { + update = true; + s_underwater->modified = false; + snd_is_underwater_enabled = ((int)s_underwater->value != 0); + } - if (s_underwater_gain_hf->modified) { - update = true; - s_underwater_gain_hf->modified = false; - } + if (s_underwater_gain_hf->modified) { + update = true; + s_underwater_gain_hf->modified = false; + } - if (!update) - return; + if (!update) { + return; + } - gain_hf = s_underwater_gain_hf->value; + gain_hf = s_underwater_gain_hf->value; - if (gain_hf < AL_LOWPASS_MIN_GAINHF) - gain_hf = AL_LOWPASS_MIN_GAINHF; + if (gain_hf < AL_LOWPASS_MIN_GAINHF) { + gain_hf = AL_LOWPASS_MIN_GAINHF; + } - if (gain_hf > AL_LOWPASS_MAX_GAINHF) - gain_hf = AL_LOWPASS_MAX_GAINHF; + if (gain_hf > AL_LOWPASS_MAX_GAINHF) { + gain_hf = AL_LOWPASS_MAX_GAINHF; + } - qalFilterf(underwaterFilter, AL_LOWPASS_GAINHF, gain_hf); + qalFilterf(underwaterFilter, AL_LOWPASS_GAINHF, gain_hf); - if (snd_is_underwater_enabled && snd_is_underwater) - filter = underwaterFilter; - else - filter = 0; + if (snd_is_underwater_enabled && snd_is_underwater) { + filter = underwaterFilter; + } else { + filter = 0; + } - for (i = 0; i < s_numchannels; ++i) - qalSourcei(s_srcnums[i], AL_DIRECT_FILTER, filter); + for (i = 0; i < s_numchannels; ++i) { + qalSourcei(s_srcnums[i], AL_DIRECT_FILTER, filter); + } } /* @@ -637,7 +642,7 @@ AL_Update(void) Otherwise sound and game will become asynchronous and the paint buffer may overflow. */ if (!QAL_RecoverLostDevice()) { - return; + return; } /* set listener (player) parameters */ @@ -706,7 +711,7 @@ AL_Update(void) AL_StreamUpdate(); AL_IssuePlaysounds(); - oal_update_underwater(); + AL_UpdateUnderwater(); } /* ----------------------------------------------------------------- */ @@ -803,10 +808,10 @@ AL_InitUnderwaterFilter() return; } - qalFilterf(underwaterFilter, AL_LOWPASS_GAIN, AL_LOWPASS_DEFAULT_GAIN); + qalFilterf(underwaterFilter, AL_LOWPASS_GAIN, AL_LOWPASS_DEFAULT_GAIN); - s_underwater->modified = true; - s_underwater_gain_hf->modified = true; + s_underwater->modified = true; + s_underwater_gain_hf->modified = true; } /* diff --git a/src/client/sound/qal.c b/src/client/sound/qal.c index 914aa50b..6a6cc737 100644 --- a/src/client/sound/qal.c +++ b/src/client/sound/qal.c @@ -156,10 +156,10 @@ LPALDELETEFILTERS qalDeleteFilters; void QAL_SoundInfo() { Com_Printf("OpenAL settings:\n"); - Com_Printf("AL_VENDOR: %s\n", qalGetString(AL_VENDOR)); - Com_Printf("AL_RENDERER: %s\n", qalGetString(AL_RENDERER)); - Com_Printf("AL_VERSION: %s\n", qalGetString(AL_VERSION)); - Com_Printf("AL_EXTENSIONS: %s\n", qalGetString(AL_EXTENSIONS)); + Com_Printf("AL_VENDOR: %s\n", qalGetString(AL_VENDOR)); + Com_Printf("AL_RENDERER: %s\n", qalGetString(AL_RENDERER)); + Com_Printf("AL_VERSION: %s\n", qalGetString(AL_VERSION)); + Com_Printf("AL_EXTENSIONS: %s\n", qalGetString(AL_EXTENSIONS)); if (qalcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT")) { @@ -262,18 +262,18 @@ QAL_RecoverLostDevice() void QAL_Shutdown() { - if (context) - { - qalcMakeContextCurrent( NULL ); - qalcDestroyContext( context ); - context = NULL; - } + if (context) + { + qalcMakeContextCurrent( NULL ); + qalcDestroyContext( context ); + context = NULL; + } if (device) { - qalcCloseDevice( device ); - device = NULL; - } + qalcCloseDevice( device ); + device = NULL; + } /* Disconnect function pointers used for OpenAL management calls */ @@ -510,7 +510,7 @@ QAL_Init() qalDistanceModel = ALSYMBOL(handle, alDistanceModel); /* Open the OpenAL device */ - Com_Printf("...opening OpenAL device: "); + Com_Printf("...opening OpenAL device: "); device = qalcOpenDevice(al_device->string[0] ? al_device->string : NULL); @@ -547,17 +547,17 @@ QAL_Init() return false; } - if (qalcIsExtensionPresent(device, "ALC_EXT_EFX") != AL_FALSE) { - qalGenFilters = qalGetProcAddress("alGenFilters"); - qalFilteri = qalGetProcAddress("alFilteri"); - qalFilterf = qalGetProcAddress("alFilterf"); - qalDeleteFilters = qalGetProcAddress("alDeleteFilters"); - } else { - qalGenFilters = NULL; - qalFilteri = NULL; - qalFilterf = NULL; - qalDeleteFilters = NULL; - } + if (qalcIsExtensionPresent(device, "ALC_EXT_EFX") != AL_FALSE) { + qalGenFilters = qalGetProcAddress("alGenFilters"); + qalFilteri = qalGetProcAddress("alFilteri"); + qalFilterf = qalGetProcAddress("alFilterf"); + qalDeleteFilters = qalGetProcAddress("alDeleteFilters"); + } else { + qalGenFilters = NULL; + qalFilteri = NULL; + qalFilterf = NULL; + qalDeleteFilters = NULL; + } Com_Printf("ok\n"); diff --git a/src/client/sound/sdl.c b/src/client/sound/sdl.c index 41c8f0e2..fafa0614 100644 --- a/src/client/sound/sdl.c +++ b/src/client/sound/sdl.c @@ -46,8 +46,8 @@ #define SDL_LOOPATTENUATE 0.003 /* Globals */ -cvar_t *s_sdldriver; -int *snd_p; +static cvar_t *s_sdldriver; +static int *snd_p; static sound_t *backend; static portable_samplepair_t paintbuffer[SDL_PAINTBUFFER_SIZE]; static int beginofs; @@ -73,7 +73,8 @@ static const float lpf_default_gain_hf = 0.25F; static LpfContext lpf_context; static qboolean lpf_is_enabled; -static void lpf_initialize(LpfContext* lpf_context, float gain_hf, int target_frequency) +static void +lpf_initialize(LpfContext* lpf_context, float gain_hf, int target_frequency) { assert(target_frequency > 0); assert(lpf_context); @@ -110,7 +111,8 @@ static void lpf_initialize(LpfContext* lpf_context, float gain_hf, int target_fr lpf_context->is_history_initialized = false; } -static void lpf_update_samples(LpfContext* lpf_context,int sample_count, portable_samplepair_t* samples) +static void +lpf_update_samples(LpfContext* lpf_context,int sample_count, portable_samplepair_t* samples) { assert(lpf_context); assert(sample_count >= 0); @@ -171,7 +173,7 @@ static void lpf_update_samples(LpfContext* lpf_context,int sample_count, portabl * the SDL output buffer and places it * at the appropriate position. */ -void +static void SDL_TransferPaintBuffer(int endtime) { int i; @@ -322,7 +324,7 @@ SDL_TransferPaintBuffer(int endtime) /* * Mixes an 8 bit sample into a channel. */ -void +static void SDL_PaintChannelFrom8(channel_t *ch, sfxcache_t *sc, int count, int offset) { int data; @@ -360,7 +362,7 @@ SDL_PaintChannelFrom8(channel_t *ch, sfxcache_t *sc, int count, int offset) /* * Mixes an 16 bit sample into a channel */ -void +static void SDL_PaintChannelFrom16(channel_t *ch, sfxcache_t *sc, int count, int offset) { int data; @@ -392,7 +394,7 @@ SDL_PaintChannelFrom16(channel_t *ch, sfxcache_t *sc, int count, int offset) * Mixes all pending sounds into * the available output channels. */ -void +static void SDL_PaintChannels(int endtime) { int i; @@ -512,10 +514,14 @@ SDL_PaintChannels(int endtime) } } - if (lpf_is_enabled && snd_is_underwater) - lpf_update_samples(&lpf_context, end - paintedtime, paintbuffer); - else - lpf_context.is_history_initialized = false; + if (lpf_is_enabled && snd_is_underwater) + { + lpf_update_samples(&lpf_context, end - paintedtime, paintbuffer); + } + else + { + lpf_context.is_history_initialized = false; + } if (s_rawend >= paintedtime) { @@ -529,7 +535,7 @@ SDL_PaintChannels(int endtime) { s = i & (MAX_RAW_SAMPLES - 1); paintbuffer[i - paintedtime].left += s_rawsamples[s].left; - paintbuffer[i - paintedtime].right += s_rawsamples[s].right; + paintbuffer[i - paintedtime].right += s_rawsamples[s].right; } } @@ -571,7 +577,7 @@ SDL_DriftBeginofs(float timeofs) /* * Spatialize a sound effect based on it's origin. */ -void +static void SDL_SpatializeOrigin(vec3_t origin, float master_vol, float dist_mult, int *left_vol, int *right_vol) { vec_t dot; @@ -829,7 +835,7 @@ SDL_ClearBuffer(void) * Calculates the absolute timecode * of current playback. */ -void +static void SDL_UpdateSoundtime(void) { static int buffers; @@ -861,7 +867,7 @@ SDL_UpdateSoundtime(void) * Updates the volume scale table * based on current volume setting. */ -void +static void SDL_UpdateScaletable(void) { int i, j; @@ -906,7 +912,7 @@ SDL_Cache(sfx_t *sfx, wavinfo_t *info, byte *data) unsigned int samplefrac = 0; stepscale = (float)info->rate / sound.speed; - len = (int)(info->samples / stepscale); + len = (int)(info->samples / stepscale); if ((info->samples == 0) || (len == 0)) { @@ -1087,17 +1093,18 @@ SDL_Update(void) int total; unsigned int endtime; - if (s_underwater->modified) { - s_underwater->modified = false; - lpf_is_enabled = ((int)s_underwater->value != 0); - } + if (s_underwater->modified) { + s_underwater->modified = false; + lpf_is_enabled = ((int)s_underwater->value != 0); + } - if (s_underwater_gain_hf->modified) { - s_underwater_gain_hf->modified = false; + if (s_underwater_gain_hf->modified) { + s_underwater_gain_hf->modified = false; - lpf_initialize( - &lpf_context, s_underwater_gain_hf->value, backend->speed); - } + lpf_initialize( + &lpf_context, s_underwater_gain_hf->value, + backend->speed); + } /* if the loading plaque is up, clear everything out to make sure we aren't looping a dirty @@ -1174,7 +1181,7 @@ SDL_Update(void) return; } - /* Mix the samples */ + /* Mix the samples */ SDL_LockAudio(); /* Updates SDL time */ @@ -1275,7 +1282,7 @@ SDL_Callback(void *data, Uint8 *stream, int length) playpos = (length2 / (backend->samplebits / 8)); } - if (playpos >= samplesize) + if (playpos >= samplesize) { playpos = 0; } @@ -1417,9 +1424,9 @@ SDL_BackendInit(void) backend->buffer = calloc(1, samplesize); s_numchannels = MAX_CHANNELS; - s_underwater->modified = true; - s_underwater_gain_hf->modified = true; - lpf_initialize(&lpf_context, lpf_default_gain_hf, backend->speed); + s_underwater->modified = true; + s_underwater_gain_hf->modified = true; + lpf_initialize(&lpf_context, lpf_default_gain_hf, backend->speed); SDL_UpdateScaletable(); SDL_PauseAudio(0); @@ -1439,13 +1446,13 @@ void SDL_BackendShutdown(void) { Com_Printf("Closing SDL audio device...\n"); - SDL_PauseAudio(1); - SDL_CloseAudio(); - SDL_QuitSubSystem(SDL_INIT_AUDIO); - free(backend->buffer); - backend->buffer = NULL; - playpos = samplesize = 0; - snd_inited = 0; - Com_Printf("SDL audio device shut down.\n"); + SDL_PauseAudio(1); + SDL_CloseAudio(); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + free(backend->buffer); + backend->buffer = NULL; + playpos = samplesize = 0; + snd_inited = 0; + Com_Printf("SDL audio device shut down.\n"); } diff --git a/src/client/sound/sound.c b/src/client/sound/sound.c index f2cac5b7..d4ca4b1a 100644 --- a/src/client/sound/sound.c +++ b/src/client/sound/sound.c @@ -58,8 +58,8 @@ vec3_t listener_forward; vec3_t listener_right; vec3_t listener_up; -playsound_t s_playsounds[MAX_PLAYSOUNDS]; -playsound_t s_freeplays; +static playsound_t s_playsounds[MAX_PLAYSOUNDS]; +static playsound_t s_freeplays; playsound_t s_pendingplays; cvar_t *s_volume; @@ -75,14 +75,13 @@ cvar_t* s_doppler; cvar_t* s_ps_sorting; channel_t channels[MAX_CHANNELS]; -int num_sfx; +static int num_sfx; int paintedtime; int s_numchannels; int s_rawend; -int s_registration_sequence; +static int s_registration_sequence = 0; portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES]; -qboolean snd_initialized = false; -sfx_t known_sfx[MAX_SFX]; +static sfx_t known_sfx[MAX_SFX]; sndstarted_t sound_started = SS_NOT; sound_t sound; static qboolean s_registering; @@ -301,7 +300,7 @@ S_LoadSound(sfx_t *s) /* * Returns the name of a sound */ -sfx_t * +static sfx_t * S_FindName(char *name, qboolean create) { int i; @@ -368,7 +367,7 @@ S_FindName(char *name, qboolean create) * Registers an alias name * for a sound */ -sfx_t * +static sfx_t * S_AliasName(char *aliasname, char *truename) { sfx_t *sfx; @@ -441,7 +440,7 @@ S_RegisterSound(char *name) return sfx; } -struct sfx_s * +static struct sfx_s * S_RegisterSexedSound(entity_state_t *ent, char *base) { int n; @@ -627,7 +626,7 @@ S_PickChannel(int entnum, int entchannel) /* * Picks a free playsound */ -playsound_t * +static playsound_t * S_AllocPlaysound(void) { playsound_t *ps; @@ -651,7 +650,7 @@ S_AllocPlaysound(void) /* * Frees a playsound */ -void +static void S_FreePlaysound(playsound_t *ps) { /* unlink from channel */ @@ -1078,7 +1077,7 @@ S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) * Plays one sample. Called * by the "play" cmd. */ -void +static void S_Play(void) { int i; @@ -1114,7 +1113,7 @@ S_Play(void) /* * List all loaded sounds */ -void +static void S_SoundList(void) { int i; @@ -1169,7 +1168,7 @@ S_SoundList(void) * Prints information about the * active sound backend */ -void +static void S_SoundInfo_f(void) { if (sound_started == SS_NOT) @@ -1217,8 +1216,8 @@ S_Init(void) s_show = Cvar_Get("s_show", "0", 0); s_testsound = Cvar_Get("s_testsound", "0", 0); s_ambient = Cvar_Get("s_ambient", "1", 0); - s_underwater = Cvar_Get("s_underwater", "1", CVAR_ARCHIVE); - s_underwater_gain_hf = Cvar_Get("s_underwater_gain_hf", "0.25", CVAR_ARCHIVE); + s_underwater = Cvar_Get("s_underwater", "1", CVAR_ARCHIVE); + s_underwater_gain_hf = Cvar_Get("s_underwater_gain_hf", "0.25", CVAR_ARCHIVE); s_doppler = Cvar_Get("s_doppler", "0", CVAR_ARCHIVE); s_ps_sorting = Cvar_Get("s_ps_sorting", "1", CVAR_ARCHIVE); diff --git a/src/client/sound/wave.c b/src/client/sound/wave.c index f770e5a5..14fb4124 100644 --- a/src/client/sound/wave.c +++ b/src/client/sound/wave.c @@ -27,13 +27,13 @@ #include "../header/client.h" #include "header/local.h" -byte *data_p; -byte *iff_end; -byte *last_chunk; -byte *iff_data; -int iff_chunk_len; +static byte *data_p; +static byte *iff_end; +static byte *last_chunk; +static byte *iff_data; +static int iff_chunk_len; -short +static short GetLittleShort(void) { short val = 0; @@ -44,7 +44,7 @@ GetLittleShort(void) return val; } -int +static int GetLittleLong(void) { int val = 0; @@ -57,7 +57,7 @@ GetLittleLong(void) return val; } -void +static void FindNextChunk(char *name) { while (1) @@ -89,7 +89,7 @@ FindNextChunk(char *name) } } -void +static void FindChunk(char *name) { last_chunk = iff_data;