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
|
Time SoundStream::getPlayingOffset() const
|
||||||
{
|
{
|
||||||
ALfloat secs = 0.f;
|
if (m_sampleRate && m_channelCount)
|
||||||
alCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &secs));
|
{
|
||||||
|
ALfloat secs = 0.f;
|
||||||
|
alCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &secs));
|
||||||
|
|
||||||
return seconds(secs + static_cast<float>(m_samplesProcessed) / m_sampleRate / m_channelCount);
|
return seconds(secs + static_cast<float>(m_samplesProcessed) / m_sampleRate / m_channelCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Time::Zero;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user