From cd7649a66640a1f9c75bbc03b617c44dd47fdde1 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 3 Apr 2020 00:12:52 -0700 Subject: [PATCH] Add 7.1 surround sound support for SDL audio output --- app/backend/nvhttp.cpp | 6 ++---- app/cli/commandlineparser.cpp | 1 + app/gui/SettingsView.qml | 4 ++++ app/settings/streamingpreferences.h | 3 ++- app/streaming/session.cpp | 13 +++++++------ moonlight-common-c/moonlight-common-c | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/backend/nvhttp.cpp b/app/backend/nvhttp.cpp index 2af36bb5..0f29b62b 100644 --- a/app/backend/nvhttp.cpp +++ b/app/backend/nvhttp.cpp @@ -174,8 +174,7 @@ NvHTTP::launchApp(int appId, "&hdrMode=1&clientHdrCapVersion=0&clientHdrCapSupportedFlagsInUint32=0&clientHdrCapMetaDataId=NV_STATIC_METADATA_TYPE_1&clientHdrCapDisplayData=0x0x0x0x0x0x0x0x0x0x0" : "")+ "&localAudioPlayMode="+QString::number(localAudio ? 1 : 0)+ - "&surroundAudioInfo="+QString::number(CHANNEL_MASK_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration) << 16 | - CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration))+ + "&surroundAudioInfo="+QString::number(SURROUNDAUDIOINFO_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration))+ "&remoteControllersBitmap="+QString::number(gamepadMask)+ "&gcmap="+QString::number(gamepadMask), LAUNCH_TIMEOUT_MS); @@ -197,8 +196,7 @@ NvHTTP::resumeApp(PSTREAM_CONFIGURATION streamConfig) "resume", "rikey="+QString(QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex())+ "&rikeyid="+QString::number(riKeyId)+ - "&surroundAudioInfo="+QString::number(CHANNEL_MASK_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration) << 16 | - CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration)), + "&surroundAudioInfo="+QString::number(SURROUNDAUDIOINFO_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration)), RESUME_TIMEOUT_MS); // Throws if the request failed diff --git a/app/cli/commandlineparser.cpp b/app/cli/commandlineparser.cpp index 2047323b..802c143b 100644 --- a/app/cli/commandlineparser.cpp +++ b/app/cli/commandlineparser.cpp @@ -252,6 +252,7 @@ StreamCommandLineParser::StreamCommandLineParser() m_AudioConfigMap = { {"stereo", StreamingPreferences::AC_STEREO}, {"5.1-surround", StreamingPreferences::AC_51_SURROUND}, + {"7.1-surround", StreamingPreferences::AC_71_SURROUND}, }; m_VideoCodecMap = { {"auto", StreamingPreferences::VCC_AUTO}, diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index d17416f2..3c9a55e0 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -480,6 +480,10 @@ Flickable { text: "5.1 surround sound" val: StreamingPreferences.AC_51_SURROUND } + ListElement { + text: "7.1 surround sound" + val: StreamingPreferences.AC_71_SURROUND + } } // ::onActivated must be used, as it only listens for when the index is changed by a human onActivated : { diff --git a/app/settings/streamingpreferences.h b/app/settings/streamingpreferences.h index bf94edde..ea6709e0 100644 --- a/app/settings/streamingpreferences.h +++ b/app/settings/streamingpreferences.h @@ -20,7 +20,8 @@ public: enum AudioConfig { AC_STEREO, - AC_51_SURROUND + AC_51_SURROUND, + AC_71_SURROUND }; Q_ENUM(AudioConfig) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index f6b48e92..31cce3a7 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -389,10 +389,13 @@ bool Session::initialize() switch (m_Preferences->audioConfig) { case StreamingPreferences::AC_STEREO: - m_StreamConfig.audioConfiguration = MAKE_AUDIO_CONFIGURATION(2, 0x3); + m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO; break; case StreamingPreferences::AC_51_SURROUND: - m_StreamConfig.audioConfiguration = MAKE_AUDIO_CONFIGURATION(6, 0xFC); + m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_51_SURROUND; + break; + case StreamingPreferences::AC_71_SURROUND: + m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_71_SURROUND; break; } @@ -607,11 +610,9 @@ bool Session::validateLaunch(SDL_Window* testWindow) // Gracefully degrade to stereo if surround sound doesn't work if (!audioTestPassed && CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(m_StreamConfig.audioConfiguration) > 2) { - int fallbackAudioConfig = MAKE_AUDIO_CONFIGURATION(2, 0x3); - - audioTestPassed = testAudio(fallbackAudioConfig); + audioTestPassed = testAudio(AUDIO_CONFIGURATION_STEREO); if (audioTestPassed) { - m_StreamConfig.audioConfiguration = fallbackAudioConfig; + m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO; emitLaunchWarning("Your selected surround sound setting is not supported by the current audio device."); } } diff --git a/moonlight-common-c/moonlight-common-c b/moonlight-common-c/moonlight-common-c index 607aaca9..85de16b4 160000 --- a/moonlight-common-c/moonlight-common-c +++ b/moonlight-common-c/moonlight-common-c @@ -1 +1 @@ -Subproject commit 607aaca93f550f516682d1266faa94786c9a240a +Subproject commit 85de16b41bca7ece0a6e0c69acdb76a5da0e79e0