All of lore.kernel.org
 help / color / mirror / Atom feed
* Order of device overrides in config files
@ 2018-06-11 11:33 Pavel Hofman
  2018-06-11 12:20 ` Jaroslav Kysela
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Hofman @ 2018-06-11 11:33 UTC (permalink / raw)
  To: alsa-devel

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Order of device overrides in config files
  2018-06-11 11:33 Order of device overrides in config files Pavel Hofman
@ 2018-06-11 12:20 ` Jaroslav Kysela
  2018-06-11 13:18   ` Pavel Hofman
  0 siblings, 1 reply; 7+ messages in thread
From: Jaroslav Kysela @ 2018-06-11 12:20 UTC (permalink / raw)
  To: alsa-devel; +Cc: Pavel Hofman

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

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Order of device overrides in config files
  2018-06-11 12:20 ` Jaroslav Kysela
@ 2018-06-11 13:18   ` Pavel Hofman
  2018-06-11 13:34     ` Jaroslav Kysela
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Hofman @ 2018-06-11 13:18 UTC (permalink / raw)
  To: Jaroslav Kysela, alsa-devel

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Order of device overrides in config files
  2018-06-11 13:18   ` Pavel Hofman
@ 2018-06-11 13:34     ` Jaroslav Kysela
  2018-06-11 13:45       ` Pavel Hofman
  0 siblings, 1 reply; 7+ messages in thread
From: Jaroslav Kysela @ 2018-06-11 13:34 UTC (permalink / raw)
  To: Pavel Hofman, alsa-devel

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

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Order of device overrides in config files
  2018-06-11 13:34     ` Jaroslav Kysela
@ 2018-06-11 13:45       ` Pavel Hofman
  2018-06-11 15:19         ` Jaroslav Kysela
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Hofman @ 2018-06-11 13:45 UTC (permalink / raw)
  To: Jaroslav Kysela, alsa-devel

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Order of device overrides in config files
  2018-06-11 13:45       ` Pavel Hofman
@ 2018-06-11 15:19         ` Jaroslav Kysela
  2018-06-11 15:30           ` Pavel Hofman
  0 siblings, 1 reply; 7+ messages in thread
From: Jaroslav Kysela @ 2018-06-11 15:19 UTC (permalink / raw)
  To: Pavel Hofman, alsa-devel

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.conf
http://git.alsa-project.org/?p=alsa-plugins.git;a=blob;f=pulse/99-pulseaudio-default.conf.example

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


-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Order of device overrides in config files
  2018-06-11 15:19         ` Jaroslav Kysela
@ 2018-06-11 15:30           ` Pavel Hofman
  0 siblings, 0 replies; 7+ messages in thread
From: Pavel Hofman @ 2018-06-11 15:30 UTC (permalink / raw)
  To: Jaroslav Kysela, alsa-devel


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.conf
> http://git.alsa-project.org/?p=alsa-plugins.git;a=blob;f=pulse/99-pulseaudio-default.conf.example
> 
> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-11 15:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11 11:33 Order of device overrides in config files Pavel Hofman
2018-06-11 12:20 ` Jaroslav Kysela
2018-06-11 13:18   ` Pavel Hofman
2018-06-11 13:34     ` Jaroslav Kysela
2018-06-11 13:45       ` Pavel Hofman
2018-06-11 15:19         ` Jaroslav Kysela
2018-06-11 15:30           ` Pavel Hofman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.