From e4165be2f9524b2ab1a80b06b26b9242d6816f9d Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Thu, 14 Jan 2010 15:15:05 +0000 Subject: [PATCH 1/2] Fixed the batch-build script for Code::Blocks git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1359 4e206d99-4929-0410-ac5d-dfc041789085 --- build/codeblocks/batch-build/build.bat | 44 ++++++++++++++------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/build/codeblocks/batch-build/build.bat b/build/codeblocks/batch-build/build.bat index bfb07045..e9c63cdf 100644 --- a/build/codeblocks/batch-build/build.bat +++ b/build/codeblocks/batch-build/build.bat @@ -10,35 +10,37 @@ set PATH=%PATH%;"%CD%" REM Compile the SFML libraries cd %SFML%\build\codeblocks +echo Compiling sfml-main... +codeblocks -na -nd -ns --build sfml-main.cbp --target="Debug_Win32" +codeblocks -na -nd -ns --build sfml-main.cbp --target="Release_Win32" + echo Compiling debug static libraries... -codeblocks -na -nd -ns --build sfml-main.cbp --target="Debug" -codeblocks -na -nd -ns --build sfml-audio.cbp --target="Debug static_Win32" -codeblocks -na -nd -ns --build sfml-graphics.cbp --target="Debug static_Win32" -codeblocks -na -nd -ns --build sfml-network.cbp --target="Debug static_Win32" codeblocks -na -nd -ns --build sfml-system.cbp --target="Debug static_Win32" codeblocks -na -nd -ns --build sfml-window.cbp --target="Debug static_Win32" +codeblocks -na -nd -ns --build sfml-graphics.cbp --target="Debug static_Win32" +codeblocks -na -nd -ns --build sfml-audio.cbp --target="Debug static_Win32" +codeblocks -na -nd -ns --build sfml-network.cbp --target="Debug static_Win32" echo Compiling debug dynamic libraries... -codeblocks -na -nd -ns --build sfml-audio.cbp --target="Debug DLL_Win32" -codeblocks -na -nd -ns --build sfml-graphics.cbp --target="Debug DLL_Win32" -codeblocks -na -nd -ns --build sfml-network.cbp --target="Debug DLL_Win32" codeblocks -na -nd -ns --build sfml-system.cbp --target="Debug DLL_Win32" codeblocks -na -nd -ns --build sfml-window.cbp --target="Debug DLL_Win32" +codeblocks -na -nd -ns --build sfml-graphics.cbp --target="Debug DLL_Win32" +codeblocks -na -nd -ns --build sfml-audio.cbp --target="Debug DLL_Win32" +codeblocks -na -nd -ns --build sfml-network.cbp --target="Debug DLL_Win32" echo Compiling release static libraries... -codeblocks -na -nd -ns --build sfml-main.cbp --target="Release" -codeblocks -na -nd -ns --build sfml-audio.cbp --target="Release static_Win32" -codeblocks -na -nd -ns --build sfml-graphics.cbp --target="Release static_Win32" -codeblocks -na -nd -ns --build sfml-network.cbp --target="Release static_Win32" codeblocks -na -nd -ns --build sfml-system.cbp --target="Release static_Win32" codeblocks -na -nd -ns --build sfml-window.cbp --target="Release static_Win32" +codeblocks -na -nd -ns --build sfml-graphics.cbp --target="Release static_Win32" +codeblocks -na -nd -ns --build sfml-audio.cbp --target="Release static_Win32" +codeblocks -na -nd -ns --build sfml-network.cbp --target="Release static_Win32" echo Compiling release dynamic libraries... -codeblocks -na -nd -ns --build sfml-audio.cbp --target="Release DLL_Win32" -codeblocks -na -nd -ns --build sfml-graphics.cbp --target="Release DLL_Win32" -codeblocks -na -nd -ns --build sfml-network.cbp --target="Release DLL_Win32" codeblocks -na -nd -ns --build sfml-system.cbp --target="Release DLL_Win32" codeblocks -na -nd -ns --build sfml-window.cbp --target="Release DLL_Win32" +codeblocks -na -nd -ns --build sfml-graphics.cbp --target="Release DLL_Win32" +codeblocks -na -nd -ns --build sfml-network.cbp --target="Release DLL_Win32" +codeblocks -na -nd -ns --build sfml-audio.cbp --target="Release DLL_Win32" REM Copy the SFML static libraries into a temporary folder IF NOT EXIST %TMP% mkdir %TMP% @@ -56,13 +58,6 @@ ar rs libsfml-window-s.a *.o ar rs libsfml-window-s-d.a *.o del *.o /f /q -REM Add external libraries to sfml-network -echo Adding external libraries to libsfml-network-s... -ar x %SFML%\build\codeblocks\batch-build\libws2_32.a -ar rs libsfml-network-s.a *.o -ar rs libsfml-network-s-d.a *.o -del *.o /f /q - REM Add external libraries to sfml-graphics echo Adding external libraries to libsfml-graphics-s... ar x %SFML%\extlibs\libs-mingw\libfreetype.a @@ -78,6 +73,13 @@ ar rs libsfml-audio-s.a *.o ar rs libsfml-audio-s-d.a *.o del *.o /f /q +REM Add external libraries to sfml-network +echo Adding external libraries to libsfml-network-s... +ar x %SFML%\build\codeblocks\batch-build\libws2_32.a +ar rs libsfml-network-s.a *.o +ar rs libsfml-network-s-d.a *.o +del *.o /f /q + REM Copy the SFML libraries to their final location echo Cleaning up... xcopy *.a %SFML%\lib\mingw /q /y From 6341b569dbcfe53e1522ecdbf83ac7fdda1ce0db Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Thu, 21 Jan 2010 10:00:31 +0000 Subject: [PATCH 2/2] FS#139 - Fix tiny musics ignoring the "loop" flag git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1368 4e206d99-4929-0410-ac5d-dfc041789085 --- build/vc2008/sfml-audio.vcproj | 14 +++++----- include/SFML/Audio/SoundStream.hpp | 19 +++++++------- src/SFML/Audio/SoundStream.cpp | 42 +++++++++++++++++++----------- 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/build/vc2008/sfml-audio.vcproj b/build/vc2008/sfml-audio.vcproj index 3c4c0bdf..b3f14c6b 100644 --- a/build/vc2008/sfml-audio.vcproj +++ b/build/vc2008/sfml-audio.vcproj @@ -402,7 +402,7 @@ > diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp index 6df0c57b..67b2babe 100644 --- a/include/SFML/Audio/SoundStream.hpp +++ b/include/SFML/Audio/SoundStream.hpp @@ -186,12 +186,12 @@ private : /// Fill a new buffer with audio data, and push it to the /// playing queue /// - /// \param Buffer : Buffer to fill + /// \param Buffer : Number of the buffer to fill (in [0, BuffersCount]) /// /// \return True if the derived class has requested to stop /// //////////////////////////////////////////////////////////// - bool FillAndPushBuffer(unsigned int Buffer); + bool FillAndPushBuffer(unsigned int BufferNum); //////////////////////////////////////////////////////////// /// Fill the buffers queue with all available buffers @@ -212,13 +212,14 @@ private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - bool myIsStreaming; ///< Streaming state (true = playing, false = stopped) - unsigned int myBuffers[BuffersCount]; ///< Sound buffers used to store temporary audio data - unsigned int myChannelsCount; ///< Number of channels (1 = mono, 2 = stereo, ...) - unsigned int mySampleRate; ///< Frequency (samples / second) - unsigned long myFormat; ///< Format of the internal sound buffers - bool myLoop; ///< Loop flag (true to loop, false to play once) - unsigned int mySamplesProcessed; ///< Number of buffers processed since beginning of the stream + bool myIsStreaming; ///< Streaming state (true = playing, false = stopped) + unsigned int myBuffers[BuffersCount]; ///< Sound buffers used to store temporary audio data + unsigned int myChannelsCount; ///< Number of channels (1 = mono, 2 = stereo, ...) + unsigned int mySampleRate; ///< Frequency (samples / second) + unsigned long myFormat; ///< Format of the internal sound buffers + bool myLoop; ///< Loop flag (true to loop, false to play once) + unsigned int mySamplesProcessed; ///< Number of buffers processed since beginning of the stream + bool myEndBuffers[BuffersCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation }; } // namespace sf diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 4fb2ff24..bd776edf 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -188,9 +188,10 @@ bool SoundStream::GetLoop() const //////////////////////////////////////////////////////////// void SoundStream::Run() { - // Create buffers + // Create the buffers ALCheck(alGenBuffers(BuffersCount, myBuffers)); - unsigned int EndBuffer = 0xFFFF; + for (int i = 0; i < BuffersCount; ++i) + myEndBuffers[i] = false; // Fill the queue bool RequestStop = FillQueue(); @@ -225,12 +226,21 @@ void SoundStream::Run() ALuint Buffer; ALCheck(alSourceUnqueueBuffers(Sound::mySource, 1, &Buffer)); + // Find its number + unsigned int BufferNum = 0; + for (int i = 0; i < BuffersCount; ++i) + if (myBuffers[i] == Buffer) + { + BufferNum = i; + break; + } + // Retrieve its size and add it to the samples count - if (Buffer == EndBuffer) + if (myEndBuffers[BufferNum]) { // This was the last buffer: reset the sample count mySamplesProcessed = 0; - EndBuffer = 0xFFFF; + myEndBuffers[BufferNum] = false; } else { @@ -242,16 +252,10 @@ void SoundStream::Run() // Fill it and push it back into the playing queue if (!RequestStop) { - if (FillAndPushBuffer(Buffer)) + if (FillAndPushBuffer(BufferNum)) { // User requested to stop: check if we must loop or really stop - if (myLoop && OnStart()) - { - // Looping: mark the current buffer as the last one - // (to know when to reset the sample count) - EndBuffer = Buffer; - } - else + if (!myLoop || !OnStart()) { // Not looping or restart failed: request stop RequestStop = true; @@ -281,18 +285,23 @@ void SoundStream::Run() /// Fill a new buffer with audio data, and push it to the /// playing queue //////////////////////////////////////////////////////////// -bool SoundStream::FillAndPushBuffer(unsigned int Buffer) +bool SoundStream::FillAndPushBuffer(unsigned int BufferNum) { bool RequestStop = false; // Acquire audio data Chunk Data = {NULL, 0}; if (!OnGetData(Data)) + { + myEndBuffers[BufferNum] = true; RequestStop = true; + } // Create and fill the buffer, and push it to the queue if (Data.Samples && Data.NbSamples) { + unsigned int Buffer = myBuffers[BufferNum]; + // Fill the buffer ALsizei Size = static_cast(Data.NbSamples) * sizeof(Int16); ALCheck(alBufferData(Buffer, myFormat, Data.Samples, Size, mySampleRate)); @@ -314,8 +323,11 @@ bool SoundStream::FillQueue() bool RequestStop = false; for (int i = 0; (i < BuffersCount) && !RequestStop; ++i) { - if (FillAndPushBuffer(myBuffers[i])) - RequestStop = true; + if (FillAndPushBuffer(i)) + { + if (!myLoop || !OnStart()) + RequestStop = true; + } } return RequestStop;