mirror of
https://github.com/nzp-team/fteqw.git
synced 2025-01-30 20:20:44 +00:00
Remove MAX_DYNAMIC_CHANNELS limit. We'll just spend even more time mixing audio instead of suffering random cutoffs. Yay.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6122 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
268f122b23
commit
99f20e7b80
4 changed files with 38 additions and 39 deletions
|
@ -3860,7 +3860,7 @@ void Media_InitFakeSoundDevice (int speed, int channels, int samplebits)
|
|||
|
||||
sc->sn.buffer = (unsigned char *) BZ_Malloc(sc->sn.samples*sc->sn.numchannels*sc->sn.samplebytes);
|
||||
|
||||
Z_ReallocElements((void**)&sc->channel, &sc->max_chans, MAX_DYNAMIC_CHANNELS+NUM_AMBIENTS+NUM_MUSICS, sizeof(*sc->channel));
|
||||
Z_ReallocElements((void**)&sc->channel, &sc->max_chans, NUM_AMBIENTS+NUM_MUSICS, sizeof(*sc->channel));
|
||||
|
||||
sc->Lock = MSD_Lock;
|
||||
sc->Unlock = MSD_Unlock;
|
||||
|
|
|
@ -732,20 +732,33 @@ static qboolean OpenAL_ReclaimASource(soundcardinfo_t *sc)
|
|||
|
||||
if (!success)
|
||||
{
|
||||
for (i = DYNAMIC_STOP; i < sc->total_chans; i++)
|
||||
{ //FIXME: prioritize the furthest
|
||||
int furthest=-1;
|
||||
float dist, bdist=-1;
|
||||
vec3_t d;
|
||||
for (i = DYNAMIC_FIRST; i < sc->total_chans; i++)
|
||||
{
|
||||
if (oali->source[i].allocated)
|
||||
{
|
||||
palDeleteSources(1, &oali->source[i].handle);
|
||||
if (oali->source[i].queuesize)
|
||||
palDeleteBuffers(oali->source[i].queuesize, oali->source[i].queue);
|
||||
oali->source[i].queuesize = 0;
|
||||
oali->source[i].handle = 0;
|
||||
oali->source[i].allocated = false;
|
||||
success++;
|
||||
break;
|
||||
VectorSubtract(sc->channel[i].origin, oali->ListenPos, d);
|
||||
dist = DotProduct(d,d);
|
||||
if (dist > bdist)
|
||||
{
|
||||
bdist = dist;
|
||||
furthest = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (furthest >= 0)
|
||||
{
|
||||
i = furthest;
|
||||
palDeleteSources(1, &oali->source[i].handle);
|
||||
if (oali->source[i].queuesize)
|
||||
palDeleteBuffers(oali->source[i].queuesize, oali->source[i].queue);
|
||||
oali->source[i].queuesize = 0;
|
||||
oali->source[i].handle = 0;
|
||||
oali->source[i].allocated = false;
|
||||
success++;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
|
|
|
@ -2014,7 +2014,7 @@ static soundcardinfo_t *SNDDMA_Init(char *driver, char *device, int seat)
|
|||
if (sc->seat == -1 && sc->ListenerUpdate)
|
||||
sc->seat = 0; //hardware rendering won't cope with seat=-1
|
||||
|
||||
Z_ReallocElements((void**)&sc->channel, &sc->max_chans, MAX_DYNAMIC_CHANNELS+NUM_AMBIENTS+NUM_MUSICS, sizeof(*sc->channel));
|
||||
Z_ReallocElements((void**)&sc->channel, &sc->max_chans, NUM_AMBIENTS+NUM_MUSICS, sizeof(*sc->channel));
|
||||
return sc;
|
||||
}
|
||||
}
|
||||
|
@ -2616,13 +2616,11 @@ SND_PickChannel
|
|||
channel_t *SND_PickChannel(soundcardinfo_t *sc, int entnum, int entchannel)
|
||||
{
|
||||
int ch_idx;
|
||||
int oldestpos;
|
||||
int oldest;
|
||||
|
||||
// Check for replacement sound, or find the best one to replace
|
||||
// Check for replacement sound, or an idle channel
|
||||
oldest = -1;
|
||||
oldestpos = -1;
|
||||
for (ch_idx=DYNAMIC_FIRST; ch_idx < DYNAMIC_STOP ; ch_idx++)
|
||||
for (ch_idx=DYNAMIC_FIRST; ch_idx < sc->max_chans ; ch_idx++)
|
||||
{
|
||||
if (entchannel != 0 // channel 0 never overrides
|
||||
&& sc->channel[ch_idx].entnum == entnum
|
||||
|
@ -2632,24 +2630,15 @@ channel_t *SND_PickChannel(soundcardinfo_t *sc, int entnum, int entchannel)
|
|||
break;
|
||||
}
|
||||
|
||||
// don't let monster sounds override player sounds
|
||||
if (sc->seat != -1 && sc->channel[ch_idx].entnum == listener[sc->seat].entnum && entnum != listener[sc->seat].entnum && sc->channel[ch_idx].sfx)
|
||||
continue;
|
||||
|
||||
if (!sc->channel[ch_idx].sfx)
|
||||
{
|
||||
oldestpos = 0x7fffffff;
|
||||
oldest = ch_idx;
|
||||
}
|
||||
else if (sc->channel[ch_idx].pos > oldestpos)
|
||||
{
|
||||
oldestpos = sc->channel[ch_idx].pos;
|
||||
oldest = ch_idx;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldest == -1)
|
||||
return NULL;
|
||||
{
|
||||
oldest = sc->max_chans;
|
||||
Z_ReallocElements((void**)&sc->channel, &sc->max_chans, oldest+1, sizeof(*sc->channel));
|
||||
}
|
||||
|
||||
sc->channel[oldest].sfx = NULL;
|
||||
|
||||
|
@ -2977,7 +2966,7 @@ static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_
|
|||
// 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 = &sc->channel[DYNAMIC_FIRST];
|
||||
for (ch_idx=DYNAMIC_FIRST; ch_idx < DYNAMIC_STOP; ch_idx++, check++)
|
||||
for (ch_idx=DYNAMIC_FIRST; ch_idx < sc->total_chans; ch_idx++, check++)
|
||||
{
|
||||
if (check == target_chan)
|
||||
continue;
|
||||
|
@ -3298,7 +3287,7 @@ void S_StopAllSounds(qboolean clear)
|
|||
}
|
||||
}
|
||||
|
||||
sc->total_chans = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS + NUM_MUSICS; // no statics
|
||||
sc->total_chans = NUM_AMBIENTS + NUM_MUSICS; // no statics
|
||||
Z_ReallocElements((void**)&sc->channel, &sc->max_chans, sc->total_chans, sizeof(*sc->channel));
|
||||
|
||||
memcpy(musics, &sc->channel[MUSIC_FIRST], sizeof(musics));
|
||||
|
@ -3380,7 +3369,7 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
|
|||
ss->master_vol = vol*255;
|
||||
ss->dist_mult = attenuation / snd_nominaldistance.value;
|
||||
ss->pos = 0;
|
||||
ss->flags = CF_FORCELOOP;
|
||||
ss->flags = CF_FORCELOOP|CF_CLI_STATIC;
|
||||
|
||||
SND_Spatialize (scard, ss);
|
||||
|
||||
|
@ -3707,7 +3696,7 @@ static void S_Q2_AddEntitySounds(soundcardinfo_t *sc)
|
|||
|
||||
if (sc->ChannelUpdate)
|
||||
{
|
||||
for (c = NULL, j=DYNAMIC_FIRST; j < DYNAMIC_STOP ; j++)
|
||||
for (c = NULL, j=DYNAMIC_FIRST; j < sc->total_chans ; j++)
|
||||
{
|
||||
if (sc->channel[j].entnum == entnums[count] && !sc->channel[j].entchannel && (sc->channel[j].flags & CF_CLI_AUTOSOUND))
|
||||
{
|
||||
|
@ -3718,7 +3707,7 @@ static void S_Q2_AddEntitySounds(soundcardinfo_t *sc)
|
|||
}
|
||||
else
|
||||
{
|
||||
for (c = NULL, j=DYNAMIC_FIRST; j < DYNAMIC_STOP ; j++)
|
||||
for (c = NULL, j=DYNAMIC_FIRST; j < sc->total_chans ; j++)
|
||||
{
|
||||
if (sc->channel[j].sfx == sfx && (sc->channel[j].flags & CF_CLI_AUTOSOUND))
|
||||
{
|
||||
|
@ -3838,7 +3827,7 @@ static void S_UpdateCard(soundcardinfo_t *sc)
|
|||
// try to combine static sounds with a previous channel of the same
|
||||
// sound effect so we don't mix five torches every frame
|
||||
|
||||
if (i >= DYNAMIC_STOP)
|
||||
if (ch->flags & CF_CLI_STATIC)
|
||||
{
|
||||
// see if it can just use the last one
|
||||
if (combine && combine->sfx == ch->sfx)
|
||||
|
|
|
@ -126,6 +126,7 @@ typedef struct
|
|||
#ifdef Q3CLIENT
|
||||
#define CF_CLI_NODUPES 4096 // block multiple identical sounds being started on the same entity within rapid succession (regardless of channel). required by quake3.
|
||||
#endif
|
||||
#define CF_CLI_STATIC 8192 //started via ambientsound/svc_spawnstaticsound
|
||||
#define CF_NETWORKED (CF_NOSPACIALISE|CF_NOREVERB|CF_FORCELOOP|CF_FOLLOW|CF_NOREPLACE)
|
||||
|
||||
typedef struct
|
||||
|
@ -281,9 +282,6 @@ void SNDVC_MicInput(qbyte *buffer, int samples, int freq, int width);
|
|||
// User-setable variables
|
||||
// ====================================================================
|
||||
|
||||
#define MAX_DYNAMIC_CHANNELS 64 /*playing sounds (identical ones merge)*/
|
||||
|
||||
|
||||
#define NUM_MUSICS 1
|
||||
|
||||
#define AMBIENT_FIRST 0
|
||||
|
@ -291,7 +289,6 @@ void SNDVC_MicInput(qbyte *buffer, int samples, int freq, int width);
|
|||
#define MUSIC_FIRST AMBIENT_STOP
|
||||
#define MUSIC_STOP (MUSIC_FIRST + NUM_MUSICS)
|
||||
#define DYNAMIC_FIRST MUSIC_STOP
|
||||
#define DYNAMIC_STOP (DYNAMIC_FIRST + MAX_DYNAMIC_CHANNELS)
|
||||
|
||||
//
|
||||
// Fake dma is a synchronous faking of the DMA progress used for
|
||||
|
|
Loading…
Reference in a new issue