Merge branch 'fix-stop-audio' of https://github.com/Tryibion/FlaxEngine into Tryibion-fix-stop-audio
This commit is contained in:
@@ -338,6 +338,7 @@ void AudioSource::PlayInternal()
|
|||||||
AudioBackend::Source::Play(this);
|
AudioBackend::Source::Play(this);
|
||||||
|
|
||||||
_isActuallyPlayingSth = true;
|
_isActuallyPlayingSth = true;
|
||||||
|
_startingToPlay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
@@ -419,6 +420,27 @@ void AudioSource::Update()
|
|||||||
AudioBackend::Source::VelocityChanged(this);
|
AudioBackend::Source::VelocityChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset starting to play value once time is greater than zero
|
||||||
|
if (_startingToPlay && GetTime() > 0.0f)
|
||||||
|
{
|
||||||
|
_startingToPlay = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 queuedBuffers;
|
||||||
|
AudioBackend::Source::GetQueuedBuffersCount(this, queuedBuffers);
|
||||||
|
if (!UseStreaming() && Math::NearEqual(GetTime(), 0.0f) && queuedBuffers > 0 && _isActuallyPlayingSth && !_startingToPlay)
|
||||||
|
{
|
||||||
|
if (GetIsLooping())
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
Play();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Skip other update logic if it's not valid streamable source
|
// Skip other update logic if it's not valid streamable source
|
||||||
if (!UseStreaming() || SourceIDs.IsEmpty())
|
if (!UseStreaming() || SourceIDs.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ private:
|
|||||||
bool _clipChanged = false;
|
bool _clipChanged = false;
|
||||||
|
|
||||||
bool _isActuallyPlayingSth = false;
|
bool _isActuallyPlayingSth = false;
|
||||||
|
bool _startingToPlay = false;
|
||||||
bool _needToUpdateStreamingBuffers = false;
|
bool _needToUpdateStreamingBuffers = false;
|
||||||
States _state = States::Stopped;
|
States _state = States::Stopped;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user