|
utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
|
Central manager responsible for OpenAL initialization and audio resource management. More...
#include <headers/utility/sound/audio_manager.hpp>


Public Member Functions | |
| AudioManager () | |
| Creates and initializes the audio subsystem. | |
| ~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. | |
| void | stop () |
| Requests termination of the audio thread. | |
| bool | isRunning () const |
| Indicates whether the audio manager is running. | |
Additional Inherited Members | |
Protected Member Functions inherited from utility::logging::Loggable< AudioManager, utility::logging::DefaultLogger > | |
| Loggable (void) | |
| Construct a Loggable with the specified LoggerType. | |
| Loggable (Loggable &&other) noexcept | |
| Move constructor for Loggable. | |
| Loggable & | operator= (Loggable &&other) noexcept |
| Move assignment operator for Loggable. | |
| LoggerType & | getLogger (void) |
| Get the internal logger. | |
| LoggerType & | getLogger (void) const |
| Get the internal logger. | |
| virtual | ~Loggable (void)=default |
| Virtual destructor for proper cleanup. | |
Central manager responsible for OpenAL initialization and audio resource management.
AudioManager owns the OpenAL device and context and executes all OpenAL operations on a dedicated audio thread.
AudioSource instances communicate with the manager by submitting AudioCommand objects through a thread-safe command queue.
This class is responsible for:
Definition at line 161 of file audio_manager.hpp.
| utility::sound::AudioManager::AudioManager | ( | ) |
Creates and initializes the audio subsystem.
This constructor opens the default OpenAL device, creates an audio context, and starts the dedicated audio processing thread.
If the audio device or context cannot be created, the manager degrades gracefully: audio is disabled (isRunning() returns false) and no exception is thrown, so callers can continue without audio.
Definition at line 24 of file audio_manager.cpp.

| utility::sound::AudioManager::~AudioManager | ( | ) |
Stops the audio thread and releases OpenAL resources.
This destructor waits for the audio thread to terminate, destroys the OpenAL context, and closes the audio device.
Definition at line 49 of file audio_manager.cpp.
| std::unique_ptr< utility::sound::AudioSource > utility::sound::AudioManager::createAudioSource | ( | std::shared_ptr< AudioBuffer > | buffer | ) |
Creates a new audio source.
The corresponding OpenAL source object is created asynchronously on the audio thread.
| buffer | Initial audio buffer assigned to the source. |
Definition at line 69 of file audio_manager.cpp.
| void utility::sound::AudioManager::destroyAudioSource | ( | uint32_t | sourceID | ) |
Destroys an existing audio source.
| sourceID | Identifier of the source to destroy. |
Definition at line 90 of file audio_manager.cpp.
| bool utility::sound::AudioManager::isRunning | ( | ) | const |
Indicates whether the audio manager is running.
Definition at line 114 of file audio_manager.cpp.
| void utility::sound::AudioManager::stop | ( | ) |
Requests termination of the audio thread.
Definition at line 108 of file audio_manager.cpp.
| void utility::sound::AudioManager::submitCommand | ( | const AudioCommand & | command | ) |
Submits an audio command for asynchronous execution.
Commands are stored in a thread-safe queue and processed by the audio thread.
| command | The command to enqueue. |
Definition at line 62 of file audio_manager.cpp.