Fixed inconsistent seek behavior in SoundStream
This commit is contained in:
parent
2df9abf341
commit
2207af41e4
6 changed files with 75 additions and 24 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <SFML/System/Time.hpp>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -146,6 +147,22 @@ public:
|
|||
////////////////////////////////////////////////////////////
|
||||
Time getDuration() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the read offset of the file in time
|
||||
///
|
||||
/// \return Time position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Time getTimeOffset() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the read offset of the file in samples
|
||||
///
|
||||
/// \return Sample position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 getSampleOffset() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current read position to the given sample offset
|
||||
///
|
||||
|
@ -203,6 +220,7 @@ private:
|
|||
SoundFileReader* m_reader; ///< Reader that handles I/O on the file's format
|
||||
InputStream* m_stream; ///< Input stream used to access the file's data
|
||||
bool m_streamOwned; ///< Is the stream internal or external?
|
||||
Uint64 m_sampleOffset; ///< Sample Read Position
|
||||
Uint64 m_sampleCount; ///< Total number of samples in the file
|
||||
unsigned int m_channelCount; ///< Number of channels of the sound
|
||||
unsigned int m_sampleRate; ///< Number of samples per second
|
||||
|
|
|
@ -168,10 +168,9 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
InputSoundFile m_file; ///< The streamed music file
|
||||
Time m_duration; ///< Music duration
|
||||
std::vector<Int16> m_samples; ///< Temporary buffer of samples
|
||||
Mutex m_mutex; ///< Mutex protecting the data
|
||||
InputSoundFile m_file; ///< The streamed music file
|
||||
std::vector<Int16> m_samples; ///< Temporary buffer of samples
|
||||
Mutex m_mutex; ///< Mutex protecting the data
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -254,11 +254,12 @@ private:
|
|||
/// playing queue.
|
||||
///
|
||||
/// \param bufferNum Number of the buffer to fill (in [0, BufferCount])
|
||||
/// \param immediateLoop Treat empty buffers as spent, and act on loops immediately
|
||||
///
|
||||
/// \return True if the stream source has requested to stop, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool fillAndPushBuffer(unsigned int bufferNum);
|
||||
bool fillAndPushBuffer(unsigned int bufferNum, bool immediateLoop = false);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Fill the audio buffers and put them all into the playing queue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue