- fixed: Exhumed's ChannelEnded method did not call the super class.

This caused all sorts of audio errors.
This commit is contained in:
Christoph Oelckers 2019-12-27 20:05:58 +01:00
parent 907c2bbe1e
commit affa8240f4
5 changed files with 24 additions and 13 deletions

View file

@ -31,6 +31,7 @@ enum EChanFlag
CHANF_VIRTUAL = 2048, // internal: Channel is currently virtual
CHANF_NOSTOP = 4096, // only for A_PlaySound. Does not start if channel is playing something.
CHANF_OVERLAP = 8192, // [MK] Does not stop any sounds in the channel and instead plays over them.
CHANF_ENDED = 16384, // Helper to detect broken ChannelEnded implementations.
};
typedef TFlags<EChanFlag> EChanFlags;

View file

@ -1702,7 +1702,9 @@ void OpenALSoundRenderer::StopChannel(FISoundChannel *chan)
ALuint source = GET_PTRID(chan->SysChannel);
// Release first, so it can be properly marked as evicted if it's being killed
chan->ChanFlags |= CHANF_ENDED;
soundEngine->ChannelEnded(chan);
assert(!(chan->ChanFlags & CHANF_ENDED));
ALint state = AL_INITIAL;
alGetSourcei(source, AL_SOURCE_STATE, &state);
@ -1726,7 +1728,9 @@ void OpenALSoundRenderer::ForceStopChannel(FISoundChannel *chan)
ALuint source = GET_PTRID(chan->SysChannel);
if(!source) return;
chan->ChanFlags |= CHANF_ENDED;
soundEngine->ChannelEnded(chan);
assert(!(chan->ChanFlags & CHANF_ENDED));
FreeSource(source);
}

View file

@ -606,6 +606,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
}
if (chan != NULL)
{
assert(!(chan->ChanFlags & CHANF_FORGETTABLE));
chan->SoundID = sound_id;
chan->OrgID = FSoundID(org_id);
chan->EntChannel = channel;
@ -1347,7 +1348,7 @@ void SoundEngine::ChannelEnded(FISoundChannel *ichan)
{
FSoundChan *schan = static_cast<FSoundChan*>(ichan);
bool evicted;
schan->ChanFlags &= ~CHANF_ENDED;
if (schan != NULL)
{
// If the sound was stopped with GSnd->StopSound(), then we know
@ -1763,7 +1764,7 @@ FString SoundEngine::NoiseDebug()
int ch = 0;
FStringf out("*** SOUND DEBUG INFO ***\nListener: %3.2f %2.3f %2.3f\n"
"x y z vol dist chan pri flags aud pos name\n", listener.X, listener.Y, listener.Z);
"x y z vol dist chan pri flags aud pos name\n", listener.X, listener.Y, listener.Z);
if (Channels == nullptr)
{
@ -1781,16 +1782,17 @@ FString SoundEngine::NoiseDebug()
CalcPosVel(chan, &origin, nullptr);
out.AppendFormat(TEXTCOLOR_GOLD "%5.0f | %5.0f | %5.0f | %5.0f ", origin.X, origin.Z, origin.Y, (origin - listener).Length());
}
out.AppendFormat("%-.2g %-4d %-4d %s3%sZ%sU%sM%sN%sA%sL%sE%sV" TEXTCOLOR_GOLD " %-5.4f %-4u %d: %s\n", chan->Volume, chan->EntChannel, chan->Priority,
(chan->ChanFlags & CHANF_IS3D) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHANF_LISTENERZ) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHANF_UI) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHANF_MAYBE_LOCAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHANF_NOPAUSE) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHANF_AREA) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHANF_LOOP) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHANF_EVICTED) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHANF_VIRTUAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
out.AppendFormat("%-.2g %-4d %-4d %sF%s3%sZ%sU%sM%sN%sA%sL%sE%sV" TEXTCOLOR_GOLD " %-5.4f %-4u %d: %s\n", chan->Volume, chan->EntChannel, chan->Priority,
(chan->ChanFlags & CHANF_FORGETTABLE) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
(chan->ChanFlags & CHANF_IS3D) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
(chan->ChanFlags & CHANF_LISTENERZ) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
(chan->ChanFlags & CHANF_UI) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
(chan->ChanFlags & CHANF_MAYBE_LOCAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
(chan->ChanFlags & CHANF_NOPAUSE) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
(chan->ChanFlags & CHANF_AREA) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
(chan->ChanFlags & CHANF_LOOP) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
(chan->ChanFlags & CHANF_EVICTED) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
(chan->ChanFlags & CHANF_VIRTUAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_DARKRED,
GSnd->GetAudibility(chan), GSnd->GetPosition(chan), ((int)chan->OrgID)-1, S_sfx[chan->SoundID].name.GetChars());
ch++;
}

View file

@ -73,6 +73,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <assert.h>
#include "gamecvars.h"
#include "savegamehelp.h"
#include "c_dispatch.h"
BEGIN_PS_NS
@ -805,6 +806,7 @@ void faketimerhandler()
void timerhandler()
{
UpdateSounds();
scan_char++;
if (scan_char == kTimerTicks)
{
@ -1840,8 +1842,10 @@ void CheckCommandLine(int argc, char const* const* argv, int &doTitle)
}
}
int GameInterface::app_main()
{
C_DoCommand("stat sounddebug");
int i;
//int esi = 1;
//int edi = esi;
@ -2209,7 +2213,6 @@ GAMELOOP:
// TODO CONTROL_GetButtonInput();
CheckKeys();
UpdateSounds();
if (bRecord || bPlayback)
{

View file

@ -182,6 +182,7 @@ class EXSoundEngine : public SoundEngine
{
if (inf.snd_channel == chan) inf.snd_channel = nullptr;
}
SoundEngine::ChannelEnded(chan);
}
public: