Fixed divide by zero when calling getPlayingOffset on an uninitialized sound stream
This commit is contained in:
parent
1336a70eac
commit
abd842510e
@ -168,10 +168,17 @@ void SoundStream::setPlayingOffset(Time timeOffset)
|
||||
////////////////////////////////////////////////////////////
|
||||
Time SoundStream::getPlayingOffset() const
|
||||
{
|
||||
if (m_sampleRate && m_channelCount)
|
||||
{
|
||||
ALfloat secs = 0.f;
|
||||
alCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &secs));
|
||||
|
||||
return seconds(secs + static_cast<float>(m_samplesProcessed) / m_sampleRate / m_channelCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Time::Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user