From 7f11d16f3ba8ae85403625e01c9d295a9e4dc8d1 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Mon, 8 Aug 2011 20:49:57 +0200 Subject: [PATCH] Fixed SoundStream::GetPlayingOffset looping after a few seconds --- include/SFML/Audio/SoundStream.hpp | 2 +- src/SFML/Audio/SoundStream.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp index 300ea942..68ff9129 100644 --- a/include/SFML/Audio/SoundStream.hpp +++ b/include/SFML/Audio/SoundStream.hpp @@ -286,7 +286,7 @@ private : 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 + Uint64 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 }; diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index eb4edf37..07b88a0c 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -159,7 +159,7 @@ void SoundStream::SetPlayingOffset(Uint32 timeOffset) OnSeek(timeOffset); // Restart streaming - mySamplesProcessed = timeOffset * mySampleRate * myChannelsCount / 1000; + mySamplesProcessed = static_cast(timeOffset) * mySampleRate * myChannelsCount / 1000; myIsStreaming = true; myThread.Launch(); } @@ -171,7 +171,7 @@ Uint32 SoundStream::GetPlayingOffset() const ALfloat seconds = 0.f; ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds)); - return static_cast(1000 * seconds) + 1000 * mySamplesProcessed / mySampleRate / myChannelsCount; + return static_cast(1000 * seconds + 1000 * mySamplesProcessed / mySampleRate / myChannelsCount); }