Driver¶
class Driver
Base class for audio device driver implementations.
A driver allows to use an audio device to output sounds and receive data from the microphone.
Variables¶
Name | Description |
---|---|
m_name | The driver name. |
m_deviceDescription | The device description. |
Functions¶
Name | Description |
---|---|
Driver | Creates a new AudioDriver with an unique name. |
~Driver | Default destructor. |
Open | Open and start using the audio device. |
Close | Closes the audio device. |
EnumerateDevices | Enumerates all the available audio devices. |
GetName | Gets the name of this driver. |
GetDeviceDescription | Gets the description of the device currently managed by this driver. |
Register | Registers a new audio driver. |
Unregister | Unregisters an audio driver. |
Default | Choose the most preferred audio driver. |
Find | Look up a driver by name. |
SetDefault | Set the default diver to use in the engine. |
LockRegistry | Locks the drivers registry. |
UnlockRegistry | Unlocks the drivers registry. |
Variable Details¶
m_deviceDescription¶
DeviceDescription m_deviceDescription
The device description.
m_name¶
AmString m_name
The driver name.
Function Details¶
Close¶
virtual bool Close() = 0
Closes the audio device.
- Return
true
if successful,false
otherwise.
Default¶
static Driver* Default()
Choose the most preferred audio driver.
- Return
- The default audio driver.
Driver¶
explicit Driver(AmString name)
Creates a new AudioDriver with an unique name.
- Parameter
name
- The driver name. Recommended names are "APIName". eg. "MiniAudio" or "PortAudio" or "SDL", etc...
EnumerateDevices¶
virtual bool EnumerateDevices(std::vector<DeviceDescription>& devices) = 0
Enumerates all the available audio devices.
- Parameter
devices
- The vector in which to store the device descriptions.
- Return
true
if successful,false
otherwise.
Find¶
static Driver* Find(const AmString& name)
Look up a driver by name.
- Parameter
name
- The name of the audio driver. Must be registered before.
- Return
- The audio driver with the given name, or
nullptr
if none.
GetDeviceDescription¶
[[nodiscard]] const DeviceDescription& GetDeviceDescription() const
Gets the description of the device currently managed by this driver.
- Return
- The device description.
GetName¶
[[nodiscard]] const AmString& GetName() const
Gets the name of this driver.
- Return
- The name of this driver.
LockRegistry¶
static void LockRegistry()
Locks the drivers registry.
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.
Open¶
virtual bool Open(const DeviceDescription& device) = 0
Open and start using the audio device.
- Parameter
device
- The audio device to use description to use for initializing the physical device.
- Return
true
if successful,false
otherwise.
Register¶
static void Register(Driver* driver)
Registers a new audio driver.
- Parameter
driver
- The audio driver to add in the registry.
SetDefault¶
static void SetDefault(const AmString& name)
Set the default diver to use in the engine.
- Parameter
name
- The name of the audio driver. Must be registered before.
UnlockRegistry¶
static void UnlockRegistry()
Unlocks the drivers registry.
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¶
static void Unregister(const Driver* driver)
Unregisters an audio driver.
- Parameter
driver
- The audio driver to remove from the registry.
~Driver¶
virtual ~Driver()
Default destructor.