diff --git a/src/SFML/Audio/SoundFileReaderWav.cpp b/src/SFML/Audio/SoundFileReaderWav.cpp index df8fb98b1..730f841d9 100644 --- a/src/SFML/Audio/SoundFileReaderWav.cpp +++ b/src/SFML/Audio/SoundFileReaderWav.cpp @@ -65,6 +65,17 @@ namespace return true; } + bool decode(sf::InputStream& stream, sf::Int32& value) + { + unsigned char bytes[sizeof(value)]; + if (stream.read(bytes, sizeof(bytes)) != sizeof(bytes)) + return false; + + value = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); + + return true; + } + bool decode(sf::InputStream& stream, sf::Uint32& value) { unsigned char bytes[sizeof(value)]; @@ -157,6 +168,16 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount) return count; break; } + + case 4: + { + Int32 sample = 0; + if (decode(*m_stream, sample)) + *samples++ = sample >> 16; + else + return count; + break; + } } ++count;