29 #include "nomlib/audio/AL/AudioDevice.hpp"
34 void AL_FreeAudioDevice ( ALCdevice* dev )
36 NOM_LOG_TRACE ( NOM );
40 alcCloseDevice ( dev );
44 void AL_FreeAudioContext ( ALCcontext* ctx )
46 NOM_LOG_TRACE ( NOM );
51 alcMakeContextCurrent (
nullptr );
54 alcDestroyContext ( ctx );
70 initialize (
nullptr );
76 initialize ( device_name.c_str() );
79 AudioDevice::~AudioDevice (
void )
81 NOM_LOG_TRACE ( NOM );
84 bool AudioDevice::initialize (
const ALCchar* device_name )
86 NOM_LOG_TRACE ( NOM );
92 this->
audio_device = std::shared_ptr<ALCdevice> ( alcOpenDevice ( device_name ), nom::priv::AL_FreeAudioDevice );
98 this->device_name = alcGetString ( this->
audio_device.get(), ALC_DEFAULT_DEVICE_SPECIFIER );
100 this->
audio_context = std::shared_ptr<ALCcontext> ( alcCreateContext ( this->
audio_device.get(), nullptr ), nom::priv::AL_FreeAudioContext );
102 if ( this->audio_context )
104 alcMakeContextCurrent ( this->audio_context.get() );
108 NOM_LOG_ERR ( NOM,
"Failed to create the audio context." );
114 NOM_LOG_ERR ( NOM,
"Failed to open the audio device." );
143 if ( ( extension.length() > 2 ) && ( extension.substr ( 0, 3 ) ==
"ALC" ) )
145 if ( alcIsExtensionPresent ( this->
audio_device.get(), extension.c_str() ) != AL_FALSE )
150 if ( alIsExtensionPresent ( extension.c_str() ) != AL_FALSE )
const std::string getDeviceName(void) const
Obtain the initialized audio device name.
bool initialized(void) const
...
AudioDevice(void)
Default constructor for initializing the default audio device.
static bool audio_initialized
std::shared_ptr< ALCdevice > getAudioDevice(void) const
Obtain the initialized OpenAL audio device.
std::shared_ptr< ALCcontext > audio_context
Audio device context.
bool isExtensionSupported(const std::string &extension) const
Obtain support info regarding a particular extension.
const ALCchar * device_name
device name
std::shared_ptr< ALCdevice > audio_device
Audio device handle.