mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
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
4a41f37d5d
commit
33c26dd6e6
@ -155,7 +155,11 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
|||||||
assert(m_stream);
|
assert(m_stream);
|
||||||
|
|
||||||
Uint64 count = 0;
|
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)
|
switch (m_bytesPerSample)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user