Added SetPlayingOffset to sf::SoundStream and sf::Music
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1076 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
364b0ae9b1
commit
22c225c64f
17 changed files with 202 additions and 166 deletions
|
@ -76,18 +76,6 @@ public :
|
|||
|
||||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see SoundStream::OnStart
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnStart()
|
||||
{
|
||||
// Reset the playing offset
|
||||
myOffset = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see SoundStream::OnGetData
|
||||
///
|
||||
|
@ -95,11 +83,11 @@ private :
|
|||
virtual bool OnGetData(sf::SoundStream::Chunk& Data)
|
||||
{
|
||||
// We have reached the end of the buffer and all audio data have been played : we can stop playback
|
||||
if ((myOffset == mySamples.size()) && myHasFinished)
|
||||
if ((myOffset >= mySamples.size()) && myHasFinished)
|
||||
return false;
|
||||
|
||||
// No new data has arrived since last update : wait until we get some
|
||||
while ((myOffset == mySamples.size()) && !myHasFinished)
|
||||
while ((myOffset >= mySamples.size()) && !myHasFinished)
|
||||
sf::Sleep(0.01f);
|
||||
|
||||
// Copy samples into a local buffer to avoid synchronization problems
|
||||
|
@ -119,6 +107,15 @@ private :
|
|||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see SoundStream::OnSeek
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(float TimeOffset)
|
||||
{
|
||||
myOffset = static_cast<std::size_t>(TimeOffset * GetSampleRate() * GetChannelsCount());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get audio data from the client until playback is stopped
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue