Audio: Add dummy device (in case OpenAL fails to load) and unifiate unit tests

This commit is contained in:
Jérôme Leclercq
2022-03-18 19:03:57 +01:00
parent efa2c0a253
commit 82641c6653
30 changed files with 809 additions and 107 deletions

View File

@@ -4,6 +4,7 @@
#include <Nazara/Audio/OpenALLibrary.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/ErrorFlags.hpp>
#include <Nazara/Core/Log.hpp>
@@ -20,6 +21,8 @@ namespace Nz
{
Unload();
CallOnExit unloadOnFailure([this] { Unload(); });
#if defined(NAZARA_PLATFORM_WINDOWS)
std::array libs{
"soft_oal.dll",
@@ -69,15 +72,21 @@ namespace Nz
continue;
}
unloadOnFailure.Reset();
return true;
}
m_hasCaptureSupport = alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE");
NazaraError("failed to load OpenAL library");
return false;
}
std::vector<std::string> OpenALLibrary::QueryInputDevices()
{
if (!m_hasCaptureSupport)
return {};
return ParseDevices(alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER));
}