1
Audio / How to properly remove sfml::sound/music (AL lib: (EE) alc_cleanup: 1 device...)
« on: December 20, 2019, 09:04:21 pm »
So all the sounds and music work, however when I exit the program I get this warning (AL lib: (EE) alc_cleanup: 1 device not closed).
So I was able to resolve this warning for sfml::music by using "GameData->assets.music.~SoundSource();" before I exited the window. However I am not sure that is proper.
I cannot resolve this warning for sound objects.
This is how I load sound buffers in a class called assetManager.
void AssetManager::LoadSoundBuffer(const string name, std::string fileName) {
sf::SoundBuffer sB;
if (sB.loadFromFile(fileName))
this->_soundBuffers[name] = sB;
else
std::cout << "\n Failed to load sound!";
}
//Music cannot be loadedaccroding to SFML documentation (due to music being long it will eat up a bunch of memory and this must
//be loaded on the go in small chucks during runtime
void AssetManager::RemoveSoundBuffer(const string name) {
if (this->_soundBuffers.find(name) != _soundBuffers.end())
_soundBuffers.erase(name);
}
And I hold a sf::sound object as a private member in a class called menuState.
According to some of the other post I read, possible issues for this is that I am not letting the new thread sounds create, exit and remove their resources, before the program closes, or that my sound buffers are being removed before the sound gets removed.
Any suggestions on how I should go about this!
So I was able to resolve this warning for sfml::music by using "GameData->assets.music.~SoundSource();" before I exited the window. However I am not sure that is proper.
I cannot resolve this warning for sound objects.
This is how I load sound buffers in a class called assetManager.
void AssetManager::LoadSoundBuffer(const string name, std::string fileName) {
sf::SoundBuffer sB;
if (sB.loadFromFile(fileName))
this->_soundBuffers[name] = sB;
else
std::cout << "\n Failed to load sound!";
}
//Music cannot be loadedaccroding to SFML documentation (due to music being long it will eat up a bunch of memory and this must
//be loaded on the go in small chucks during runtime
void AssetManager::RemoveSoundBuffer(const string name) {
if (this->_soundBuffers.find(name) != _soundBuffers.end())
_soundBuffers.erase(name);
}
And I hold a sf::sound object as a private member in a class called menuState.
According to some of the other post I read, possible issues for this is that I am not letting the new thread sounds create, exit and remove their resources, before the program closes, or that my sound buffers are being removed before the sound gets removed.
Any suggestions on how I should go about this!