Sound - Simultaneous Output - Nearly Working - HELP

  • 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

    Then I define the Pulseaudio elements in /storage/.conf/

    1. # Set devices for Pulseaudio
    2. pactl load-module module-alsa-sink device=hw:0,1 channels=2
    3. pactl load-module module-alsa-sink device=hw:1,0 channels=2
    4. pactl load-module module-combine-sink slaves=alsa_output.hw_0_1,alsa_output.hw_1_0
    5. 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

    1. pactl load-module module-alsa-sink device=plug:usbboth
    2. 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

  • you don't need the asound.conf at all


    1. dtparam=audio=on

    in you config.txt, this will load the rpi alsa module.

    Then you can just use pulseaudio to load the 'udev-detect' module, then make the combined sink

  • Thanks for the response.
    Yes, I have set dtparam=audio=on. Alsa is loaded at boot and the new plugin appears immediately after boot in the list generated by aplay -L ie.

    The challenge is that the key pulse sink can only be created manually after boot. All the others are created successfully during boot as shown by pactl list sinks short ie.

    1. OE-Pi3:~ # pactl list sinks short
    2. 1       alsa_output.hw_0_1      module-alsa-sink.c      s16le 2ch 44100Hz       SUSPENDED
    3. 2       alsa_output.hw_1_0      module-alsa-sink.c      s16le 2ch 44100Hz       SUSPENDED
    4. 3       combined        module-combine-sink.c   s16le 2ch 44100Hz       SUSPENDED
    5. OE-Pi3:~ #

    This is even after (a) the entries above AND (b) creating similar entries in /storage/.config/pulse-daemon.conf.d/99-default.conf ie.

    1. load-module module-alsa-sink device=hw:0,1 channels=2
    2. load-module module-alsa-sink device=hw:1,0 channels=2
    3. load-module module-combine-sink slaves=alsa_output.hw_0_1,alsa_output.hw_1_0
    4. load-module module-alsa-sink device=plug:usbboth

    Once the machine is booted I can successfully manually add the usbboth plugin to Pulse ...

    Problem How do I ensure Pulseaudio recognises and creates the usbboth sink during the boot procedure ?

    Thanks for your advice

  • I'm saying you don't need any of the asound.conf


    1. pactl load-module module-udev-detect
    2. pactl load-module module-compine-sink slaves=alsa_output.platform-soc_audio.analog-stereo,<some-other-alsa-device>
  • yes, thanks. I still need the asound.conf for channel mapping because the 2 device display a different number of channels and I couldn't make that work directly with Pulse combin-sink

    It's working now :)

    here's the final asound.conf

    here's the final

    I needed to

    • Stop pulse and restart it before doing anything else. For whatever reason this makes the process consistent. Then restart pulse manually. Actually not sure I needed to stop it first
    • Stop Kodi just in case. Probably not necessary, but didn't seem to do any harm so I've kept it
    • "sleep" statements to slow the process down before Kodi starts. For some reason it takes Pulse a while to create the combined sink and kodi had been starting in the meantime so it didn't read & recognise the new sink

    Additionally, in Kodi we then set the following in system settings/audio output/ -
    Audio Output Device = "ALSA: bcm2835, bcm2835 IEC958/HDMI"
    Number of Channels = 2
    Enable Passthrough = true
    Passthrough Output Device = "ALSA: USB Sound Device, S/PDIF"
    AC3 Capable = true
    DTS Capable = true

    Try some AC3 and DTS files, plus some stereo.
    Stereo will play through both the TV and the Amp, but AC3 and DTS will only play through the amp (tv limitation)
    We could make everything always play through both by setting Passthrough OFF ... this compromises quality BUT provides greater consistency of experience (WAF ?)

    I've tried a few reboots and the setup seems to consistently provide the same result (not necessarily a given due to timing issues)

    Edited once, last by redger ().