mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-19 17:01:44 +02:00
De-initialize OpenAL
This commit is contained in:
parent
a574649dce
commit
77ca9054c6
@ -14,6 +14,7 @@ class SoundManager
|
||||
{
|
||||
public:
|
||||
SoundManager();
|
||||
~SoundManager();
|
||||
|
||||
bool loadSound(const std::string& name, const std::string& fileName);
|
||||
bool isLoaded(const std::string& name);
|
||||
@ -63,8 +64,8 @@ private:
|
||||
|
||||
bool initializeOpenAL();
|
||||
|
||||
ALCcontext* alContext;
|
||||
ALCdevice* alDevice;
|
||||
ALCcontext* alContext = nullptr;
|
||||
ALCdevice* alDevice = nullptr;
|
||||
|
||||
std::map<std::string, Sound> sounds;
|
||||
std::map<std::string, MADStream> musics;
|
||||
|
@ -7,6 +7,45 @@
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
SoundManager::SoundManager()
|
||||
{
|
||||
initializeOpenAL();
|
||||
}
|
||||
|
||||
SoundManager::~SoundManager()
|
||||
{
|
||||
// De-initialize OpenAL
|
||||
if(alContext) {
|
||||
alcMakeContextCurrent(NULL);
|
||||
alcDestroyContext(alContext);
|
||||
}
|
||||
|
||||
if(alDevice)
|
||||
alcCloseDevice(alDevice);
|
||||
}
|
||||
|
||||
bool SoundManager::initializeOpenAL()
|
||||
{
|
||||
alDevice = alcOpenDevice(NULL);
|
||||
if ( ! alDevice) {
|
||||
std::cerr << "Could not find OpenAL device!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
alContext = alcCreateContext(alDevice, NULL);
|
||||
if ( ! alContext) {
|
||||
std::cerr << "Could not create OpenAL context!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! alcMakeContextCurrent(alContext)) {
|
||||
std::cerr << "Unable to make OpenAL context current!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SoundManager::SoundSource::loadFromFile(const std::string& filename)
|
||||
{
|
||||
fileInfo.format = 0;
|
||||
@ -50,33 +89,6 @@ bool SoundManager::SoundBuffer::bufferData(SoundSource& soundSource)
|
||||
return true;
|
||||
}
|
||||
|
||||
SoundManager::SoundManager()
|
||||
{
|
||||
initializeOpenAL();
|
||||
}
|
||||
|
||||
bool SoundManager::initializeOpenAL()
|
||||
{
|
||||
alDevice = alcOpenDevice(NULL);
|
||||
if ( ! alDevice) {
|
||||
std::cerr << "Could not find OpenAL device!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
alContext = alcCreateContext(alDevice, NULL);
|
||||
if ( ! alContext) {
|
||||
std::cerr << "Could not create OpenAL context!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! alcMakeContextCurrent(alContext)) {
|
||||
std::cerr << "Unable to make OpenAL context current!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SoundManager::loadSound(const std::string& name, const std::string& fileName)
|
||||
{
|
||||
Sound* sound = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user