mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 13:23:55 +00:00
Make the sound output init return void
This commit is contained in:
parent
1965b5bc79
commit
b938fd7b36
4 changed files with 15 additions and 22 deletions
|
@ -279,34 +279,22 @@ void OpenAL_Sound::update(const float *pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OpenAL_Output::init(const std::string &devname)
|
void OpenAL_Output::init(const std::string &devname)
|
||||||
{
|
{
|
||||||
if(mContext)
|
if(mDevice || mContext)
|
||||||
fail("Device already initialized");
|
fail("Device already open");
|
||||||
|
|
||||||
mDevice = alcOpenDevice(devname.c_str());
|
mDevice = alcOpenDevice(devname.c_str());
|
||||||
if(!mDevice)
|
if(!mDevice)
|
||||||
{
|
fail("Failed to open \""+devname+"\"");
|
||||||
std::cout << "Failed to open \""<<devname<<"\"" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
std::cout << "Opened \""<<alcGetString(mDevice, ALC_DEVICE_SPECIFIER)<<"\"" << std::endl;
|
std::cout << "Opened \""<<alcGetString(mDevice, ALC_DEVICE_SPECIFIER)<<"\"" << std::endl;
|
||||||
|
|
||||||
mContext = alcCreateContext(mDevice, NULL);
|
mContext = alcCreateContext(mDevice, NULL);
|
||||||
if(!mContext || alcMakeContextCurrent(mContext) == ALC_FALSE)
|
if(!mContext || alcMakeContextCurrent(mContext) == ALC_FALSE)
|
||||||
{
|
fail(std::string("Failed to setup context: ")+alcGetString(mDevice, alcGetError(mDevice)));
|
||||||
std::cout << "Failed to setup device context" << std::endl;
|
|
||||||
if(mContext)
|
|
||||||
alcDestroyContext(mContext);
|
|
||||||
mContext = 0;
|
|
||||||
alcCloseDevice(mDevice);
|
|
||||||
mDevice = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
|
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
|
||||||
throwALerror();
|
throwALerror();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenAL_Output::deinit()
|
void OpenAL_Output::deinit()
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace MWSound
|
||||||
ALCdevice *mDevice;
|
ALCdevice *mDevice;
|
||||||
ALCcontext *mContext;
|
ALCcontext *mContext;
|
||||||
|
|
||||||
virtual bool init(const std::string &devname="");
|
virtual void init(const std::string &devname="");
|
||||||
virtual void deinit();
|
virtual void deinit();
|
||||||
|
|
||||||
virtual Sound *playSound(const std::string &fname, float volume, float pitch, bool loop);
|
virtual Sound *playSound(const std::string &fname, float volume, float pitch, bool loop);
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
SoundManager &mManager;
|
SoundManager &mManager;
|
||||||
|
|
||||||
virtual bool init(const std::string &devname="") = 0;
|
virtual void init(const std::string &devname="") = 0;
|
||||||
virtual void deinit() = 0;
|
virtual void deinit() = 0;
|
||||||
|
|
||||||
virtual Sound *playSound(const std::string &fname, float volume, float pitch, bool loop) = 0;
|
virtual Sound *playSound(const std::string &fname, float volume, float pitch, bool loop) = 0;
|
||||||
|
|
|
@ -47,9 +47,14 @@ namespace MWSound
|
||||||
std::cout << "Sound output: " << SOUND_OUT << std::endl;
|
std::cout << "Sound output: " << SOUND_OUT << std::endl;
|
||||||
std::cout << "Sound decoder: " << SOUND_IN << std::endl;
|
std::cout << "Sound decoder: " << SOUND_IN << std::endl;
|
||||||
|
|
||||||
mOutput.reset(new DEFAULT_OUTPUT(*this));
|
try
|
||||||
if(!mOutput->init())
|
|
||||||
{
|
{
|
||||||
|
mOutput.reset(new DEFAULT_OUTPUT(*this));
|
||||||
|
mOutput->init();
|
||||||
|
}
|
||||||
|
catch(std::exception &e)
|
||||||
|
{
|
||||||
|
std::cout <<"Sound init failed: "<<e.what()<< std::endl;
|
||||||
mOutput.reset();
|
mOutput.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue