alsa-utils icon indicating copy to clipboard operation
alsa-utils copied to clipboard

alsaloop: link existing mixer controls

Open bravl opened this issue 5 months ago • 0 comments

Hi,

I'm trying to link the volume controls of 2 soundcards together. We've got 2 souncards, an UAC2Gadget card and a custom soundcard. We use alsaloop to create the following setup:

UAC2Gadget record -> alsaloop -> Custom soundcard speaker out
Custom soundcard mic in -> alsaloop -> UAC2Gadget soundcard playback

For this the alsaloop.conf looks like

-P hw:CARD=customsoundcard,DEV=0 -C hw:CARD=UAC2Gadget,DEV=0 -S 5 -T 1"                                                          
-C hw:CARD=customsoundcard,DEV=1 -P hw:CARD=UAC2Gadget,DEV=0 -S 5 -T 2                                                                                                               

This setup works perfectly. But we would like to control the volume of the custom soundcard's speaker out via the UAC2Gadgets' PCM Record volume.

The cards expose the following controls:

$ amixer -c1 controls #custom soundcard
numid=1,iface=MIXER,name='Master Volume'
numid=2,iface=MIXER,name='Speaker Volume'

$ amixer -c2 controls #UAC2Gadget
numid=3,iface=MIXER,name='PCM Playback Switch'
numid=4,iface=MIXER,name='PCM Playback Volume'
numid=6,iface=MIXER,name='PCM Capture Switch'
numid=7,iface=MIXER,name='PCM Capture Volume'
numid=1,iface=PCM,name='Capture Pitch 1000000'
numid=8,iface=PCM,name='Capture Rate'
numid=2,iface=PCM,name='Playback Pitch 1000000'
numid=5,iface=PCM,name='Playback Rate'

Adding -m "name=Speaker Volume" creates a new linked control to the UAC2Gadget card called "Speaker Volume" as expected. Adding -m "name=Speaker Volume"@name="PCM Capture Volume" does not work. Resulting in:

Unable to create control '0,MIXER,0,0,PCM Capture Volume,0': Device or resource busy
playback hw:CARD=customsoundcard,DEV=0/capture hw:CARD=UAC2Gadget,DEV=0: Unable to remove control '0,MIXER,0,0,PCM Capture Volume,0': Invalid argument

Looking at the alsaloop code, it seems that this is expected behaviour because it's trying to remove a control which was created by the UAC2Gadget driver.

Is the above conclusion correct or is there a different way to allow alsaloop to sync 2 existing driver controls?

Thanks

bravl avatar Jun 05 '25 14:06 bravl