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.
Returns:
true if successful, false otherwise.
Driver
Creates a new driver with a unique name.
Parameters:
-
nameThe driver's name. Recommended names are "APIName", e.g., "MiniAudio" or "PortAudio" or "SDL", etc...
EnumerateDevices
Enumerates all the available audio devices.
Parameters:
-
devicesThe 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.
Returns:
The device description.
GetName
Gets the name of this driver.
Returns:
The name of this driver.
Open
Open and start using the audio device.
Parameters:
-
deviceThe audio device description to use for initializing the physical device.
Returns:
true if successful, false otherwise.
Public Static Functions Documentation¶
Default
Choose the most preferred audio driver.
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.
Parameters:
-
nameThe 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.
Returns:
The registry of Drivers.
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.
Register
Registers a new audio driver.
Note:
This method does nothing if the registry is locked.
Parameters:
-
driverThe audio driver to add in the registry.
See also: LockRegistry, UnlockRegistry
ResetDefault
Resets the default driver setting.
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.
This method will overwrite the default driver set from the loaded engine configuration.
Parameters:
-
nameThe name of the audio driver. Must be registered before.
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
Unregisters an audio driver.
Note:
This method does nothing if the registry is locked.
Parameters:
-
driverThe audio driver to remove from the registry.
See also: LockRegistry, UnlockRegistry
Protected Attributes Documentation¶
m_deviceDescription
The device description.
The documentation for this class was generated from the following file: include/SparkyStudios/Audio/Amplitude/Core/Driver.h