moonlight-ios icon indicating copy to clipboard operation
moonlight-ios copied to clipboard

5.1 audio on Apple TV

Open matthewvinton opened this issue 5 years ago • 71 comments

It would be very helpful to have the tvOS build of Moonlight be able to support greater than stereo audio, in a similar fashion to the QT clients. With the upcoming support for real gamepads, the Apple TV is shaping up to be a good options for streaming to living rooms. 5.1 support would really complete it.

matthewvinton avatar Jun 22 '19 22:06 matthewvinton

@matthewvinton It should automatically request 5.1 now if the connected audio device supports at least 6 channels. Can you confirm it's working for you and that the channel mappings are correct?

cgutman avatar Aug 27 '19 05:08 cgutman

@cgutman I just built it and I don't seem to be getting any sound. I'm looking through the console to see if there is anything obvious - anything specific log-wise I should look for?

matthewvinton avatar Aug 29 '19 18:08 matthewvinton

Can you post the log?

cgutman avatar Aug 29 '19 22:08 cgutman

Absolutely.

Below is the NVStreamer log. It looks like it is trying to use 6 channel audio, as one would expect.

BTW, I also ran a test with forcing the AppleTV into stereo, and the audio worked correctly.

I'm not as sure how to get logs out of the AppleTV build, so let me know what you would like from that. (Does Moonlight log to Console?)

NvStreamerCurrent.log

matthewvinton avatar Aug 29 '19 22:08 matthewvinton

When you launch it from Xcode on your Apple TV, it should have logs in the Xcode window.

cgutman avatar Aug 30 '19 00:08 cgutman

OK, I have both the Moonlight logs and the logs from the AppleTV console from the same time period. console_appletv_log.txt moonlight_appletv_log.txt

matthewvinton avatar Aug 30 '19 01:08 matthewvinton

Thanks, I've reproduced the issue here too. Not sure what the cause is yet.

cgutman avatar Aug 30 '19 03:08 cgutman

I think I fixed it. It's working for me now. Try with the latest code.

cgutman avatar Aug 30 '19 04:08 cgutman

It is producing sound now. The sound that comes through is only two channel, but it wouldn't surprise me if it isn't the same issue that is affecting the Steam Link software on AppleTV:

https://steamcommunity.com/app/353380/discussions/7/1642045003578575456/

matthewvinton avatar Aug 30 '19 17:08 matthewvinton

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Nov 28 '19 18:11 stale[bot]

Hy! I have the same issue using the App Store Moonlight version. It only outputs Stereo. Netflix etc works. On my Shield TV it outputs in 7.1. On my Raspberry Pi 4 Moonlight also outputs 7.1. So it must be something with the iOS app?

Laess3r avatar May 06 '20 16:05 Laess3r

Hy! I have the same issue using the App Store Moonlight version. It only outputs Stereo. Netflix etc works. On my Shield TV it outputs in 7.1. On my Raspberry Pi 4 Moonlight also outputs 7.1. So it must be something with the iOS app?

Installed yesterday for the first time. I have the same issue. It only out 3.0 or 3.1, I think. No sounds in my rear left and rear right.

iFredOS avatar Jun 10 '20 09:06 iFredOS

Same issue here, also I tried steam link and it does support 5.1

BetoRn avatar Jun 12 '20 17:06 BetoRn

in mediaserverd parameters send correct:

  CAReportingClient.mm:497   message {
    mBitsPerChannel = 16;
    mBytesPerFrame = 12;
    mBytesPerPacket = 12;
    mChannelsPerFrame = 6;
    mFormatFlags = 12;
    mFormatID = lpcm;
    mFramesPerPacket = 1;
    mSampleRate = 48000;
    spatializationEnabled = 0;
}

maybe next internal setup with bug? how i may helps you with this issue?

Alien-hide avatar Sep 21 '20 08:09 Alien-hide

Also would love this feature!

jski avatar Sep 30 '20 22:09 jski

I am also having this issue.

robbyb20 avatar Nov 24 '20 05:11 robbyb20

I am also having this issue as described above.

dhhuston avatar Dec 14 '20 02:12 dhhuston

I have the same issue. This feature would make it perfect for me.

toto77github avatar Dec 14 '20 18:12 toto77github

