Make deleting listenerSlot in idSoundWorldLocal::Shutdown() work

the problem was that the sources were still associated to it, because
they get deleted after the listenerSlot: the sources get freed in
idSoundSystemLocal::Shutdown() which is called by
idCommonLocal::ShutdownGame() in line 3217,
while the listenerSlot is deleted via idSessionLocal::Shutdown()
-> delete sw/rw -> idSoundWorldLocal::~idSoundWorldLocal()
-> idSoundWorldLocal::Shutdown() - and idSessionLocal::Shutdown() is
called in idCommonLocal::ShutdownGame() line 3211, before the other.

I'm not gonna mess with the order of deleting things in ShutdownGame(),
but it's sufficient to unassociate the effect slot from the source
when destroying the emitters in idSoundWorldLocal::Shutdown(),
by adding a call for that to idSoundChannel::ALStop() - and destroying
the emitters before deleting listenerSlot.

Before this fix, with ALSOFT_LOGLEVEL=3 you got the following warning:
  (WW) Error generated on context 0x5578fce2a280, code 0xa004,
  "Deleting in-use effect slot 1"
Thanks for openal-soft's KittyCat for pointing this out!
This commit is contained in:
Daniel Gibson 2021-04-12 18:55:52 +02:00
parent 9c6b835f16
commit 13ac657ebf
2 changed files with 12 additions and 6 deletions

View file

@ -227,6 +227,9 @@ void idSoundChannel::ALStop( void ) {
if ( alIsSource( openalSource ) ) {
alSourceStop( openalSource );
alSourcei( openalSource, AL_BUFFER, 0 );
// unassociate effect slot from source, so the effect slot can be deleted on shutdown
// even though the source itself is deleted later (in idSoundSystemLocal::Shutdown())
alSource3i( openalSource, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL );
soundSystemLocal.FreeOpenALSource( openalSource );
}

View file

@ -157,6 +157,15 @@ void idSoundWorldLocal::Shutdown() {
AVIClose();
// delete emitters before deletign the listenerSlot, so their sources aren't
// associated with the listenerSlot anymore
for ( i = 0; i < emitters.Num(); i++ ) {
if ( emitters[i] ) {
delete emitters[i];
emitters[i] = NULL;
}
}
if (idSoundSystemLocal::useEFXReverb) {
if (soundSystemLocal.alIsAuxiliaryEffectSlot(listenerSlot)) {
soundSystemLocal.alAuxiliaryEffectSloti(listenerSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECTSLOT_NULL);
@ -175,12 +184,6 @@ void idSoundWorldLocal::Shutdown() {
}
}
for ( i = 0; i < emitters.Num(); i++ ) {
if ( emitters[i] ) {
delete emitters[i];
emitters[i] = NULL;
}
}
localSound = NULL;
}