Audio/Music: Fix possible data-race in GetPlayingOffset
This commit is contained in:
parent
ad81b8642e
commit
150787971a
|
|
@ -131,12 +131,12 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(m_stream, "Music not created");
|
NazaraAssert(m_stream, "Music not created");
|
||||||
|
|
||||||
if (!m_streaming)
|
|
||||||
return Time::Zero();
|
|
||||||
|
|
||||||
// Prevent music thread from enqueuing new buffers while we're getting the count
|
// Prevent music thread from enqueuing new buffers while we're getting the count
|
||||||
std::lock_guard<std::recursive_mutex> lock(m_sourceLock);
|
std::lock_guard<std::recursive_mutex> lock(m_sourceLock);
|
||||||
|
|
||||||
|
if (!m_streaming)
|
||||||
|
return Time::Zero();
|
||||||
|
|
||||||
Time playingOffset = m_source->GetPlayingOffset();
|
Time playingOffset = m_source->GetPlayingOffset();
|
||||||
Time processedTime = Time::Microseconds(1'000'000ll * m_processedSamples / (GetChannelCount(m_stream->GetFormat()) * m_sampleRate));
|
Time processedTime = Time::Microseconds(1'000'000ll * m_processedSamples / (GetChannelCount(m_stream->GetFormat()) * m_sampleRate));
|
||||||
playingOffset += processedTime;
|
playingOffset += processedTime;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue