I have a Pi 2 with an attached USB sound card. I'd like sound through both of them at the same time.
I can make it work by creating a new Alsa definition and then adding that definition to Pulseaudio.
The problem is that I can only use the newly defined Pulse device when (a) I manually define it via pactl (b) restart kodi using "pkill -9 kodi.bin"
/storage/.config/asound.conf is as follows
# Define pihdmi as a destination (for our duplication)
pcm.pihdmi {
type hw
card 0
device 1
}
ctl.pihdmi {
type hw
card 0
device 1
}
#
# Define usbcm106 as a destination (for our duplication)
pcm.usbcm106 {
type hw
card 1
device 0
}
ctl.usbcm106 {
type hw
card 1
device 0
}
#
pcm.usbmulti {
type multi
slaves.a.pcm "pihdmi"
slaves.b.pcm "usbcm106"
slaves.a.channels 2
slaves.b.channels 2
bindings.0.slave a
bindings.0.channel 0 # bind alsa channel 0 to front left
bindings.1.slave a
bindings.1.channel 1 # bind alsa channel 1 to front right
bindings.2.slave b
bindings.2.channel 0 # bind alsa channel 2 to front left
bindings.3.slave b
bindings.3.channel 1 # bind alsa channel 3 to front right
}
#
pcm.usbcopy {
type route
slave.pcm "usbmulti"
slave.channels 4
# syntax for ttable is "ttable.inputchannel.outputchannel volume"
# First send info to Slave A (HDMI = 2 channel)
ttable.0.0 1 # Copy input channel 0 to output channel 0 ie. Slave A channel 0 at 100% volume
ttable.1.1 1
# Now send info to Slave B (usbcm106 = 6 channel)
ttable.0.2 1 # Copy input channel 0 (front left) to output channel 2 ie. Slave B channel 0 (front left) at 100% volume
ttable.1.3 1 # Copy input channel 1 (front left) to output channel 3 ie. Slave B channel 1 (front right) at 100% volume
}
#
pcm.usbboth {
type plug
slave.pcm "usbcopy"
hint {
show on
description "Multichannel output to both usb device and hdmi"
}
}
Display More
Then I define the Pulseaudio elements in /storage/.conf/autostart.sh
# Set devices for Pulseaudio
pactl load-module module-alsa-sink device=hw:0,1 channels=2
pactl load-module module-alsa-sink device=hw:1,0 channels=2
pactl load-module module-combine-sink slaves=alsa_output.hw_0_1,alsa_output.hw_1_0
pactl load-module module-alsa-sink device=plug:usbboth
Sadly the final load of "usbboth" doesn't do anything.
On the other hand if I log in via ssh and then issue
pactl load-module module-alsa-sink device=plug:usbboth
pkill -9 kodi.bin
When kodi restarts (auto-magically) I can now select a new audio device. The ALSA:bcm2836 ALSA, bcm2835 IEC958/HDMI device actually sends sound to both the PI built in HDMI and the USB card (furthermore passthrough to both seems to work too, an unexpected bonus)
PROBLEM: How can I automate this so the Pulseaudio device is loaded/created at boot time ???
Is this a sequencing problem, or is there something else occurring ?
Note that combine-sink is created successfully at boot time and can be used by Kodi. The problem with the combined sink is that it induces so much audio delay that it's basically unuseable (unpleasant anyway
Any help gratefully appreciated