Gorgon Game Engine
Device Class Reference

Represents an audio device. More...

Public Member Functions

 Device ()=default
 
 Device (const std::string &id, const std::string &name, int rate, Format format, bool headphones, const std::vector< Channel > &channels)
 
int FindChannel (Channel type) const
 Returns the index of the given type of channel. If that channel type does not exists, -1 is returned. More...
 
Channel GetChannel (int index) const
 Returns the channel type with the given index. More...
 
int GetChannelCount () const
 Returns the number of channels available. More...
 
Format GetFormat () const
 Returns the format of this device. More...
 
std::string GetID () const
 Returns the ID of this device. More...
 
std::string GetName () const
 Returns the readable name of this device. More...
 
int GetSampleRate () const
 Returns number of samples per second. More...
 
bool IsHeadphones () const
 Returns if this device is connected to headphones. More...
 
bool IsValid () const
 Returns if this is a valid device. More...
 

Static Public Member Functions

static Device Default ()
 Returns the default device of the current system. More...
 
static const std::vector< Device > & Devices ()
 Returns the devices in the current system. More...
 
static Device Find (const std::string &id)
 Name based device lookup. More...
 
static void Refresh ()
 Refreshes the list of audio devices. Calling this function triggers ChangedEvent. More...
 

Static Public Attributes

static Event ChangedEvent
 Triggers when the audio device configuration is changed. More...
 

Detailed Description

Represents an audio device.

Constructor & Destructor Documentation

◆ Device() [1/2]

Device ( )
default

◆ Device() [2/2]

Device ( const std::string &  id,
const std::string &  name,
int  rate,
Format  format,
bool  headphones,
const std::vector< Channel > &  channels 
)

Member Function Documentation

◆ Default()

static Device Default ( )
static

Returns the default device of the current system.

◆ Devices()

static const std::vector<Device>& Devices ( )
static

Returns the devices in the current system.

◆ Find()

static Device Find ( const std::string &  id)
static

Name based device lookup.

Fires std::runtime_error if the given device cannot be found.

◆ FindChannel()

int FindChannel ( Channel  type) const

Returns the index of the given type of channel. If that channel type does not exists, -1 is returned.

◆ GetChannel()

Channel GetChannel ( int  index) const

Returns the channel type with the given index.

◆ GetChannelCount()

int GetChannelCount ( ) const

Returns the number of channels available.

◆ GetFormat()

Format GetFormat ( ) const

Returns the format of this device.

In some cases, this format might be different than the actual device format.

◆ GetID()

std::string GetID ( ) const

Returns the ID of this device.

◆ GetName()

std::string GetName ( ) const

Returns the readable name of this device.

◆ GetSampleRate()

int GetSampleRate ( ) const

Returns number of samples per second.

◆ IsHeadphones()

bool IsHeadphones ( ) const

Returns if this device is connected to headphones.

◆ IsValid()

bool IsValid ( ) const

Returns if this is a valid device.

◆ Refresh()

static void Refresh ( )
static

Refreshes the list of audio devices. Calling this function triggers ChangedEvent.

Member Data Documentation

◆ ChangedEvent

Event ChangedEvent
static

Triggers when the audio device configuration is changed.

Depending on the operating system this event might be unavailable. When this even is triggered, current audio configuration must be checked but should not be recreated unless there is a change.


The documentation for this class was generated from the following files: