+class SoundManagerSingleton
+{
+public:
+ unique_ptr_alcdevice m_device;
+ unique_ptr_alccontext m_context;
+public:
+ SoundManagerSingleton() :
+ m_device(nullptr, delete_alcdevice),
+ m_context(nullptr, delete_alccontext)
+ {
+ if (!(m_device = unique_ptr_alcdevice(alcOpenDevice(nullptr), delete_alcdevice)))
+ throw std::runtime_error("Audio: Global Initialization: Device Open");
+
+ if (!(m_context = unique_ptr_alccontext(
+ alcCreateContext(m_device.get(), nullptr), delete_alccontext))) {
+ throw std::runtime_error("Audio: Global Initialization: Context Create");
+ }
+
+ if (!alcMakeContextCurrent(m_context.get()))
+ throw std::runtime_error("Audio: Global Initialization: Context Current");
+
+ alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
+
+ if (alGetError() != AL_NO_ERROR)
+ throw std::runtime_error("Audio: Global Initialization: OpenAL Error");
+
+ infostream << "Audio: Global Initialized: OpenAL " << alGetString(AL_VERSION)
+ << ", using " << alcGetString(m_device.get(), ALC_DEVICE_SPECIFIER)
+ << std::endl;
+ }
+
+ ~SoundManagerSingleton()
+ {
+ infostream << "Audio: Global Deinitialized." << std::endl;
+ }
+};
+