Closed bku-sue closed 2 years ago
It's already implemented: https://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html (look for pcm_hooks)
I'm not familiar with that method, how would one set the "Mux1" enum control to "IN2" using that syntax?
See the example:
name "Mux1"
value "IN2"
The parser is in src/control/setup.c
.
EDIT: changed slave "hw:0"
to slave.pcm "hw:0"
pcm.selmux {
type hooks
slave.pcm "hw:0"
hooks.0 {
type ctl_elems
hook_args [
{
name "Mux1"
value "IN2"
}
]
}
}
The hooks API looks very promising, but unfortunately I cannot get it to work on my setup, based on alsa-lib 1.1.6 the device is opened but the ctls aren't changed.
My test
Added to ~/.asoundrc (with the slave definition correction):
pcm.selmux1 {
type hooks
slave.pcm "hw:1"
hooks.0 {
type ctl_elems
hook_args [
{
name "Auto-Mute Mode"
value "Enabled"
}
]
}
}
pcm.selmux2 {
type hooks
slave.pcm "hw:1"
hooks.0 {
type ctl_elems
hook_args [
{
name "Auto-Mute Mode"
value "Disabled"
}
]
}
}
Test commands:
aplay -Dplug:selmux1 /dev/zero
aplay -Dplug:selmux2 /dev/zero
Event verification:
amixer -c 1 events
output:
Ready to listen...
Poll ok: 1
event value: numid=5,iface=MIXER,name='Auto-Mute Mode'
event value: numid=5,iface=MIXER,name='Auto-Mute Mode'
Value verification:
amixer -c 1 cget name='Auto-Mute Mode'
output:
numid=5,iface=MIXER,name='Auto-Mute Mode'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'Disabled'
; Item #1 'Enabled'
: values=0
amixer -c 2 cget name='Auto-Mute Mode'
output:
numid=5,iface=MIXER,name='Auto-Mute Mode'
; type=ENUMERATED,access=rw------,values=1,items=2
; Item #0 'Disabled'
; Item #1 'Enabled'
: values=1
Stale. Closing.
The kernel's sound soc subsystem has a DAPM functionality, which makes complex audio routing easy, and most of it is done inside the kernel. However, in the case of dynamic routing (when there is a multiplexer in the signal path), the multiplexer is exposed as an enum MIXER control which must be set from userspace. As the selection of these controls directly influences what audio path is captured/played, the sensible thing to do is to create multiple HW plugins in the ALSA conf, each referring to the same HW device number, but with different routing parameters.