From cd9b8b9a150b8c883e827ebd3e060dd7daa402e6 Mon Sep 17 00:00:00 2001 From: binary1248 Date: Wed, 11 Mar 2015 02:05:52 +0100 Subject: [PATCH] Fixed FLAC SoundStreams not checking for the EOF decoder state and looping forever. --- src/SFML/Audio/SoundFileReaderFlac.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SFML/Audio/SoundFileReaderFlac.cpp b/src/SFML/Audio/SoundFileReaderFlac.cpp index 8469a6007..646b0312f 100644 --- a/src/SFML/Audio/SoundFileReaderFlac.cpp +++ b/src/SFML/Audio/SoundFileReaderFlac.cpp @@ -298,8 +298,13 @@ Uint64 SoundFileReaderFlac::read(Int16* samples, Uint64 maxCount) while (m_clientData.remaining > 0) { // Everything happens in the "write" callback + // This will break on any fatal error (does not include EOF) if (!FLAC__stream_decoder_process_single(m_decoder)) break; + + // Break on EOF + if (FLAC__stream_decoder_get_state(m_decoder) == FLAC__STREAM_DECODER_END_OF_STREAM) + break; } return maxCount - m_clientData.remaining;