Flatpak Multichannel Audio over HDMI

  • I've recently started using the LE13 nighties on an intel NUC. All the HDMI audio works great in Kodi but apps/add-ons running via Flatpak are limited to stereo and i'm trying to use Moonlight with 5.1 surround.

    I've tried tweaking the custom audio device setting in "External programs helper" but i don't think that's where the problem is.

    I've added some Pulseaudio daemon config with "default-sample-channels = 6" which did make it start outputting 5.1 but the channel map is all mixed up with audio coming from the wrong speaker. Changing "default-channel-map" in the same config doesn't help.

    Anyone have any ideas? it would be really good if this could be streamlined / automatically configured based of the Kodi audio output settings in future.

  • Go to Best Answer
  • I know little about pulse audio, but channel placement comes from ELD data which alsa derives from the EDID data on the HDMI connection. It might be worth ensuring (with Kodi stopped else it hogs the audio device) that alsa speaker-test can output 6ch audio correctly.

  • Interesting thanks, speaker-test works correctly, lists the expected channels and the tones play from the expected speaker.

    But when I config the pulseaudio to with "default-sample-channels = 6" i get:

    I know pulse is used for Bluetooth audio and that's limited to stereo, maybe some existing config for is getting in the way.

  • Code
    channel-map = front-left,front-center,front-right,rear-left,rear-right,lfe

    Have you tried something like that ^ in the config? (rearrange the text until things come out right)

    Try default-channel-map as an alternative

  • I tried a "default-channel-map" like you suggested in the daemon config, same place I set "default-sample-channels = 6" but it had no effect.

    Most other suggestions online talk about editing /etc/pulse/default.pa which is read only for us.

  • Ok i made some progress hacking stuff around until it worked.

    I had to add channels=6 to https://github.com/LibreELEC/Libr…run-wrapper#L42 the created sink then has the correct channel count and mapping.

    The next issue was by default it now upmixes stereo output to all the channels, for this the daemon config did work so i created a file as:

    Code: ~/.config/pulse-daemon.conf.d/multi.conf
    enable-remixing = no

    So would be really nice if the flatpak-run-wrapper could be properly updated to honour your Kodi channel count, as for the remixing at least that is already fixable via user config.

  • Might even be best to delegate the channel count config to each flatpak app, because something like VacuumTube only supports stereo and it's nice if that is output at 2 channels to allow the AVR/TV to process it suitably. On the other hand Moonlight works great at 5.1 or 7.1 via 6/8 channels.

  • Thanks for the hint that moonlight can support surround sound output, I've now implemented that and added a setting in the moonlight addon https://github.com/LibreELEC/LibreELEC.tv/pull/11985

    I also noticed that stereo-upmixing should actually have been disabled by default in LE about 9 years ago, but the change was buggy and had no effect - and no one seems to have noticed that yet :)

    I've also opened a PR for that https://github.com/LibreELEC/LibreELEC.tv/pull/11986

    so long,

    Hias

  • Thanks for the hint that moonlight can support surround sound output, I've now implemented that and added a setting in the moonlight addon https://github.com/LibreELEC/LibreELEC.tv/pull/11985

    I also noticed that stereo-upmixing should actually have been disabled by default in LE about 9 years ago, but the change was buggy and had no effect - and no one seems to have noticed that yet :)

    I've also opened a PR for that https://github.com/LibreELEC/LibreELEC.tv/pull/11986

    so long,

    Hias

    That should be perfect, thank you.

    On a related note could the display configuration that's currently in the External Programs helper add-on be added to the moonlght add-on settings too? As I would like to be able to run VacuumTube at 4k60 but moonlight at 1440p120.

  • On a related note could the display configuration that's currently in the External Programs helper add-on be added to the moonlght add-on settings too? As I would like to be able to run VacuumTube at 4k60 but moonlight at 1440p120.

    Ha, I knew this request would come up at some point :)

    I'll need to think about how to best implement that without duplicating too much code - pretty much all flatpak addons might benefit from a separate display config, and I suspect some other flatpak addons could want the audio config as well.

    so long,

    Hias

  • The first version (with multichannel support for moonlight) is now in the repo, would be nice if you could give that a try and report back if it works.

    Addons with yesterday's PR (adding per-addon display configuration) still need to be built (our CI is quite busy, image and addon builds take quite a lot of time).

    so long,

    Hias

  • Great, just got the first wave of updates, tested all audio channel settings in moonlight and all are working correctly. Only minor point being default and stereo are the same, but not an issue really.

  • Thanks for reporting back!

    Default should use whatever is configured as default-sample-channels setting in PA's daemon.conf - default value is 2, so same as stereo.

    I just added it for completeness before someone comes up with requesting it and I have to touch the code again :)

    so long,

    Hias

  • Addon builds for Generic just finished (ARM is still running) and the second version, with per-addon display configuration is now in the repo.

    Please update, test and report back again.

    so long,

    Hias