From 4ae412b21945b87a980dcdc31d219dc0699aabe5 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 7 May 2023 14:57:40 -0500 Subject: [PATCH] Allow localAudioPlayMode to change on /resume Newer clients send all /launch parameters to /resume too --- src/nvhttp.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index b53d8d73..289d2ef0 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -823,11 +823,11 @@ namespace nvhttp { return; } - // Probe encoders again before streaming to ensure our chosen - // encoder matches the active GPU (which could have changed - // due to hotplugging, driver crash, primary monitor change, - // or any number of other factors). if (rtsp_stream::session_count() == 0) { + // Probe encoders again before streaming to ensure our chosen + // encoder matches the active GPU (which could have changed + // due to hotplugging, driver crash, primary monitor change, + // or any number of other factors). if (video::probe_encoders()) { tree.put("root.resume", 0); tree.put("root..status_code", 503); @@ -835,6 +835,13 @@ namespace nvhttp { return; } + + // Newer Moonlight clients send localAudioPlayMode on /resume too, + // so we should use it if it's present in the args and there are + // no active sessions we could be interfering with. + if (args.find("localAudioPlayMode"s) != std::end(args)) { + host_audio = util::from_view(get_arg(args, "localAudioPlayMode")); + } } rtsp_stream::launch_session_raise(make_launch_session(host_audio, args)); @@ -922,7 +929,7 @@ namespace nvhttp { auto add_cert = std::make_shared>(30); - // /resume doesn't get the parameter "localAudioPlayMode" + // /resume doesn't always get the parameter "localAudioPlayMode" // /launch will store it in host_audio bool host_audio {};