mirror of
https://github.com/SFML/SFML.git
synced 2024-11-29 06:41:05 +08:00
Fixed a possible bug in the calculation of sf::SoundStream playing offset
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1495 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
007db7d39a
commit
14d0b8a483
@ -71,7 +71,7 @@ bool Music::OpenFromFile(const std::string& filename)
|
||||
myDuration = static_cast<float>(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount();
|
||||
|
||||
// Resize the internal buffer so that it can contain 1 second of audio samples
|
||||
mySamples.resize(myFile->GetSampleRate());
|
||||
mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount());
|
||||
|
||||
// Initialize the stream
|
||||
Initialize(myFile->GetChannelsCount(), myFile->GetSampleRate());
|
||||
@ -97,7 +97,7 @@ bool Music::OpenFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
myDuration = static_cast<float>(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount();
|
||||
|
||||
// Resize the internal buffer so that it can contain 1 second of audio samples
|
||||
mySamples.resize(myFile->GetSampleRate());
|
||||
mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount());
|
||||
|
||||
// Initialize the stream
|
||||
Initialize(myFile->GetChannelsCount(), myFile->GetSampleRate());
|
||||
|
@ -243,9 +243,10 @@ void SoundStream::Run()
|
||||
}
|
||||
else
|
||||
{
|
||||
ALint size;
|
||||
ALint size, bits;
|
||||
ALCheck(alGetBufferi(buffer, AL_SIZE, &size));
|
||||
mySamplesProcessed += size / sizeof(Int16);
|
||||
ALCheck(alGetBufferi(buffer, AL_BITS, &bits));
|
||||
mySamplesProcessed += size / (bits / 8);
|
||||
}
|
||||
|
||||
// Fill it and push it back into the playing queue
|
||||
|
Loading…
Reference in New Issue
Block a user