mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-03 06:20:57 +00:00
renamed the global channels to snd_channels. removed the global variable
sound_nominal_clip_dist and made it into a macro in snd_dma.c. snd_dma.c: general whitespace and formatting cleanup. (S_StaticSound): Explicitly cast vol to int when assigning it to ss->master_vol. (S_UpdateAmbientSounds): changed the type of vol from float to int. used int casts in its calculations. added explicit int casts when assigning values to chan->master_vol. (S_Update_): added explicit unsigned int casts in endtime calculations. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@181 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
80a3a0df30
commit
5658a9e28d
3 changed files with 101 additions and 101 deletions
|
@ -34,20 +34,21 @@ void S_StopAllSoundsC(void);
|
|||
// Internal sound data & structures
|
||||
// =======================================================================
|
||||
|
||||
channel_t channels[MAX_CHANNELS];
|
||||
channel_t snd_channels[MAX_CHANNELS];
|
||||
int total_channels;
|
||||
|
||||
int snd_blocked = 0;
|
||||
qboolean snd_initialized = false;
|
||||
|
||||
volatile dma_t *shm = NULL;
|
||||
volatile dma_t sn;
|
||||
volatile dma_t *shm = NULL;
|
||||
|
||||
vec3_t listener_origin;
|
||||
vec3_t listener_forward;
|
||||
vec3_t listener_right;
|
||||
vec3_t listener_up;
|
||||
vec_t sound_nominal_clip_dist=1000.0;
|
||||
|
||||
#define sound_nominal_clip_dist 1000.0
|
||||
|
||||
int soundtime; // sample PAIRS
|
||||
int paintedtime; // sample PAIRS
|
||||
|
@ -99,7 +100,6 @@ void S_SoundInfo_f(void)
|
|||
S_Startup
|
||||
================
|
||||
*/
|
||||
|
||||
void S_Startup (void)
|
||||
{
|
||||
if (!snd_initialized)
|
||||
|
@ -194,7 +194,6 @@ void S_Init (void)
|
|||
// =======================================================================
|
||||
// Shutdown sound engine
|
||||
// =======================================================================
|
||||
|
||||
void S_Shutdown (void)
|
||||
{
|
||||
if (!sound_started)
|
||||
|
@ -297,6 +296,8 @@ sfx_t *S_PrecacheSound (char *name)
|
|||
/*
|
||||
=================
|
||||
SND_PickChannel
|
||||
|
||||
picks a channel based on priorities, empty slots, number of channels
|
||||
=================
|
||||
*/
|
||||
channel_t *SND_PickChannel (int entnum, int entchannel)
|
||||
|
@ -311,20 +312,20 @@ channel_t *SND_PickChannel(int entnum, int entchannel)
|
|||
for (ch_idx = NUM_AMBIENTS; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS; ch_idx++)
|
||||
{
|
||||
if (entchannel != 0 // channel 0 never overrides
|
||||
&& channels[ch_idx].entnum == entnum
|
||||
&& (channels[ch_idx].entchannel == entchannel || entchannel == -1) )
|
||||
{ // allways override sound from same entity
|
||||
&& snd_channels[ch_idx].entnum == entnum
|
||||
&& (snd_channels[ch_idx].entchannel == entchannel || entchannel == -1) )
|
||||
{ // always override sound from same entity
|
||||
first_to_die = ch_idx;
|
||||
break;
|
||||
}
|
||||
|
||||
// don't let monster sounds override player sounds
|
||||
if (channels[ch_idx].entnum == cl.viewentity && entnum != cl.viewentity && channels[ch_idx].sfx)
|
||||
if (snd_channels[ch_idx].entnum == cl.viewentity && entnum != cl.viewentity && snd_channels[ch_idx].sfx)
|
||||
continue;
|
||||
|
||||
if (channels[ch_idx].end - paintedtime < life_left)
|
||||
if (snd_channels[ch_idx].end - paintedtime < life_left)
|
||||
{
|
||||
life_left = channels[ch_idx].end - paintedtime;
|
||||
life_left = snd_channels[ch_idx].end - paintedtime;
|
||||
first_to_die = ch_idx;
|
||||
}
|
||||
}
|
||||
|
@ -332,15 +333,17 @@ channel_t *SND_PickChannel(int entnum, int entchannel)
|
|||
if (first_to_die == -1)
|
||||
return NULL;
|
||||
|
||||
if (channels[first_to_die].sfx)
|
||||
channels[first_to_die].sfx = NULL;
|
||||
if (snd_channels[first_to_die].sfx)
|
||||
snd_channels[first_to_die].sfx = NULL;
|
||||
|
||||
return &channels[first_to_die];
|
||||
return &snd_channels[first_to_die];
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
SND_Spatialize
|
||||
|
||||
spatializes a channel
|
||||
=================
|
||||
*/
|
||||
void SND_Spatialize (channel_t *ch)
|
||||
|
@ -438,7 +441,7 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
|
|||
|
||||
// if an identical sound has also been started this frame, offset the pos
|
||||
// a bit to keep it from just making the first one louder
|
||||
check = &channels[NUM_AMBIENTS];
|
||||
check = &snd_channels[NUM_AMBIENTS];
|
||||
for (ch_idx = NUM_AMBIENTS; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS; ch_idx++, check++)
|
||||
{
|
||||
if (check == target_chan)
|
||||
|
@ -461,11 +464,11 @@ void S_StopSound(int entnum, int entchannel)
|
|||
|
||||
for (i = 0; i < MAX_DYNAMIC_CHANNELS; i++)
|
||||
{
|
||||
if (channels[i].entnum == entnum
|
||||
&& channels[i].entchannel == entchannel)
|
||||
if (snd_channels[i].entnum == entnum
|
||||
&& snd_channels[i].entchannel == entchannel)
|
||||
{
|
||||
channels[i].end = 0;
|
||||
channels[i].sfx = NULL;
|
||||
snd_channels[i].end = 0;
|
||||
snd_channels[i].sfx = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -482,11 +485,11 @@ void S_StopAllSounds(qboolean clear)
|
|||
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
if (channels[i].sfx)
|
||||
channels[i].sfx = NULL;
|
||||
if (snd_channels[i].sfx)
|
||||
snd_channels[i].sfx = NULL;
|
||||
}
|
||||
|
||||
memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
|
||||
memset(snd_channels, 0, MAX_CHANNELS * sizeof(channel_t));
|
||||
|
||||
if (clear)
|
||||
S_ClearBuffer ();
|
||||
|
@ -538,7 +541,7 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
|
|||
return;
|
||||
}
|
||||
|
||||
ss = &channels[total_channels];
|
||||
ss = &snd_channels[total_channels];
|
||||
total_channels++;
|
||||
|
||||
sc = S_LoadSound (sfx);
|
||||
|
@ -553,7 +556,7 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
|
|||
|
||||
ss->sfx = sfx;
|
||||
VectorCopy (origin, ss->origin);
|
||||
ss->master_vol = vol;
|
||||
ss->master_vol = (int)vol;
|
||||
ss->dist_mult = (attenuation / 64) / sound_nominal_clip_dist;
|
||||
ss->end = paintedtime + sc->length;
|
||||
|
||||
|
@ -571,8 +574,7 @@ S_UpdateAmbientSounds
|
|||
void S_UpdateAmbientSounds (void)
|
||||
{
|
||||
mleaf_t *l;
|
||||
float vol;
|
||||
int ambient_channel;
|
||||
int vol, ambient_channel;
|
||||
channel_t *chan;
|
||||
|
||||
//johnfitz -- no ambients when disconnected
|
||||
|
@ -588,29 +590,29 @@ void S_UpdateAmbientSounds (void)
|
|||
if (!l || !ambient_level.value)
|
||||
{
|
||||
for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++)
|
||||
channels[ambient_channel].sfx = NULL;
|
||||
snd_channels[ambient_channel].sfx = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++)
|
||||
{
|
||||
chan = &channels[ambient_channel];
|
||||
chan = &snd_channels[ambient_channel];
|
||||
chan->sfx = ambient_sfx[ambient_channel];
|
||||
|
||||
vol = ambient_level.value * l->ambient_sound_level[ambient_channel];
|
||||
vol = (int) (ambient_level.value * l->ambient_sound_level[ambient_channel]);
|
||||
if (vol < 8)
|
||||
vol = 0;
|
||||
|
||||
// don't adjust volume too fast
|
||||
if (chan->master_vol < vol)
|
||||
{
|
||||
chan->master_vol += host_frametime * ambient_fade.value;
|
||||
chan->master_vol += (int) (host_frametime * ambient_fade.value);
|
||||
if (chan->master_vol > vol)
|
||||
chan->master_vol = vol;
|
||||
}
|
||||
else if (chan->master_vol > vol)
|
||||
{
|
||||
chan->master_vol -= host_frametime * ambient_fade.value;
|
||||
chan->master_vol -= (int) (host_frametime * ambient_fade.value);
|
||||
if (chan->master_vol < vol)
|
||||
chan->master_vol = vol;
|
||||
}
|
||||
|
@ -648,7 +650,7 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
|
|||
combine = NULL;
|
||||
|
||||
// update spatialization for static and dynamic sounds
|
||||
ch = channels+NUM_AMBIENTS;
|
||||
ch = snd_channels + NUM_AMBIENTS;
|
||||
for (i = NUM_AMBIENTS; i < total_channels; i++, ch++)
|
||||
{
|
||||
if (!ch->sfx)
|
||||
|
@ -671,7 +673,7 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
|
|||
continue;
|
||||
}
|
||||
// search for one
|
||||
combine = channels+MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS;
|
||||
combine = snd_channels + MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS;
|
||||
for (j = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; j < i; j++, combine++)
|
||||
{
|
||||
if (combine->sfx == ch->sfx)
|
||||
|
@ -701,7 +703,7 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
|
|||
if (snd_show.value)
|
||||
{
|
||||
total = 0;
|
||||
ch = channels;
|
||||
ch = snd_channels;
|
||||
for (i = 0; i < total_channels; i++, ch++)
|
||||
{
|
||||
if (ch->sfx && (ch->leftvol || ch->rightvol) )
|
||||
|
@ -784,10 +786,9 @@ void S_Update_(void)
|
|||
}
|
||||
|
||||
// mix ahead of current position
|
||||
endtime = soundtime + _snd_mixahead.value * shm->speed;
|
||||
endtime = soundtime + (unsigned int)(_snd_mixahead.value * shm->speed);
|
||||
samps = shm->samples >> (shm->channels - 1);
|
||||
if (endtime - soundtime > samps)
|
||||
endtime = soundtime + samps;
|
||||
endtime = min(endtime, (unsigned int)(soundtime + samps));
|
||||
|
||||
S_PaintChannels (endtime);
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ void S_PaintChannels (int endtime)
|
|||
memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t));
|
||||
|
||||
// paint in the channels.
|
||||
ch = channels;
|
||||
ch = snd_channels;
|
||||
for (i = 0; i < total_channels; i++, ch++)
|
||||
{
|
||||
if (!ch->sfx)
|
||||
|
|
|
@ -148,7 +148,7 @@ void SNDDMA_UnblockSound(void);
|
|||
#define MAX_DYNAMIC_CHANNELS 128 //johnfitz -- was 8
|
||||
|
||||
|
||||
extern channel_t channels[MAX_CHANNELS];
|
||||
extern channel_t snd_channels[MAX_CHANNELS];
|
||||
// 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds
|
||||
// MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc
|
||||
// MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds
|
||||
|
@ -170,7 +170,6 @@ extern vec3_t listener_right;
|
|||
extern vec3_t listener_up;
|
||||
extern volatile dma_t *shm;
|
||||
extern volatile dma_t sn;
|
||||
extern vec_t sound_nominal_clip_dist;
|
||||
|
||||
extern cvar_t loadas8bit;
|
||||
extern cvar_t bgmvolume;
|
||||
|
|
Loading…
Reference in a new issue