If we're in the last loop, it is not necessary to provide a full period
on read. Just provide the remaining of the data and hit the end of the
stream by returning less than requested, otherwise we potentially
generate some garbage noise.
Change-Id: I9d3a632ddc0c3289957c9f876d5dbe2999b50ebd
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
dataOffset += (sampleSize - m_offset);
m_offset = 0;
+ if (m_runningCount > 0 && m_runningCount != QSoundEffect::Infinite)
+ soundeffect->setLoopsRemaining(m_runningCount-1);
+
if (m_runningCount > 0 || m_runningCount == QSoundEffect::Infinite) {
// There are still more loops of this sound to play, append the start of sound to make up full period
memcpy(data + dataOffset, sampleData + m_offset, wrapLen);
<< ", part2=" << wrapLen;
qDebug() << "part1 + part2 should be a period " << periodSize;
#endif
- if (m_runningCount != QSoundEffect::Infinite)
- soundeffect->setLoopsRemaining(m_runningCount-1);
}
}
if (m_runningCount == 0)