Get the list of available audio devices in Linux
I want to get the list of all audio devices that are available on my Linux system. Then I will show this list into a combo box from which user will select the device to use for recording/playback. Based on the user’s selection, I will then construct QAudioInput [doc.qt.nokia.com] and QAudioOutput [doc.qt.nokia.com] for recording/playback.
According to the Qt documentation, this can be done using QAudioDeviceInfo::availableDevices [doc.qt.nokia.com] static method. This method returns a list of all the available audio devices in my system.
I have used this method to list the number of audio devices. This method should have returned a list containing only two elements since my system has two sound cards installed in it (one is in motherboard, another one is a USB device). But it returned a list containing 23 items. When I accessed their names, I got something like below –
The reason behind this is probably the ALSA API [alsa-project.org] that is being used in the back-end. According to this article [home.roadrunner.com] ALSA logically partitions a sound card into multiple logical audio devices, which is being fetched by the Qt API when it queries the driver.
I don’t want to list all these names for the user to choose from. I want to list something like –
from which users will then choose their desired sound card..
Is there any way this can be done using Qt?