diff --git a/src/SFML/Audio/AudioDevice.cpp b/src/SFML/Audio/AudioDevice.cpp index 2e7bccf21..39d5b9075 100644 --- a/src/SFML/Audio/AudioDevice.cpp +++ b/src/SFML/Audio/AudioDevice.cpp @@ -79,7 +79,7 @@ AudioDevice::~AudioDevice() alcMakeContextCurrent(NULL); if (audioContext) alcDestroyContext(audioContext); - + // Destroy the device if (audioDevice) alcCloseDevice(audioDevice); diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp index 8ec0deb4e..2e89b8217 100644 --- a/src/SFML/Audio/Music.cpp +++ b/src/SFML/Audio/Music.cpp @@ -71,7 +71,7 @@ bool Music::OpenFromFile(const std::string& filename) myDuration = static_cast(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(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()); diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index abcc69172..ee47ca436 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -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