Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get the list of available audio devices in Linux

Get the list of available audio devices in Linux

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 4.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sayem.bd
    wrote on last edited by
    #1

    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":http://doc.qt.nokia.com/4.7/qaudioinput.html and "QAudioOutput":http://doc.qt.nokia.com/4.7/qaudiooutput.html for recording/playback.

    According to the Qt documentation, this can be done using "QAudioDeviceInfo::availableDevices":http://doc.qt.nokia.com/4.7/qaudiodeviceinfo.html#availableDevices 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 -

    bq. default
    pulse
    front:CARD=Intel,DEV=0
    surround40:CARD=Intel,DEV=0
    surround41:CARD=Intel,DEV=0
    surround50:CARD=Intel,DEV=0
    surround51:CARD=Intel,DEV=0
    surround71:CARD=Intel,DEV=0
    dmix:CARD=Intel,DEV=0
    dsnoop:CARD=Intel,DEV=0
    hw:CARD=Intel,DEV=0
    plughw:CARD=Intel,DEV=0
    front:CARD=default,DEV=0
    surround40:CARD=default,DEV=0
    surround41:CARD=default,DEV=0
    surround50:CARD=default,DEV=0
    surround51:CARD=default,DEV=0
    surround71:CARD=default,DEV=0
    iec958:CARD=default,DEV=0
    dmix:CARD=default,DEV=0
    dsnoop:CARD=default,DEV=0
    hw:CARD=default,DEV=0
    plughw:CARD=default,DEV=0

    The reason behind this is probably the "ALSA API":http://www.alsa-project.org/main/index.php/Main_Page that is being used in the back-end. According to "this article":http://home.roadrunner.com/~jgglatt/tech/linuxapi.htm 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 -

    bq. HDA-Intel
    USB-Audio

    from which users will then choose their desired sound card..

    Is there any way this can be done using Qt?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RazrFalcon
      wrote on last edited by
      #2

      I don't know about Qt (I think no), but you always can use QProcess and the following command:
      @cat /proc/asound/cards@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved