Alsa - how can I tell my default audio output is card 2 and device 0, not hdmi?

56,923

Solution 1

If you find that your sound cards keep switching indices, you won't be able to hardcode defaults.pcm.card 2 in /etc/asound.conf. One (complex) approach might work, is to configure the sound kernel modules with your desired priority.

This approach is described in Debian Bug #614113:

  1. run alsamixer;
  2. use F6 and research available sound devices
  3. set correct levels for playing on devices;
  4. run some sound player that allow select sound devices (audacious for example);
  5. play with you sound devices (with repeating steps 2,3) and decide what should be default;
  6. exit alsamixer and player;
  7. login as root;
  8. run lsmod | grep snd and try to understood what modules corresponds to physical sound devices;
  9. if unsure that you correctly determine modules on step 2: go to /sys/module and inspect all directories wich names begins with "snd". This directories names exactly as modules. If you will see "drivers" directory in inspected directory - then name of inspected directory is name of module that corresponds to physical sound device. Remember (wrote in notepad) all such modules.
  10. run modinfo <module name> | grep desc for each module that yo found at steps 2 and 3. Read descriptions and make decidion about priorities of this modules. This will be priorities of corresponding sound devices.
  11. go to /etc/modprobe.d;
  12. create snd_cards_priorities.conf;
  13. write to snd_cards_priorities.conf something like this:

    alias snd-card-0 <module for highest priority card>
    options <module for highest priority card> index=0
    alias snd-card-1 <module for lower priority card>
    options <module for lower priority card> index=1
    
  14. save file;
  15. restart alsa with /usr/sbin/alsa force-reload command;
  16. run cat /proc/asound/cards command and check that sound devices are in correct order (device #0 has highest priority);
  17. repeat steps 9, 10 several times and check that sound devices order is not changing;
  18. exit root;

  19. run alsamixer and configure you default sound device, exit alsamixer.

  20. use you favorite sound player to test you new configuration.

Solution 2

To set the default device, you should not redefine the default device but simply put the following into /etc/asound.conf:

defaults.pcm.card 2      # or better "PCH"
defaults.pcm.device 0

This will work only for programs that actually use a default device without explicitly specifying a device. If some program like PulseAudio or VLC has been configured for some specific output device, you must change that configuration.

Share:
56,923

Related videos on Youtube

peterh
Author by

peterh

Truthful words are not beautiful; beautiful words are not truthful. (Lao Tze) The Last Question

Updated on September 18, 2022

Comments

  • peterh
    peterh over 1 year

    How can I tell my system default sound output is card 2 and device 0, and not card 2 device 3 or 7 or 1?

    I did this, but no sound.

    $ aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: Device [C-Media USB Audio Device], device 0: USB Audio [USB Audio]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 2: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 2: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 2: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 2: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
      Subdevices: 0/1
      Subdevice #0: subdevice #0
    
    $ cat /etc/asound.conf
    #pcm.!default { 
    #  type plug; 
    #  slave { pcm "hw:2" } 
    #} 
    pcm.!default {
        type hw
        card 2
        device 0
    }
    
  • Stéphane Gourichon
    Stéphane Gourichon over 6 years
    This worked for me with card 1, but not with PCH, although PCH seems indeed name of card 1.
  • Stéphane Gourichon
    Stéphane Gourichon over 6 years
    Before modifying /etc for global change as root, it can be applied immediately to one specific user by putting said lines in ~/.asoundrc.
  • bodo
    bodo about 3 years
    You can find the module more easily with cat /proc/asound/modules (Cf. superuser.com/a/1013451/149452).