Functions | |
std::vector< std::string > | getAvailableDevices () |
Get a list of the names of all available audio playback devices. | |
std::optional< std::string > | getDefaultDevice () |
Get the name of the default audio playback device. | |
bool | setDevice (const std::string &name) |
Set the audio playback device. | |
std::optional< std::string > | getDevice () |
Get the name of the current audio playback device. | |
Function Documentation
◆ getAvailableDevices()
|
nodiscard |
Get a list of the names of all available audio playback devices.
This function returns a vector of strings containing the names of all available audio playback devices.
If the operating system reports multiple devices with the same name, a number will be appended to the name of all subsequent devices to distinguish them from each other. This guarantees that every entry returned by this function will represent a unique device.
For example, if the operating system reports multiple devices with the name "Sound Card", the entries returned would be:
The default device, if one is marked as such, will be placed at the beginning of the vector.
If no devices are available, this function will return an empty vector.
- Returns
- A vector of strings containing the device names or an empty vector if no devices are available
◆ getDefaultDevice()
|
nodiscard |
Get the name of the default audio playback device.
This function returns the name of the default audio playback device. If none is available, an empty string is returned.
- Returns
- The name of the default audio playback device
◆ getDevice()
|
nodiscard |
Get the name of the current audio playback device.
- Returns
- The name of the current audio playback device or
std::nullopt
if there is none
◆ setDevice()
|
nodiscard |
Set the audio playback device.
This function sets the audio playback device to the device with the given name
. It can be called on the fly (i.e: while sounds are playing).
If there are sounds playing when the audio playback device is switched, the sounds will continue playing uninterrupted on the new audio playback device.
- Parameters
-
name The name of the audio playback device
- Returns
true
, if it was able to set the requested device
- See also
getAvailableDevices
,getDefaultDevice