It's best to use card names instead of numbers as the latter may change (eg if you plug in a USB audio card).
Simply run "aplay -L", that will show you the available PCMs with card names - then use the same PCM as you used in kodi. eg here on RPi4 it looks like this:
...
hdmi:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM vc4-hdmi-hifi-0
HDMI Audio Output
...
"hdmi:CARD=vc4hdmi0,DEV=0" is what you use as pcm and the name after CARD= (vc4hdmi0 in my case) is your card - on intel you'll have multiple devices (DEV=...), one for each HDMI output.
You can then create .config/asound.conf like this (adapt to your PCM/card):
pcm.myoutput {
type softvol
slave {
pcm "hdmi:CARD=vc4hdmi0,DEV=0"
}
control {
name "PCM My Volume"
card "vc4hdmi0"
}
hint.description "My Output with softvol"
}
Display More
This creates a new pcm "myoutput" with a control named "PCM My Volume". The hint is only there so you can check with "aplay -L" if your new PCM is available. It should look like this:
LibreELEC:~ # aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default
Default Audio Device
sysdefault
Default Audio Device
myoutput
My Output with softvol
...
A small gotcha is that the new mixer control will only show up after the device has been used once, so to see the new volume control you'll have to first access it. eg:
speaker-test -c 2 -t sine -D myoutput
Then you should see the new mixer in amixer output:
LibreELEC:~ # amixer controls
numid=6,iface=MIXER,name='PCM My Volume'
numid=5,iface=MIXER,name='PCM Playback Volume'
numid=2,iface=MIXER,name='IEC958 Playback Default'
numid=3,iface=MIXER,name='IEC958 Playback Mask'
numid=1,iface=PCM,name='ELD'
numid=4,iface=PCM,name='Playback Channel Map'
In alsamixer and "amixer scontrols" it will show as "PCM My", as it automatically strips "Volume" from the end.
so long,
Hias