[Unofficial] moonlight-embedded

Simply connect the SPDIF output from your TV to your AVR.
That way you get surround for both CE box and TV built in apps.

its solution, i know that :slight_smile: when my spdif not work i use tv optical output. But tv sometimes do strange thinks with sound so i repaired spdif in box and wanna come back to use it :slight_smile:

the strange is that audio is working in moonlight on spdif of my box when i choose hdmi in system settings :slight_smile: but not work when i choose spdif in system settings :slight_smile:

Of curse kodi play audio correclty :slight_smile: when i set hdmi on system there is no audio on spdif of my box, but when i set spdif audio appear on spdif of my box.

@TheCoolest is it possible to compile new xpadneo driver in coreelec?

Hey smg04, thanks for taking the time to expand on that and it makes more sense.

I suppose I should have taken the time to expand and clarify on my setup as my posts were very brief - very difficult to discuss properly with a 2 year old toddler around my feet! (very much like my opportunities to actually play any games these days haha!).

My main Kodi setup is using an X96 Air which has the S905X3 SOC, so is therefore running Kodi Matrix. Going by what you’ve said about the limitation on the audio driver, in theory it should be possible to use 7.1 configuration? Obviously, there’d physically be two channels missing, but I could probably live with that.

My understanding with Nvidia Gamestream technology, is that surround audio has to use Multichannel PCM, which can only be achieved over a HDMI connection straight into the AVR. Which is why if using HDMI ARC from the TV, this will never work unless possibly all devices support the newer eARC standard.

My old S912 I keep plugged in has Android 8 which has working Multichannel PCM, so I use that when i occasionally get to play games. I think Google broke Multichannel PCM on Android 9, and fixed it again on Android 10, which isn’t available on any S905X3 boxes.

It would be nice to get surround via Moonlight Embedded though, as this is a fantastic project and a great piece of work.

On an unrelated note to the sound issues, is there any possibility or plans to be able to emulate the mouse using the controller like you can do currently on the PC version of Moonlight?

Cheers

about mouse emulation

i asked for the same but it depends on original project of moonlight embedded, on android there is also ā€œno frame dropā€ option but look here moonlight options there is summary of all options

Experimental mouse emulation

As requested by @Adam86, I’ve tried implementing mouse emulation via gamepad. I found out it can be done really simply by looking at moonlight-qt project.

Test it out. If it works, I’ll send a PR to the official project.
It works by holding the Start button on your gamepad. Hold it for a second. You won’t see anything happen on screen, but it should move the cursor. A is left click, B is right click (xbox360 layout). Scrolling not yet implemented. Gamepad doesn’t work if mouse emulation is on.

script.luna-0.8.2.1-matrix.113.zip (3.1 MB)

1 Like

for me it works :slight_smile: great now i will not have to move ass to host pc on some situation :smiley: i have no idea why its not build in original project already :slight_smile:

Fantastic, tested mouse emulation and that works great!

Just have no sound at all, even when set to stereo.

EDIT:

Have managed to get stereo sound working by selecting audio device in moonlight configuration and choosing the first SPDIF device in the list: HW 0,0.

Of course set Kodi Audio Config to 2 channel.

About surround:

I believe that alsa can be configured to get surround51 output that would map audio to a 7.1 output with two silent channels. But I have almost zero idea how to do it. If anyone knows/understands ALSA, can you help?

I wonder if any of the CoreELEC team would be able to offer any assistance?

hi all,
many thanks for this very good addon.
i still have it in use on my old Odroid C2 with Kodi 18.
The only thing is with newer NVIDIA Experience version i see following RTSP message too long:

Blockquote
[DEBUG] Stream 1280 x 720, 60 fps, 10000 kbps
Initializing platform…done
Resolving host name…done
Starting RTSP handshake…RTSP message too long
RTSP DESCRIBE request failed: -1
failed: -1
Cleaning up platform…done

The workaround is to fallback to an older Nvidia Experience, but you have to be sure that it will not automatically be updated. It is described here:

Maybe someone can implement this update.
I soon get my Odroid N2+. so lets see is with matrix something has changed :slight_smile:

This has been fixed on Matrix. Luna for Kodi v18 is EOL, as no developers reached out to assist and I no longer have a test box for v18.

Also, new release for v2.5.1 with gamepad improvements.

Having an unusual issue.

So moonlight is set to 1920x1080 resolution, just as my Kodi is.

Windows is set to that too.

Yet on my UHD TV I’m only seeing the image in the top left quarter. It’s as though my resolution is 4K, but it’s definitely not.

It was working fine until a few days back and is randomly doing this.

EDIT: Solved it, you need to set scaling to GPU within Nvidia Control Panel.

I got surround sound to work but the center channel is playing back from surround left.

I have a s903x3 device, any ideas?

I chose ā€œAMLAUGESOUND [AML-AUGESOUND], device 3: TDM-C-dummy dummy-3ā€ for surround playback as it was the only one working.

For anyone willing to test surround…

Can you give me your pactl list sinks. If I use pulseaudio, surround works for me, even though I think it’s emulated because I don’t have a surround setup.

So I ran this command pactl load-module module-alsa-card device_id=0 and then from pactl list sinks I took the device name and wrote that in the audio setting Audio Parameter…

But just for testing, just try starting these series of commands:
pactl load-module module-alsa-card device_id=0
pactl list sinks
and give me the output… Thanks!

I’ll try this ASAP. Presumibly if something goes wrong, a reboot will revert this?

Will this require Kodi to be set to 5.1/7.1 appropriately?

