mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 07:23:52 +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)
|
||||
fail("Device already initialized");
|
||||
if(mDevice || mContext)
|
||||
fail("Device already open");
|
||||
|
||||
mDevice = alcOpenDevice(devname.c_str());
|
||||
if(!mDevice)
|
||||
{
|
||||
std::cout << "Failed to open \""<<devname<<"\"" << std::endl;
|
||||
return false;
|
||||
}
|
||||
fail("Failed to open \""+devname+"\"");
|
||||
std::cout << "Opened \""<<alcGetString(mDevice, ALC_DEVICE_SPECIFIER)<<"\"" << std::endl;
|
||||
|
||||
mContext = alcCreateContext(mDevice, NULL);
|
||||
if(!mContext || alcMakeContextCurrent(mContext) == ALC_FALSE)
|
||||
{
|
||||
std::cout << "Failed to setup device context" << std::endl;
|
||||
if(mContext)
|
||||
alcDestroyContext(mContext);
|
||||
mContext = 0;
|
||||
alcCloseDevice(mDevice);
|
||||
mDevice = 0;
|
||||
return false;
|
||||
}
|
||||
fail(std::string("Failed to setup context: ")+alcGetString(mDevice, alcGetError(mDevice)));
|
||||
|
||||
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
|
||||
throwALerror();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenAL_Output::deinit()
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace MWSound
|
|||
ALCdevice *mDevice;
|
||||
ALCcontext *mContext;
|
||||
|
||||
virtual bool init(const std::string &devname="");
|
||||
virtual void init(const std::string &devname="");
|
||||
virtual void deinit();
|
||||
|
||||
virtual Sound *playSound(const std::string &fname, float volume, float pitch, bool loop);
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MWSound
|
|||
{
|
||||
SoundManager &mManager;
|
||||
|
||||
virtual bool init(const std::string &devname="") = 0;
|
||||
virtual void init(const std::string &devname="") = 0;
|
||||
virtual void deinit() = 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 decoder: " << SOUND_IN << std::endl;
|
||||
|
||||
mOutput.reset(new DEFAULT_OUTPUT(*this));
|
||||
if(!mOutput->init())
|
||||
try
|
||||
{
|
||||
mOutput.reset(new DEFAULT_OUTPUT(*this));
|
||||
mOutput->init();
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout <<"Sound init failed: "<<e.what()<< std::endl;
|
||||
mOutput.reset();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue