2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2022 DS
|
|
|
|
// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
// Copyright (C) 2011 Sebastian 'Bahamada' Rühl
|
|
|
|
// Copyright (C) 2011 Cyriaque 'Cisoun' Skrapits <cysoun@gmail.com>
|
|
|
|
// Copyright (C) 2011 Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
|
2023-09-28 18:20:53 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-10-09 07:24:44 -07:00
|
|
|
#include <memory>
|
2023-09-28 18:20:53 +02:00
|
|
|
#include "al_helpers.h"
|
|
|
|
|
2023-09-28 18:59:06 +02:00
|
|
|
namespace sound {
|
|
|
|
|
2023-09-28 18:20:53 +02:00
|
|
|
/**
|
|
|
|
* Class for the openal device and context
|
|
|
|
*/
|
|
|
|
class SoundManagerSingleton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct AlcDeviceDeleter {
|
|
|
|
void operator()(ALCdevice *p)
|
|
|
|
{
|
|
|
|
alcCloseDevice(p);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AlcContextDeleter {
|
|
|
|
void operator()(ALCcontext *p)
|
|
|
|
{
|
|
|
|
alcMakeContextCurrent(nullptr);
|
|
|
|
alcDestroyContext(p);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
using unique_ptr_alcdevice = std::unique_ptr<ALCdevice, AlcDeviceDeleter>;
|
|
|
|
using unique_ptr_alccontext = std::unique_ptr<ALCcontext, AlcContextDeleter>;
|
|
|
|
|
|
|
|
unique_ptr_alcdevice m_device;
|
|
|
|
unique_ptr_alccontext m_context;
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool init();
|
|
|
|
|
|
|
|
~SoundManagerSingleton();
|
|
|
|
};
|
2023-09-28 18:59:06 +02:00
|
|
|
|
|
|
|
} // namespace sound
|