attempt to fix csqc's updatesound builtin - openal will no longer restart, and other devices will now loop properly (instead of muting).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5177 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2017-12-03 03:03:02 +00:00
parent fbf5069a38
commit f715f38b08
3 changed files with 14 additions and 16 deletions

View File

@ -929,7 +929,8 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, unsigned
}
/*and start it up again*/
palSourcePlay(src);
if (schanged != 2)
palSourcePlay(src);
}
PrintALError("post start sound");

View File

@ -2781,14 +2781,14 @@ static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_
extern cvar_t cl_demospeed;
int chanupdatetype = true;
if (fvol < 0)
if (!sfx)
sfx = target_chan->sfx;
if (fvol < 0 || !sfx)
{ //stopsound, apparently.
target_chan->sfx = NULL;
return;
}
if (!sfx)
sfx = target_chan->sfx;
if (ratemul <= 0)
ratemul = 1;
@ -2798,6 +2798,8 @@ static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_
vol = fvol*255;
// spatialize
if (target_chan->sfx != sfx)
chanupdatetype = true;
memset (target_chan, 0, sizeof(*target_chan));
if (!origin)
{
@ -2831,19 +2833,14 @@ static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_
return; // not audible at all
}
if (sfx)
if (!S_LoadSound (sfx))
{
if (!S_LoadSound (sfx))
{
target_chan->sfx = NULL;
return; // couldn't load the sound's data
}
if (target_chan->sfx != sfx)
chanupdatetype = true;
target_chan->sfx = sfx;
target_chan->sfx = NULL;
return; // couldn't load the sound's data
}
target_chan->sfx = sfx;
if (updateonly && sc->ChannelUpdate)
{
chanupdatetype = 2;

View File

@ -278,7 +278,7 @@ void S_PaintChannels(soundcardinfo_t *sc, int endtime)
avail = scache->length;
if (avail > maxlen)
avail = snd_speed*10;
avail = (((int)(scache->soundoffset + avail)<<PITCHSHIFT) - ch->pos) / ch->rate;
avail = (((int)(scache->soundoffset + avail)<<PITCHSHIFT) - ch->pos + (ch->rate-1)) / ch->rate;
}
// mix the smaller of how much is available or the time left
count = min(avail, end - ltime);