forked from mirror/openmw-tes3mp
Try opening the default device fallback in OpenAL_Output
This commit is contained in:
parent
f594eda574
commit
acd6d9cd72
2 changed files with 23 additions and 32 deletions
|
@ -595,23 +595,23 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
|
||||||
deinit();
|
deinit();
|
||||||
|
|
||||||
mDevice = alcOpenDevice(devname.c_str());
|
mDevice = alcOpenDevice(devname.c_str());
|
||||||
|
if(!mDevice && !devname.empty())
|
||||||
|
{
|
||||||
|
std::cerr<< "Failed to open \""<<devname<<"\", trying default" <<std::endl;
|
||||||
|
mDevice = alcOpenDevice(nullptr);
|
||||||
|
}
|
||||||
if(!mDevice)
|
if(!mDevice)
|
||||||
{
|
{
|
||||||
if(devname.empty())
|
std::cerr<< "Failed to open default audio device" <<std::endl;
|
||||||
std::cerr<< "Failed to open default audio device" <<std::endl;
|
|
||||||
else
|
|
||||||
std::cerr<< "Failed to open \""<<devname<<"\"" <<std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
const ALCchar *name = nullptr;
|
||||||
const ALCchar *name = NULL;
|
if(alcIsExtensionPresent(mDevice, "ALC_ENUMERATE_ALL_EXT"))
|
||||||
if(alcIsExtensionPresent(mDevice, "ALC_ENUMERATE_ALL_EXT"))
|
name = alcGetString(mDevice, ALC_ALL_DEVICES_SPECIFIER);
|
||||||
name = alcGetString(mDevice, ALC_ALL_DEVICES_SPECIFIER);
|
if(alcGetError(mDevice) != AL_NO_ERROR || !name)
|
||||||
if(alcGetError(mDevice) != AL_NO_ERROR || !name)
|
name = alcGetString(mDevice, ALC_DEVICE_SPECIFIER);
|
||||||
name = alcGetString(mDevice, ALC_DEVICE_SPECIFIER);
|
std::cout<< "Opened \""<<name<<"\"" <<std::endl;
|
||||||
std::cout << "Opened \""<<name<<"\"" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
ALC.EXT_EFX = alcIsExtensionPresent(mDevice, "ALC_EXT_EFX");
|
ALC.EXT_EFX = alcIsExtensionPresent(mDevice, "ALC_EXT_EFX");
|
||||||
ALC.SOFT_HRTF = alcIsExtensionPresent(mDevice, "ALC_SOFT_HRTF");
|
ALC.SOFT_HRTF = alcIsExtensionPresent(mDevice, "ALC_SOFT_HRTF");
|
||||||
|
@ -643,7 +643,7 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
|
||||||
}
|
}
|
||||||
|
|
||||||
if(index < 0)
|
if(index < 0)
|
||||||
std::cerr<< "Failed to find HRTF name \""<<hrtfname<<"\", using default" <<std::endl;
|
std::cerr<< "Failed to find HRTF \""<<hrtfname<<"\", using default" <<std::endl;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
attrs.push_back(ALC_HRTF_ID_SOFT);
|
attrs.push_back(ALC_HRTF_ID_SOFT);
|
||||||
|
@ -698,7 +698,7 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
|
||||||
{
|
{
|
||||||
ALuint src = 0;
|
ALuint src = 0;
|
||||||
alGenSources(1, &src);
|
alGenSources(1, &src);
|
||||||
if(getALError() != AL_NO_ERROR)
|
if(alGetError() != AL_NO_ERROR)
|
||||||
break;
|
break;
|
||||||
mFreeSources.push_back(src);
|
mFreeSources.push_back(src);
|
||||||
}
|
}
|
||||||
|
@ -824,8 +824,10 @@ void OpenAL_Output::deinit()
|
||||||
{
|
{
|
||||||
mStreamThread->removeAll();
|
mStreamThread->removeAll();
|
||||||
|
|
||||||
for(size_t i = 0;i < mFreeSources.size();i++)
|
std::for_each(mFreeSources.cbegin(), mFreeSources.cend(),
|
||||||
alDeleteSources(1, &mFreeSources[i]);
|
[](ALuint source) -> void
|
||||||
|
{ alDeleteSources(1, &source); }
|
||||||
|
);
|
||||||
mFreeSources.clear();
|
mFreeSources.clear();
|
||||||
|
|
||||||
if(mEffectSlot)
|
if(mEffectSlot)
|
||||||
|
|
|
@ -26,11 +26,7 @@
|
||||||
#include "sound.hpp"
|
#include "sound.hpp"
|
||||||
|
|
||||||
#include "openal_output.hpp"
|
#include "openal_output.hpp"
|
||||||
#define SOUND_OUT "OpenAL"
|
|
||||||
#include "ffmpeg_decoder.hpp"
|
#include "ffmpeg_decoder.hpp"
|
||||||
#ifndef SOUND_IN
|
|
||||||
#define SOUND_IN "FFmpeg"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace MWSound
|
namespace MWSound
|
||||||
|
@ -60,6 +56,8 @@ namespace MWSound
|
||||||
, mUnderwaterSound(nullptr)
|
, mUnderwaterSound(nullptr)
|
||||||
, mNearWaterSound(nullptr)
|
, mNearWaterSound(nullptr)
|
||||||
{
|
{
|
||||||
|
std::cout<< "Initializing sound..." <<std::endl;
|
||||||
|
|
||||||
mMasterVolume = Settings::Manager::getFloat("master volume", "Sound");
|
mMasterVolume = Settings::Manager::getFloat("master volume", "Sound");
|
||||||
mMasterVolume = std::min(std::max(mMasterVolume, 0.0f), 1.0f);
|
mMasterVolume = std::min(std::max(mMasterVolume, 0.0f), 1.0f);
|
||||||
mSFXVolume = Settings::Manager::getFloat("sfx volume", "Sound");
|
mSFXVolume = Settings::Manager::getFloat("sfx volume", "Sound");
|
||||||
|
@ -91,9 +89,6 @@ namespace MWSound
|
||||||
HrtfMode hrtfmode = hrtfstate < 0 ? HrtfMode::Auto :
|
HrtfMode hrtfmode = hrtfstate < 0 ? HrtfMode::Auto :
|
||||||
hrtfstate > 0 ? HrtfMode::Enable : HrtfMode::Disable;
|
hrtfstate > 0 ? HrtfMode::Enable : HrtfMode::Disable;
|
||||||
|
|
||||||
std::cout << "Sound output: " << SOUND_OUT << std::endl;
|
|
||||||
std::cout << "Sound decoder: " << SOUND_IN << std::endl;
|
|
||||||
|
|
||||||
std::vector<std::string> names = mOutput->enumerate();
|
std::vector<std::string> names = mOutput->enumerate();
|
||||||
std::cout <<"Enumerated output devices:\n";
|
std::cout <<"Enumerated output devices:\n";
|
||||||
std::for_each(names.cbegin(), names.cend(),
|
std::for_each(names.cbegin(), names.cend(),
|
||||||
|
@ -103,15 +98,9 @@ namespace MWSound
|
||||||
std::cout.flush();
|
std::cout.flush();
|
||||||
|
|
||||||
std::string devname = Settings::Manager::getString("device", "Sound");
|
std::string devname = Settings::Manager::getString("device", "Sound");
|
||||||
bool inited = mOutput->init(devname, hrtfname, hrtfmode);
|
if(!mOutput->init(devname, hrtfname, hrtfmode))
|
||||||
if(!inited && !devname.empty())
|
|
||||||
{
|
{
|
||||||
std::cerr<< "Failed to initialize device \""<<devname<<"\", trying default" <<std::endl;
|
std::cerr<< "Failed to initialize audio output, sound disabled" <<std::endl;
|
||||||
inited = mOutput->init(std::string(), hrtfname, hrtfmode);
|
|
||||||
}
|
|
||||||
if(!inited)
|
|
||||||
{
|
|
||||||
std::cerr<< "Failed to initialize default audio device, sound disabled" <<std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue