From 1055dc84155b5d8d3e12e038902ac1f96aaa5be9 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 7 Aug 2024 21:51:36 -0500 Subject: [PATCH] guiaudio crashfix on exit further ensure sound playback isn't even started unless the test condition is true and the gui element is awake remove redundant sfx->stop(). already does so with SFX_DELETE(source) --- Engine/source/gui/shiny/guiAudioCtrl.cpp | 56 ++++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Engine/source/gui/shiny/guiAudioCtrl.cpp b/Engine/source/gui/shiny/guiAudioCtrl.cpp index a077ee24fb..9d79c68d9b 100644 --- a/Engine/source/gui/shiny/guiAudioCtrl.cpp +++ b/Engine/source/gui/shiny/guiAudioCtrl.cpp @@ -150,40 +150,41 @@ void GuiAudioCtrl::initPersistFields() void GuiAudioCtrl::_update() { - bool useTrackDescriptionOnly = (mUseTrackDescriptionOnly && getSoundProfile()); - if (getSoundProfile()) + if (testCondition() && isAwake()) { - if (mSoundPlaying == NULL) - { - mSoundPlaying = SFX->createSource(getSoundProfile(), &(SFX->getListener().getTransform())); - } - } + bool useTrackDescriptionOnly = (mUseTrackDescriptionOnly && getSoundProfile()); - // The rest only applies if we have a source. - if (mSoundPlaying && !useTrackDescriptionOnly) - { - - // Set the volume irrespective of the profile. - if (mSourceGroup) - { - mSourceGroup->addObject(mSoundPlaying); - mSoundPlaying->setVolume(mSourceGroup->getVolume() * mVolume); - } - else + if (getSoundProfile()) { - mSoundPlaying->setVolume(mVolume); + if (mSoundPlaying == NULL) + { + mSoundPlaying = SFX->createSource(getSoundProfile(), &(SFX->getListener().getTransform())); + } } - mSoundPlaying->setPitch(mPitch); - mSoundPlaying->setFadeTimes(mFadeInTime, mFadeOutTime); - - } - - if (isAwake()) - { - if (testCondition() && mSoundPlaying && !mSoundPlaying->isPlaying()) + if ( mSoundPlaying && !mSoundPlaying->isPlaying()) { + // The rest only applies if we have a source. + if (!useTrackDescriptionOnly) + { + + // Set the volume irrespective of the profile. + if (mSourceGroup) + { + mSourceGroup->addObject(mSoundPlaying); + mSoundPlaying->setVolume(mSourceGroup->getVolume() * mVolume); + } + else + { + mSoundPlaying->setVolume(mVolume); + } + + mSoundPlaying->setPitch(mPitch); + mSoundPlaying->setFadeTimes(mFadeInTime, mFadeOutTime); + + } + mSoundPlaying->play(); } } @@ -191,7 +192,6 @@ void GuiAudioCtrl::_update() { if (mSoundPlaying != NULL) { - mSoundPlaying->stop(); SFX_DELETE(mSoundPlaying); setProcessTicks(false); }