In an ideal case, you won’t notice anything and/or shouldn’t do any Kodi configuration. Kodi will continue working as normal and the whole thing is reverted after a reboot.

In a less-ideal case, try setting the audio to PULSE or something, but I don’t recommend it, its supposed to work in any configuration.

PulseAudio configuration will still require HDMI output (so SPDIF surround is not an option).

Have run those commands and this is the output, can you just confirm which device name I should use in Moonlight?

##############################################
#                  CoreELEC                  #
#            https://coreelec.org            #
##############################################

CoreELEC (official): 19.2-Matrix_rc3 (Amlogic-ng.arm)
LOUNGE-FD:~ # pactl load-module module-alsa-card device_id=0
14
LOUNGE-FD:~ # pactl list sinks
Sink #1
        State: SUSPENDED
        Name: alsa_output.0.hdmi-stereo
        Description: Built-in Audio Digital Stereo (HDMI)
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 14
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.0.hdmi-stereo.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY SET_FORMATS
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "SPDIF-B-dummy dummy-0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "AML-AUGESOUND"
                alsa.long_card_name = "AML-AUGESOUND"
                device.bus_path = "/devices/platform/auge_sound/sound/card0"
                sysfs.path = "/devices/platform/auge_sound/sound/card0"
                device.form_factor = "internal"
                device.string = "hdmi:0"
                device.buffering.buffer_size = "262144"
                device.buffering.fragment_size = "131072"
                device.access_mode = "mmap+timer"
                device.profile.name = "hdmi-stereo"
                device.profile.description = "Digital Stereo (HDMI)"
                device.description = "Built-in Audio Digital Stereo (HDMI)"
                device.icon_name = "audio-card"
        Ports:
                hdmi-output-0: HDMI / DisplayPort (type: HDMI, priority: 5900, availability unknown)
        Active Port: hdmi-output-0
        Formats:
                pcm
LOUNGE-FD:~ #

alsa_output.0.hdmi-stereo

but what worries me is the fact that it’s only recognized as a 2 channel output, which was the same result I got.
Try this and play surround audio on your PC. You should either hear it working on surround speakers OR it’s gonna use only two channels and some kind of downmixing. I’m pretty sure the difference is gonna be obvious.

On s905x3 device my output was also stereo, but after adding ā€œdefault-sample-channels=6ā€ to custom.conf the output looks like this,

CoreELEC:~ # pactl list sinks
Sink #1
        State: IDLE
        Name: alsa_output.0.hdmi-surround
        Description: Built-in Audio Digital Surround 5.1 (HDMI)
        Driver: module-alsa-card.c
        Sample Specification: s16le 6ch 44100Hz
        Channel Map: front-left,front-right,rear-left,rear-right,front-center,lfe
        Owner Module: 14
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB,   rear-left: 65536 / 100% / 0.00 dB,   rear-right: 65536 / 100% / 0.00 dB,   front-center: 65536 / 100% / 0.00 dB,   lfe: 65536 / 100% / 0.00 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.0.hdmi-surround.monitor
        Latency: 0 usec, configured 495351 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "SPDIF-B-dummy dummy-0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "AML-AUGESOUND"
                alsa.long_card_name = "AML-AUGESOUND"
                device.bus_path = "/devices/platform/auge_sound/sound/card0"
                sysfs.path = "/devices/platform/auge_sound/sound/card0"
                device.form_factor = "internal"
                device.string = "hdmi:0"
                device.buffering.buffer_size = "262140"
                device.buffering.fragment_size = "131064"
                device.access_mode = "mmap+timer"
                device.profile.name = "hdmi-surround"
                device.profile.description = "Digital Surround 5.1 (HDMI)"
                device.description = "Built-in Audio Digital Surround 5.1 (HDMI)"
                device.icon_name = "audio-card"
        Ports:
                hdmi-output-0: HDMI / DisplayPort (type: HDMI, priority: 5900, availability unknown)
        Active Port: hdmi-output-0
        Formats:
                pcm

I can get surround sound working using alsa but center and surround left channels are swapped for some reason. I couldn’t get pulseaudio to work so far. Where should I put ā€œalsa_output.0.hdmi-surroundā€ if you don’t mind me asking.

You’re gonna have to explain what you did, but before that…

You have to put ā€œalsa_output.0.hdmi-surroundā€ in your Luna settings.
So Settings → Streaming:

  1. Customize Audio Settings (check the box/enable option)
  2. Set Audio Parameter to ā€œalsa_output.0.hdmi-surroundā€ (without spaces and quotation marks)

You can do that by using Kodi Remote on your phone or maybe even through the web.
Or run these commands:

cd ~/.kodi/addons/script.luna/bin
rm moonlight.conf
killall -STOP kodi.bin
echo "rm default" > /sys/class/vfm/map
echo "add default vdec.h265.00 amvideo" > /sys/class/vfm/map
moonlight stream -app "Some app" -1080 -fps 60 -audio alsa_output.0.hdmi-surround -surround 5.1 # or 7.1 whatever you're trying to do

When you are done, run another ssh (or kill nvstreamer.exe on host) and:

killall moonlight # or kill nvstreamer.exe and don't run this, wait for moonlight to gracefully quit.
echo 0 > /sys/class/graphics/fb0/blank
echo 0 > /sys/class/graphics/fb1/blank
echo "rm default" > /sys/class/vfm/map
echo "add default decoder ppmgr amlvideo deinterlace amvideo" > /sys/class/vfm/map
killall -CONT kodi.bin

to fix Kodi.