Fixed performance issue with reading WAV files
Calling tell() and thus std::ftell() for every reading iteration ate up 80-90% of the whole read call. By manually tracking the current position the calls to tell() can be safely removed.
This commit is contained in:
parent
ff011dc51d
commit
b97a5be615
@ -155,7 +155,11 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
||||
assert(m_stream);
|
||||
|
||||
Uint64 count = 0;
|
||||
while ((count < maxCount) && (static_cast<Uint64>(m_stream->tell()) < m_dataEnd))
|
||||
Uint64 startPos = m_stream->tell();
|
||||
|
||||
// Tracking of m_dataEnd is important to prevent sf::Music from reading
|
||||
// data until EOF, as WAV files may have metadata at the end.
|
||||
while ((count < maxCount) && (startPos + count * m_bytesPerSample < m_dataEnd))
|
||||
{
|
||||
switch (m_bytesPerSample)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user