Skip to content

Driver

Base class used to create device drivers.

Detailed Description

A driver allows using an audio device to output sounds on speakers and receive data from the microphone.

Public Functions

Type Name
virtual bool Close () = 0
Closes the audio device.
Driver (AmString name)
Creates a new driver with a unique name.
virtual bool EnumerateDevices (std::vector< DeviceDescription > & devices) = 0
Enumerates all the available audio devices.
const DeviceDescription & GetDeviceDescription () const
Gets the description of the device currently managed by this driver.
const AmString & GetName () const
Gets the name of this driver.
virtual bool Open (const DeviceDescription & device) = 0
Open and start using the audio device.
virtual ~Driver ()
Default destructor.

Public Static Functions

Type Name
std::shared_ptr< Driver > Default ()
Choose the most preferred audio driver.
std::shared_ptr< Driver > Find (const AmString & name)
Look up a driver by name.
const std::map< AmString, std::shared_ptr< Driver > > & GetRegistry ()
Gets the list of registered Drivers.
void LockRegistry ()
Locks the drivers' registry.
void Register (std::shared_ptr< Driver > driver)
Registers a new audio driver.
void ResetDefault ()
Resets the default driver setting.
void SetDefault (const AmString & name)
Set the default diver to use in the engine.
void UnlockRegistry ()
Unlocks the drivers' registry.
void Unregister (std::shared_ptr< const Driver > driver)
Unregisters an audio driver.

Protected Attributes

Type Name
DeviceDescription m_deviceDescription
The device description.
AmString m_name
The driver's name.

Public Functions Documentation

Close

Closes the audio device.

virtual bool Amplitude::Driver::Close () = 0

Returns:

true if successful, false otherwise.

Driver

Creates a new driver with a unique name.

explicit Amplitude::Driver::Driver (
    AmString name
) 

Parameters:

  • name The driver's name. Recommended names are "APIName", e.g., "MiniAudio" or "PortAudio" or "SDL", etc...
EnumerateDevices

Enumerates all the available audio devices.

virtual bool Amplitude::Driver::EnumerateDevices (
    std::vector< DeviceDescription > & devices
) = 0

Parameters:

  • devices The vector in which to store the device descriptions.

Returns:

true if successful, false otherwise.

GetDeviceDescription

Gets the description of the device currently managed by this driver.

const DeviceDescription & Amplitude::Driver::GetDeviceDescription () const

Returns:

The device description.

GetName

Gets the name of this driver.

const AmString & Amplitude::Driver::GetName () const

Returns:

The name of this driver.

Open

Open and start using the audio device.

virtual bool Amplitude::Driver::Open (
    const DeviceDescription & device
) = 0

Parameters:

  • device The audio device description to use for initializing the physical device.

Returns:

true if successful, false otherwise.

~Driver

Default destructor.

virtual Amplitude::Driver::~Driver () 

Public Static Functions Documentation

Default

Choose the most preferred audio driver.

static std::shared_ptr< Driver > Amplitude::Driver::Default () 

This method will return the driver instance corresponding to the name provided in the loaded engine configuration. Read this page to learn more.

Returns:

The default audio driver.

Find

Look up a driver by name.

static std::shared_ptr< Driver > Amplitude::Driver::Find (
    const AmString & name
) 

Parameters:

  • name The name of the audio driver. Must be registered before.

Returns:

The audio driver with the given name, or nullptr if not found.

GetRegistry

Gets the list of registered Drivers.

static const std::map< AmString, std::shared_ptr< Driver > > & Amplitude::Driver::GetRegistry () 

Returns:

The registry of Drivers.

LockRegistry

Locks the drivers' registry.

static void Amplitude::Driver::LockRegistry () 

Warning:

This function is mainly used for internal purposes. It's called before the Engine initialization, to discard the registration of new divers after the engine is fully loaded.

Register

Registers a new audio driver.

static void Amplitude::Driver::Register (
    std::shared_ptr< Driver > driver
) 

Note:

This method does nothing if the registry is locked.

Parameters:

  • driver The audio driver to add in the registry.

See also: LockRegistry, UnlockRegistry

ResetDefault

Resets the default driver setting.

static void Amplitude::Driver::ResetDefault () 

After calling this method, Default() will return the last registered driver instead of a specifically set default.

SetDefault

Set the default diver to use in the engine.

static void Amplitude::Driver::SetDefault (
    const AmString & name
) 

This method will overwrite the default driver set from the loaded engine configuration.

Parameters:

  • name The name of the audio driver. Must be registered before.
UnlockRegistry

Unlocks the drivers' registry.

static void Amplitude::Driver::UnlockRegistry () 

Warning:

This function is mainly used for internal purposes. It's called after the Engine deinitialization, to allow the registration of new divers after the engine is fully unloaded.

Unregister

Unregisters an audio driver.

static void Amplitude::Driver::Unregister (
    std::shared_ptr< const Driver > driver
) 

Note:

This method does nothing if the registry is locked.

Parameters:

  • driver The audio driver to remove from the registry.

See also: LockRegistry, UnlockRegistry

Protected Attributes Documentation

m_deviceDescription

The device description.

DeviceDescription SparkyStudios::Audio::Amplitude::Driver::m_deviceDescription;
m_name

The driver's name.

AmString SparkyStudios::Audio::Amplitude::Driver::m_name;

The documentation for this class was generated from the following file: include/SparkyStudios/Audio/Amplitude/Core/Driver.h