make snd_inactive work for drivers other than just the directsound one.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5220 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2018-03-05 11:34:20 +00:00
parent 42b31a6cc3
commit e221c6b5ca
4 changed files with 25 additions and 6 deletions

View File

@ -2689,6 +2689,9 @@ static void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch)
else
volscale = volume.value * voicevolumemod;
if (!vid.activeapp && !snd_inactive.ival && !(ch->flags & CF_INACTIVE))
volscale = 0;
if (sc->seat == -1)
{
seat = 0;
@ -3282,8 +3285,10 @@ void S_UpdateAmbientSounds (soundcardinfo_t *sc)
}
if (chan->sfx)
{
chan->flags = CF_ABSVOLUME|CF_NOSPACIALISE|CF_NOREVERB; //bypasses volume cvar completely.
chan->flags = /*CF_INACTIVE|*/CF_ABSVOLUME|CF_NOSPACIALISE|CF_NOREVERB; //bypasses volume cvar completely.
vol = 255*bgmvolume.value*voicevolumemod;
if (!vid.activeapp && !snd_inactive.ival && !(chan->flags & CF_INACTIVE))
vol = 0;
vol = bound(0, vol, 255);
vol = Media_CrossFade(i-MUSIC_FIRST, vol, (chan->pos>>PITCHSHIFT) / (float)snd_speed);
if (vol < 0)
@ -3953,7 +3958,7 @@ void S_LocalSound2 (const char *sound, int channel, float volume)
Con_Printf ("S_LocalSound: can't cache %s\n", sound);
return;
}
S_StartSound (0, channel, sfx, NULL, NULL, volume, 0, 0, 0, CF_NOSPACIALISE|CF_NOREVERB);
S_StartSound (0, channel, sfx, NULL, NULL, volume, 0, 0, 0, CF_INACTIVE|CF_NOSPACIALISE|CF_NOREVERB);
}
void S_LocalSound (const char *sound)
{
@ -4164,7 +4169,7 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels,
channel_t *c = SND_PickChannel(si, -1, 0);
if (c)
{
c->flags = CF_ABSVOLUME|CF_NOSPACIALISE;
c->flags = (sourceid>=0?CF_INACTIVE:0)|CF_ABSVOLUME|CF_NOSPACIALISE;
c->entnum = 0;
c->entchannel = 0;
c->dist_mult = 0;

View File

@ -192,7 +192,9 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime)
//does it still make a sound if it cannot be heard?...
//technically no...
//this code is hacky.
if (s->decoder.decodedata)
if (s->decoder.querydata)
s->decoder.querydata(s, scache=&scachebuf, NULL, 0);
else if (s->decoder.decodedata)
scache = s->decoder.decodedata(s, &scachebuf, ch->pos>>PITCHSHIFT, 0); /*1 for luck - balances audio termination below*/
else
scache = s->decoder.buf;

View File

@ -72,6 +72,8 @@ typedef struct {
int decodedbytestart;
int decodedbytecount;
quintptr_t pcmtotal;
float timetotal;
OggVorbis_File vf;
sfx_t *s;
@ -127,11 +129,18 @@ float QDECL OV_Query(struct sfx_s *sfx, struct sfxcache_s *buf, char *name, size
ovdecoderbuffer_t *dec = sfx->decoder.buf;
if (!dec)
return -1;
if (dec->timetotal < 0)
{
dec->pcmtotal = p_ov_pcm_total(&dec->vf, -1);
dec->timetotal = p_ov_time_total(&dec->vf, -1);
}
if (buf)
{
buf->data = NULL; //you're not meant to actually be using the data here
buf->soundoffset = 0;
buf->length = p_ov_pcm_total(&dec->vf, -1);
buf->length = dec->pcmtotal;
buf->numchannels = dec->srcchannels;
buf->speed = dec->srcspeed;
buf->width = 2;
@ -155,7 +164,7 @@ float QDECL OV_Query(struct sfx_s *sfx, struct sfxcache_s *buf, char *name, size
else if (title)
Q_snprintfz(name, namesize, "%s", title);
}
return p_ov_time_total(&dec->vf, -1);
return dec->timetotal;
}
static sfxcache_t *QDECL OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, ssamplepos_t start, int length)
@ -502,6 +511,8 @@ static qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdec
buffer->start = BZ_Malloc(length);
memcpy(buffer->start, start, length);
buffer->timetotal = -1;
return true;
}
#endif

View File

@ -121,6 +121,7 @@ typedef struct
//client-internal
#define CF_AUTOSOUND 1024 // generated from q2 entities, which avoids breaking regular sounds, using it outside the sound system will probably break things.
#define CF_INACTIVE 2048 // try to play even when inactive
//server only
#define CF_RELIABLE 1 // serverside only. yeah, evil. screw you.