Audio: Final fixes

This commit is contained in:
Lynix
2022-03-19 12:16:52 +01:00
parent 82641c6653
commit 45f0825a6e
4 changed files with 70 additions and 15 deletions

View File

@@ -38,8 +38,16 @@ namespace Nz
m_hasDummyDevice(config.allowDummyDevice)
{
// Load OpenAL
if (!config.noAudio && !s_openalLibrary.Load())
throw std::runtime_error("failed to load OpenAL");
if (!config.noAudio)
{
if (!s_openalLibrary.Load())
{
if (!config.allowDummyDevice)
throw std::runtime_error("failed to load OpenAL");
NazaraError("failed to load OpenAL");
}
}
// Loaders
m_soundBufferLoader.RegisterLoader(Loaders::GetSoundBufferLoader_drwav());
@@ -52,8 +60,21 @@ namespace Nz
m_soundStreamLoader.RegisterLoader(Loaders::GetSoundStreamLoader_minimp3());
if (s_openalLibrary.IsLoaded())
m_defaultDevice = s_openalLibrary.OpenDevice();
else
{
try
{
m_defaultDevice = s_openalLibrary.OpenDevice();
}
catch (const std::exception& e)
{
if (!config.allowDummyDevice)
throw;
NazaraError(std::string("failed to open default OpenAL device: ") + e.what());
}
}
if (!m_defaultDevice)
m_defaultDevice = std::make_shared<DummyAudioDevice>();
}