Skip to content

Commit 5dba2a0

Browse files
authored
perf(audio): Optimize fail condition order in AudioManager::addAudioEvent (#1843)
1 parent e616d82 commit 5dba2a0

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Core/GameEngine/Source/Common/Audio/GameAudio.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,11 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
440440
return AHSV_NoSound;
441441
}
442442

443+
if (!eventToAdd->getUninterruptable()) {
444+
if (!shouldPlayLocally(eventToAdd)) {
445+
return AHSV_NotForLocal;
446+
}
447+
}
443448

444449
AudioEventRTS *audioEvent = MSGNEW("AudioEventRTS") AudioEventRTS(*eventToAdd); // poolify
445450
audioEvent->setPlayingHandle( allocateNewHandle() );
@@ -455,13 +460,6 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
455460
}
456461
}
457462

458-
if (!audioEvent->getUninterruptable()) {
459-
if (!shouldPlayLocally(audioEvent)) {
460-
releaseAudioEventRTS(audioEvent);
461-
return AHSV_NotForLocal;
462-
}
463-
}
464-
465463
// cull muted audio
466464
if (audioEvent->getVolume() < m_audioSettings->m_minVolume) {
467465
#ifdef INTENSIVE_AUDIO_DEBUG

0 commit comments

Comments
 (0)