From 32bafa98a4ae65ccc7d365b4779b40cbd2f8913b Mon Sep 17 00:00:00 2001 From: binary1248 Date: Sun, 9 Nov 2014 23:55:47 +0100 Subject: [PATCH] Reduced lock contention when playing and immediately querying the status of a SoundStream. --- src/SFML/Audio/SoundStream.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 832188932..e8faf468d 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -274,17 +274,21 @@ void SoundStream::streamData() m_isStreaming = false; return; } + } - // Create the buffers - alCheck(alGenBuffers(BufferCount, m_buffers)); - for (int i = 0; i < BufferCount; ++i) - m_endBuffers[i] = false; + // Create the buffers + alCheck(alGenBuffers(BufferCount, m_buffers)); + for (int i = 0; i < BufferCount; ++i) + m_endBuffers[i] = false; - // Fill the queue - requestStop = fillQueue(); + // Fill the queue + requestStop = fillQueue(); - // Play the sound - alCheck(alSourcePlay(m_source)); + // Play the sound + alCheck(alSourcePlay(m_source)); + + { + Lock lock(m_threadMutex); // Check if the thread was launched Paused if (m_threadStartState == Paused)