From 51bf5cd1bf2516d28158b5844de0643bc31fb0b0 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 15 Aug 2024 15:16:32 +0200 Subject: [PATCH] Fix to not call `GetQueuedBuffersCount` unless needed for the looping fix #2834 --- Source/Engine/Audio/AudioSource.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Source/Engine/Audio/AudioSource.cpp b/Source/Engine/Audio/AudioSource.cpp index e85280f90..719961604 100644 --- a/Source/Engine/Audio/AudioSource.cpp +++ b/Source/Engine/Audio/AudioSource.cpp @@ -426,18 +426,21 @@ void AudioSource::Update() _startingToPlay = false; } - int32 queuedBuffers; - AudioBackend::Source::GetQueuedBuffersCount(this, queuedBuffers); - if (!UseStreaming() && Math::NearEqual(GetTime(), 0.0f) && queuedBuffers > 0 && _isActuallyPlayingSth && !_startingToPlay) + if (!UseStreaming() && Math::NearEqual(GetTime(), 0.0f) && _isActuallyPlayingSth && !_startingToPlay) { - if (GetIsLooping()) + int32 queuedBuffers; + AudioBackend::Source::GetQueuedBuffersCount(this, queuedBuffers); + if (queuedBuffers) { - Stop(); - Play(); - } - else - { - Stop(); + if (GetIsLooping()) + { + Stop(); + Play(); + } + else + { + Stop(); + } } }