From f715f38b08219621d20cdf32a3820bedbdcc1f01 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 3 Dec 2017 03:03:02 +0000 Subject: [PATCH] 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 --- engine/client/snd_al.c | 3 ++- engine/client/snd_dma.c | 25 +++++++++++-------------- engine/client/snd_mix.c | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/engine/client/snd_al.c b/engine/client/snd_al.c index 01139fd13..c9f440d37 100644 --- a/engine/client/snd_al.c +++ b/engine/client/snd_al.c @@ -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"); diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index 413818c96..5b08b83a2 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -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; diff --git a/engine/client/snd_mix.c b/engine/client/snd_mix.c index 454dbae73..2e57c36d1 100644 --- a/engine/client/snd_mix.c +++ b/engine/client/snd_mix.c @@ -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)<pos) / ch->rate; + avail = (((int)(scache->soundoffset + avail)<pos + (ch->rate-1)) / ch->rate; } // mix the smaller of how much is available or the time left count = min(avail, end - ltime);