Alsa - how can I tell my default audio output is card 2 and device 0, not hdmi?
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:
- run
alsamixer
;- use F6 and research available sound devices
- set correct levels for playing on devices;
- run some sound player that allow select sound devices (
audacious
for example);- play with you sound devices (with repeating steps 2,3) and decide what should be default;
- exit
alsamixer
and player;- login as root;
- run
lsmod | grep snd
and try to understood what modules corresponds to physical sound devices;- 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.- 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.- go to
/etc/modprobe.d
;- create
snd_cards_priorities.conf
;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
- save file;
- restart alsa with
/usr/sbin/alsa force-reload
command;- run
cat /proc/asound/cards
command and check that sound devices are in correct order (device #0 has highest priority);- repeat steps 9, 10 several times and check that sound devices order is not changing;
exit root;
run
alsamixer
and configure you default sound device, exitalsamixer
.- 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.
Related videos on Youtube
peterh
Truthful words are not beautiful; beautiful words are not truthful. (Lao Tze) The Last Question
Updated on September 18, 2022Comments
-
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 over 6 yearsThis worked for me with card 1, but not with PCH, although PCH seems indeed name of card 1.
-
Stéphane Gourichon over 6 yearsBefore modifying
/etc
for global change as root, it can be applied immediately to one specific user by putting said lines in~/.asoundrc
. -
bodo about 3 yearsYou can find the module more easily with
cat /proc/asound/modules
(Cf. superuser.com/a/1013451/149452).