Hi @cgutman are there any updates on this yet? Loving moonlight - the image is so much better than Steam Link but still no surround sound makes me use steam link instead at the moment. Steam link has an option to choose 7.1 on the client as well as the host and I noticed moonlight doesn't on Apple TV - is this likely the problem? Thanks

ghost avatar Jan 13 '21 13:01 ghost

Same issue here. Apple tvOS 14.3. Moonlight installed through the app store. Steam Link app produces PCM 3/4 according to my A/V receiver by using its 7.1 option. Moonlight only doing stereo audio.

GMedlin avatar Jan 19 '21 03:01 GMedlin

version 7.0.3 (2021.02.04) still have this issues

Alien-hide avatar Feb 05 '21 17:02 Alien-hide

any information on this? anything we can do to help?

dhhuston avatar May 11 '21 21:05 dhhuston

Bump this up - it would be great to have proper multichannel support. It says PCM for me but 2.0. I got a 7.1 setup - but only the front and side speakers are used, not the one in the back. I tried out several games to validate and it behaves always the same. Sound effects are not specifically directed to the sides, it's like the front area just expands to the sides and the rears are not used at all.

xenom0rph1 avatar May 22 '21 07:05 xenom0rph1

I don't have a surround sound system available to test, but I have a possible fix. Please let me know if one of you has Xcode set up and can build Moonlight for your Apple TV to test my fix.

cgutman avatar Jun 13 '21 19:06 cgutman

I will have access tonight! Let me know!

// Davin Huston @.***


From: Cameron Gutman @.> Sent: Sunday, June 13, 2021 3:06:48 PM To: moonlight-stream/moonlight-ios @.> Cc: dhhuston @.>; Comment @.> Subject: Re: [moonlight-stream/moonlight-ios] 5.1 audio on Apple TV (#371)

I don't have a surround sound system available to test, but I have a possible fix. Please let me know if one of you has Xcode set up and can build Moonlight for your Apple TV to test my fix.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/moonlight-stream/moonlight-ios/issues/371#issuecomment-860256263, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAIPZWREJK6L356GP4J2MZ3TST6URANCNFSM4H2XWZ7Q.

dhhuston avatar Jun 13 '21 20:06 dhhuston

Try changing: https://github.com/moonlight-stream/moonlight-ios/blob/e143dff76ae9c8c2af8b95aad4913917cf79653b/Limelight/Stream/Connection.m#L231 to: [audioSession setPreferredOutputNumberOfChannels:opusConfig.channelCount error:&audioSessionError];

Best I can tell, you have to call that to get surround sound (rather than downmixed stereo, which is what we get now). However, calling that on my TV seems to break audio. I'm not sure if it's just because I don't have a real surround sound system.

I'm referencing a commit from SDL which fixed the surround sound bug for Apple TV for Steam Link - https://github.com/libsdl-org/SDL/commit/2c9871a4a8d4c7cd3ac4c1840de1d0694b176607

That looks like the only meaningful difference between the working SDL code and the broken Moonlight code, but let me know if you see other things. I've sunk a few hours in and can't figure out any other differences.

cgutman avatar Jun 13 '21 20:06 cgutman

I’ll give it a shot

dhhuston avatar Jun 14 '21 02:06 dhhuston

I tried to fix with this, the sound is completely gone. used the master branch. In SteamLink at the same time I have 5.1 sound on the same installation.

Alien-hide avatar Jun 16 '21 08:06 Alien-hide

Same thing happened to me. I’ll sniff around the sources as well.

dhhuston avatar Jun 16 '21 11:06 dhhuston

@cgutman I tried your suggestion and it works for me. I'm now able to get surround sound on my AppleTV through my amplifier. It is however defaulting to 7.1 configuration at the moment (Windows is set to 5.1).

My setup:

Sony STR-DN1080 AppleTV (4th gen) - v14.6 Sony XBR-658AG

Dolby ATMOS is enabled in the audio setting for the Apple TV.

Edit: Digging through the code I see that the configuration queries and defaults to the highest supported number of channels. So perhaps an audio settings panel may need to be added to enable users to select their desired audio configuration.

It doesn't really explain why audio is disappearing for some. Perhaps the Apple TV reports the incorrect audio configuration.

Nitropud avatar Jul 10 '21 07:07 Nitropud