[alsa-devel] Order of device overrides in config files
Hello,
Please in what order are devices specified in alsa conf overriden?
The pcm.!default device is defined in /usr/share/alsa/pulse-alsa.conf. Also, I redefine this device in my .asoundrc. Strace dump shows my .asoundrc is loaded after /usr/share/alsa/pulse-alsa.conf. Yet the default device remains the pulse plugin.
Also, what is the exact meaning of the exclamation mark in the device name?
I very much appreciate any help.
Best regards,
Pavel.
Dne 11.6.2018 v 13:33 Pavel Hofman napsal(a):
Hello,
Please in what order are devices specified in alsa conf overriden?
The pcm.!default device is defined in /usr/share/alsa/pulse-alsa.conf. Also, I redefine this device in my .asoundrc. Strace dump shows my .asoundrc is loaded after /usr/share/alsa/pulse-alsa.conf. Yet the default device remains the pulse plugin.
Also, what is the exact meaning of the exclamation mark in the device name?
It means operation mode 'override':
http://www.alsa-project.org/alsa-doc/alsa-lib/conf.html
By default, the operation mode is 'merge+create'.
Jaroslav
Dne 11.6.2018 v 14:20 Jaroslav Kysela napsal(a):
It means operation mode 'override':
http://www.alsa-project.org/alsa-doc/alsa-lib/conf.html
By default, the operation mode is 'merge+create'.
Hi Jaroslav,
Thank you for the information and the link.
In alsa.conf I see the order of config files which is same as my strace output reveals:
@hooks [ { func load files [ { @func concat strings [ { @func datadir } "/alsa.conf.d/" ] } "/etc/asound.conf" "~/.asoundrc" ] errors false } ]
The default device is overriden in pulse-alsa.conf which is called by hook_func.pulse_load_if_running defined in alsa.conf.d/pulse.conf read BEFORE processing my .asoundrc . Strace shows that reading pulse-alsa.conf occurs AFTER reading .asoundrc . It works as specified :-)
Please would it make sense to call .asoundrc (somehow...) after all the config hooks were processed so that redefining the default device in the user's config actually works? Many users get confused by this behavior as it is not really obvious. No matter what they list in their .asoundrc (correctly following alsa documentation), the default device always ends up to be the pulse plugin.
Thanks a lot for your time and opinion.
Best regards,
Pavel.
Dne 11.6.2018 v 15:18 Pavel Hofman napsal(a):
Dne 11.6.2018 v 14:20 Jaroslav Kysela napsal(a):
It means operation mode 'override':
http://www.alsa-project.org/alsa-doc/alsa-lib/conf.html
By default, the operation mode is 'merge+create'.
Hi Jaroslav,
Thank you for the information and the link.
In alsa.conf I see the order of config files which is same as my strace output reveals:
@hooks [ { func load files [ { @func concat strings [ { @func datadir } "/alsa.conf.d/" ] } "/etc/asound.conf" "~/.asoundrc" ] errors false } ]
The default device is overriden in pulse-alsa.conf which is called by hook_func.pulse_load_if_running defined in alsa.conf.d/pulse.conf read BEFORE processing my .asoundrc . Strace shows that reading pulse-alsa.conf occurs AFTER reading .asoundrc . It works as specified :-)
I cannot confirm that - the order specified in the configuration file (files compound/array) is retained on my system (as it should):
open("/usr/share/alsa/alsa.conf", O_RDONLY) = 3 open("/usr/share/alsa/alsa.conf.d/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3 open("/usr/share/alsa/alsa.conf.d//50-pulseaudio.conf", O_RDONLY) = 3 open("/usr/share/alsa/alsa.conf.d//99-pulseaudio-default.conf", O_RDONLY) = 3 open("/etc/asound.conf", O_RDONLY) = 3 open("/home/perex/.asoundrc", O_RDONLY) = 3
The snd_config_hook_load() in src/conf.c function handles that.
Please would it make sense to call .asoundrc (somehow...) after all the config hooks were processed so that redefining the default device in the user's config actually works? Many users get confused by this behavior as it is not really obvious. No matter what they list in their .asoundrc (correctly following alsa documentation), the default device always ends up to be the pulse plugin.
It seems that there's something different in your system, so the ~/.asoundrc file is not parsed as last.
Jaroslav
Dne 11.6.2018 v 15:34 Jaroslav Kysela napsal(a):
Dne 11.6.2018 v 15:18 Pavel Hofman napsal(a):
Dne 11.6.2018 v 14:20 Jaroslav Kysela napsal(a):
It seems that there's something different in your system, so the ~/.asoundrc file is not parsed as last.
Ubuntu 16:04 (Mint 17)
It is parsed by the same order as specified in
@hooks [ { func load files [ { @func concat strings [ { @func datadir } "/alsa.conf.d/" ] } "/etc/asound.conf" "~/.asoundrc" ] errors false } ]
But the last "default" redefinition occurs from usr/share/alsa/pulse-alsa.conf, which is "scheduled" by alsa.conf.d/pulse.conf:
hook_func.pulse_load_if_running { lib "libasound_module_conf_pulse.so" func "conf_pulse_hook_load_if_running" }
@hooks [ { func pulse_load_if_running files [ "/usr/share/alsa/pulse-alsa.conf" ] errors false } ]
According to strace, the function pulse_load_if_running opens /usr/share/alsa/pulse-alsa.conf AFTER ~/.asoundrc:
strace aplay -v -D default /home/hestia/Hudba/192.wav 2>&1 | nl | grep -E '/usr/share/alsa|asoundrc' 88 stat("/usr/share/alsa/alsa.conf", {st_mode=S_IFREG|0644, st_size=9182, ...}) = 0 89 open("/usr/share/alsa/alsa.conf", O_RDONLY) = 3 100 access("/usr/share/alsa/alsa.conf.d/", R_OK) = 0 101 stat("/usr/share/alsa/alsa.conf.d/", {st_mode=S_IFDIR|0755, st_size=123, ...}) = 0 102 openat(AT_FDCWD, "/usr/share/alsa/alsa.conf.d/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 106 open("/usr/share/alsa/alsa.conf.d//50-pulseaudio.conf", O_RDONLY) = 3 114 open("/usr/share/alsa/alsa.conf.d//bluetooth.conf", O_RDONLY) = 3 122 open("/usr/share/alsa/alsa.conf.d//pulse.conf", O_RDONLY) = 3 131 access("/home/hestia/.asoundrc", R_OK) = 0 132 stat("/home/hestia/.asoundrc", {st_mode=S_IFREG|0644, st_size=215, ...}) = 0 133 open("/home/hestia/.asoundrc", O_RDONLY) = 3 540 access("/usr/share/alsa/pulse-alsa.conf", R_OK) = 0 541 stat("/usr/share/alsa/pulse-alsa.conf", {st_mode=S_IFREG|0644, st_size=340, ...}) = 0 542 open("/usr/share/alsa/pulse-alsa.conf", O_RDONLY) = 6
Best regards,
Pavel.
Dne 11.6.2018 v 15:45 Pavel Hofman napsal(a):
Dne 11.6.2018 v 15:34 Jaroslav Kysela napsal(a):
Dne 11.6.2018 v 15:18 Pavel Hofman napsal(a):
Dne 11.6.2018 v 14:20 Jaroslav Kysela napsal(a):
It seems that there's something different in your system, so the ~/.asoundrc file is not parsed as last.
Ubuntu 16:04 (Mint 17)
It is parsed by the same order as specified in
@hooks [ { func load files [ { @func concat strings [ { @func datadir } "/alsa.conf.d/" ] } "/etc/asound.conf" "~/.asoundrc" ] errors false } ]
But the last "default" redefinition occurs from usr/share/alsa/pulse-alsa.conf, which is "scheduled" by alsa.conf.d/pulse.conf:
hook_func.pulse_load_if_running { lib "libasound_module_conf_pulse.so" func "conf_pulse_hook_load_if_running" }
@hooks [ { func pulse_load_if_running files [ "/usr/share/alsa/pulse-alsa.conf" ] errors false } ]
According to strace, the function pulse_load_if_running opens /usr/share/alsa/pulse-alsa.conf AFTER ~/.asoundrc:
strace aplay -v -D default /home/hestia/Hudba/192.wav 2>&1 | nl | grep -E '/usr/share/alsa|asoundrc' 88 stat("/usr/share/alsa/alsa.conf", {st_mode=S_IFREG|0644, st_size=9182, ...}) = 0 89 open("/usr/share/alsa/alsa.conf", O_RDONLY) = 3 100 access("/usr/share/alsa/alsa.conf.d/", R_OK) = 0 101 stat("/usr/share/alsa/alsa.conf.d/", {st_mode=S_IFDIR|0755, st_size=123, ...}) = 0 102 openat(AT_FDCWD, "/usr/share/alsa/alsa.conf.d/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 106 open("/usr/share/alsa/alsa.conf.d//50-pulseaudio.conf", O_RDONLY) = 3 114 open("/usr/share/alsa/alsa.conf.d//bluetooth.conf", O_RDONLY) = 3 122 open("/usr/share/alsa/alsa.conf.d//pulse.conf", O_RDONLY) = 3 131 access("/home/hestia/.asoundrc", R_OK) = 0 132 stat("/home/hestia/.asoundrc", {st_mode=S_IFREG|0644, st_size=215, ...}) = 0 133 open("/home/hestia/.asoundrc", O_RDONLY) = 3 540 access("/usr/share/alsa/pulse-alsa.conf", R_OK) = 0 541 stat("/usr/share/alsa/pulse-alsa.conf", {st_mode=S_IFREG|0644, st_size=340, ...}) = 0 542 open("/usr/share/alsa/pulse-alsa.conf", O_RDONLY) = 6
This configuration comes from Ubuntu (debian). We do not have such config in the upstream (nor Fedora) where we expect to change the pulse configuration file or uninstall the alsa-plugins-pulseaudio package (which contains the default configuration file) when the pulseaudio is not used:
http://git.alsa-project.org/?p=alsa-plugins.git;a=blob;f=pulse/50-pulseaudio... http://git.alsa-project.org/?p=alsa-plugins.git;a=blob;f=pulse/99-pulseaudio...
Unfortunately @hooks from the alsa.conf.d files (or any other files loaded from the @hooks in alsa.conf) are expanded dynamically on request when the 'pcm' definitions are parsed. So yes, pulse-alsa.conf is loaded later than other configuration files in this case.
Jaroslav
Dne 11.6.2018 v 17:19 Jaroslav Kysela napsal(a):
This configuration comes from Ubuntu (debian). We do not have such config in the upstream (nor Fedora) where we expect to change the pulse configuration file or uninstall the alsa-plugins-pulseaudio package (which contains the default configuration file) when the pulseaudio is not used:
http://git.alsa-project.org/?p=alsa-plugins.git;a=blob;f=pulse/50-pulseaudio... http://git.alsa-project.org/?p=alsa-plugins.git;a=blob;f=pulse/99-pulseaudio...
Unfortunately @hooks from the alsa.conf.d files (or any other files loaded from the @hooks in alsa.conf) are expanded dynamically on request when the 'pcm' definitions are parsed. So yes, pulse-alsa.conf is loaded later than other configuration files in this case.
Jaroslav, I very much apprecite your expert advice. Next time I will remove the ubuntu-added configuration to avoid this problem.
Best regards,
Pavel.
participants (2)
-
Jaroslav Kysela
-
Pavel Hofman