From fae91bbbf22a5c6155d133ed6fc20dcb5f6a8992 Mon Sep 17 00:00:00 2001 From: kimci86 Date: Mon, 7 Mar 2022 00:18:03 +0100 Subject: [PATCH] Allow SoundStream::play to be called again after reaching the end --- src/SFML/Audio/SoundStream.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 76e7d3778..e1c913ebd 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -136,6 +136,12 @@ void SoundStream::play() // If the sound is playing, stop it and continue as if it was stopped stop(); } + else if (!isStreaming && m_thread.joinable()) + { + // If the streaming thread reached its end, let it join so it can be restarted. + // Also reset the playing offset at the beginning. + stop(); + } // Start updating the stream in a separate thread to avoid blocking the application launchStreamingThread(Playing);