26#include <unordered_map>
34#include "utility/sound/audio_source.hpp"
36#include "utility/math/vector.hpp"
41namespace utility::sound
53 enum class AudioCommandType {
163 utility::logging::DefaultLogger>
206 std::unique_ptr<AudioSource>
243 void processCommands();
255 ALCdevice *_device =
nullptr;
260 ALCcontext *_context =
nullptr;
265 std::unordered_map<uint32_t, ALuint> _sources;
270 std::deque<AudioCommand> _commandQueue;
275 std::mutex _commandQueueMutex;
280 std::thread _audioThread;
285 std::mutex _sourcesMutex;
290 uint32_t _nextSourceID = 1;
298 std::atomic<bool> _running {
true };
300 using Loggable::getLogger;
Mixin base class providing logging capabilities to derived classes.
3D vector class inheriting from glm::vec3.
Central manager responsible for OpenAL initialization and audio resource management.
bool isRunning() const
Indicates whether the audio manager is running.
AudioManager()
Creates and initializes the audio subsystem.
void stop()
Requests termination of the audio thread.
~AudioManager()
Stops the audio thread and releases OpenAL resources.
void submitCommand(const AudioCommand &command)
Submits an audio command for asynchronous execution.
std::unique_ptr< AudioSource > createAudioSource(std::shared_ptr< AudioBuffer > buffer)
Creates a new audio source.
void destroyAudioSource(uint32_t sourceID)
Destroys an existing audio source.
Platform-specific default logger alias.
Mixin class to provide logging capabilities to derived classes.
Represents a command submitted to the audio thread.
CommandData data
Command-specific payload.
uint32_t sourceID
Identifier of the target audio source.
AudioCommandType type
Type of operation to execute.
Payload associated with an AudioCommand.
float gain
Gain multiplier applied to the source.
math::Vector3F position
New world-space position of the audio source.
float pitch
Playback pitch multiplier.
ALuint bufferID
OpenAL buffer identifier.
bool looping
Indicates whether playback should loop.