From e6a258cc91266918c7baab39181f6c63dfa550ea Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 6 Oct 2017 06:19:12 -0700 Subject: [PATCH] Fix source stream seconds offset calculation --- src/source.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/source.cpp b/src/source.cpp index 5ea0463..652b119 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -734,11 +734,11 @@ std::pair ALSource::getSecOffsetLatency() const int64_t streampos = mStream->getPosition(); if(state != AL_STOPPED) { - srcpos *= mStream->getFrequency(); - frac = srcpos - std::floor(srcpos); + ALdouble ipos; + frac = std::modf(srcpos * mStream->getFrequency(), &ipos); // The amount of samples in the queue waiting to play - ALuint inqueue = queued*mStream->getUpdateLength() - (ALuint)std::ceil(srcpos); + ALuint inqueue = queued*mStream->getUpdateLength() - (ALuint)ipos; if(!mStream->hasLooped()) { // A non-looped stream should never have more samples queued -- 2.11.4.GIT