Libreelec 10.0.1 on RPi-4B : Simultanous output to HDMI and Bluetooth Box?

  • Hello all,

    I am trying to get audio output onto HDMI and a Bluetooth box working simultanously.

    This wiki entry suggests that this should be possible with the pulseaudio module-combine-sink

    Unfortunately, I have a hard time to find my audio sinks. The sinks I am interested in are listed by Kodi as:

    Code
    ALSA: Default Audio Device ()
    PULSE: Default, Bluetooth Audio (PULSEAUDIO)

    But neither pactl nor amixer shows me those two devices:

    In addition, I get:

    Code
    kodi-rpi4:~ # pacmd list-cards
    No PulseAudio daemon running, or not running as session daemon.
    kodi-rpi4:~ # export PULSE_RUNTIME_PATH=/run/pulse
    kodi-rpi4:~ # pacmd list-cards
    0 card(s) available.

    Nevertheless, after executing

    Code
    kodi-rpi4:~ # pacmd load-module module-combine-sink sink_name=combined

    a new device appears in Kodi, called

    Code
    PULSE: Simultanous output to Anker SoudCore (PULSEAUDIO)

    When I select this device, my Bluetooth box plays fine. So the module-combine-sink basically seems to work. But how do I find the name of the HDMI sink so that I can add it to the combined sink?

    What's more, all those settings don't change when I change outputs in Kodi.

    https://kodi.wiki/view/PulseAudio says, it is not possible to have ALSA and Pulseaudio at the same time. But Kodi shows me ALSA devices as well as Pulseaudio devices. Can anybody elaborate on this? What is installed by default in a libreelec install on RPi 4B?

    Thanks in Advance!

  • Digging through pulseaudio, I found that

    Code
    pactl module-load module-udev-detect

    should detect alsa devices and make them available to pulseaudio. But for some reason, this command fails to detect those devices:

    Any idea why this command won't find the alsa cards?

    Is there any way to debug pulseaudio?

  • Got it (almost) working now.

    Problem was, that module-udev-detect can be loaded only once at startup. So executing

    Code
    echo "pactl load-module module-udev-detect" >> /storage/.config/autostart.sh

    makes alsa sinks available after reboot.

    After that, executing

    Code
    pactl load-module module-combine-sink slaves=alsa_output.0.hdmi-stereo,bluez_sink.A4_77_58_02_93_FB.a2dp_sink

    on the command line makes the device for simultanous output available to Kodi. Works fine so far.

    Problem is, this last command won't work from autostart.sh to make this simultanous sink available after boot because the bluetooth speaker is not available at boot time.

    Journalctl says:

    Code
    Jan 01 14:18:06 kodi-rpi4 pulseaudio[352]: E: [pulseaudio] module-combine-sink.c: Invalid slave sink 'bluez_sink.A4_77_58_02_93_FB.a2dp_sink'
    Jan 01 14:18:06 kodi-rpi4 pulseaudio[352]: E: [pulseaudio] module.c: Failed to load module "module-combine-sink" (argument: "slaves=alsa_output.0.hdmi-stereo,bluez_sink.A4_77_58_02_93_FB.a2dp_sink"): initialization failed.
    Jan 01 14:18:18 kodi-rpi4 pulseaudio[352]: E: [pulseaudio] module-combine-sink.c: failed to parse module arguments
    Jan 01 14:18:18 kodi-rpi4 pulseaudio[352]: E: [pulseaudio] module.c: Failed to load module "module-combine-sink" (argument: "sink_name=combined alsa_output.0.hdmi-stereo"): initialization failed.

    the bluetooth sink is created only after I switch the bluetooth speaker off and on again.

    So the question now is: is it possible to create the bluetoosh sink even before the connection to the actual device has been made?

  • Try my kodi dualaudio project. I have a LibreELEC Generic PC version compiled. For Raspberry Pi, you can simply get the source code and compile by your own.

    Please visit my project page:

    https://github.com/xhbl/LibreELEC_dualaudio/

    For more information, please refer to the thread I posted here and in Kodi Forum

    xhbl
    November 5, 2022 at 9:15 PM

    [Project] Dual Audio Output support (Matrix/Krypton/Jarvis/Isengard/Helix/Gotham/...)

    Edited once, last by xhbl (November 5, 2022 at 10:58 PM).

  • it works for me

    my /storage/.config/autostart.sh :

    pactl load-module module-udev-detect

    pactl load-module module-combine-sink slaves=alsa_output.0.hdmi-stereo,alsa_output.3.iec958-stereo


    however I have 2 problems

    1) playing video create sometimes echo artifacts (crackling) on hdmi output

    2) playing spotify plugin librespot? causes lagging / pitch during palyback

    Not sure if this is pulseaudio problem or HW is just too weak to send audio to 2 sinks.. (RPi3)

    anyone knows?b

  • Not sure if this is pulseaudio problem or HW is just too weak to send audio to 2 sinks.. (RPi3)


    anyone knows?

    I had almost same "result" when tried to get working the HDMI and DAC sound on my RPi3.

    The "echo" problem you have probably because the hdmi and the bluetooth have different delay in sound processing, I had too when tried to use same setup. Because I didn't need simultaneous audio (HDMI for video, DAC for music/net-radio), I dropped the pulse-audio and using the "Audio profiles" addon. That able to auto switch the audio output for different types of media.

  • Hi,

    Actually my case is same as yours HDMI and DAC (Hifiberry) RPi3..

    The addon is interesting, I will check it out.

    Nevertheless Did I undersand right that you did not solved the pulseaudio issue at all? Or you at least found what causes the "echo"?

    Anybody else had /resolved the same issue?

  • Hi,

    Actually my case is same as yours HDMI and DAC (Hifiberry) RPi3..

    The addon is interesting, I will check it out.

    Nevertheless Did I undersand right that you did not solved the pulseaudio issue at all? Or you at least found what causes the "echo"?

    Anybody else had /resolved the same issue?

    First of all, to be clear, the "Audio Profiles" addon don't have option for simultaneous audio. And if no simultaneous audio... no echo.

    I'm using without pulse-audio, only with the default alsa sound and enabled in the config.txt the hifiberry module. I set the addon to change the sound output to DAC for audio type media (listening music) and to HDMI for video. Also the addon can be set to toggle the sound outputswith a remote button (ex for youtube, never tried...).

    Basically I wanted to be able to listen my favorite internet radio channel using the better quality DAC output, without to be necessary to start the TV, so I reprogrammed a remote button (remote.xml) to start the music, and the addon automatically switch the sound output to DAC. :cool: