From 6844c54d95644b73dc676a7185e0abacbc183295 Mon Sep 17 00:00:00 2001 From: Clutchnp Date: Tue, 29 Apr 2025 22:35:56 +0530 Subject: [PATCH 1/5] add an option to disabled sound streaming --- docs/configuration.md | 23 +++++++++++++++++++++++ src/audio.cpp | 4 ++++ src/config.cpp | 2 ++ src/config.h | 1 + 4 files changed, 30 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index bdd187bef9b..da73e1864d3 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -770,6 +770,29 @@ editing the `conf` file in a text editor. Use the examples as reference. +### disable_audio + + + + + + + + + + + + + + +
Description + This option allows to disable streaming audio completely, useful for streaming of headless displays as second monitors +
Default@code{} + disabled + @endcode
Example@code{} + disable_audio = enabled + @endcode
+ ### install_steam_audio_drivers diff --git a/src/audio.cpp b/src/audio.cpp index f060118d8c0..c8c01206b6d 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -129,6 +129,10 @@ namespace audio { void capture(safe::mail_t mail, config_t config, void *channel_data) { auto shutdown_event = mail->event(mail::shutdown); + if (config::audio.disable){ + shutdown_event->view(); + return; + } auto stream = stream_configs[map_stream(config.channels, config.flags[config_t::HIGH_QUALITY])]; if (config.flags[config_t::CUSTOM_SURROUND_PARAMS]) { apply_surround_params(stream, config.customStreamParams); diff --git a/src/config.cpp b/src/config.cpp index 167b244a7ea..d0317a745f5 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -511,6 +511,7 @@ namespace config { audio_t audio { {}, // audio_sink {}, // virtual_sink + false, // disable audio true, // install_steam_drivers }; @@ -1160,6 +1161,7 @@ namespace config { string_f(vars, "audio_sink", audio.sink); string_f(vars, "virtual_sink", audio.virtual_sink); + bool_f(vars, "disable_audio", audio.disable); bool_f(vars, "install_steam_audio_drivers", audio.install_steam_drivers); string_restricted_f(vars, "origin_web_ui_allowed", nvhttp.origin_web_ui_allowed, {"pc"sv, "lan"sv, "wan"sv}); diff --git a/src/config.h b/src/config.h index 474cbb5aafa..b41e61a8200 100644 --- a/src/config.h +++ b/src/config.h @@ -147,6 +147,7 @@ namespace config { struct audio_t { std::string sink; std::string virtual_sink; + bool disable; bool install_steam_drivers; }; From cb94b1032a0faaa6dfcc0155cc3be6cd948bf716 Mon Sep 17 00:00:00 2001 From: Clutchnp Date: Wed, 30 Apr 2025 08:19:51 +0530 Subject: [PATCH 2/5] add disable_audio option to web-ui --- src_assets/common/assets/web/configs/tabs/AudioVideo.vue | 8 ++++++++ src_assets/common/assets/web/public/assets/locale/en.json | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src_assets/common/assets/web/configs/tabs/AudioVideo.vue b/src_assets/common/assets/web/configs/tabs/AudioVideo.vue index 6791a9c60db..79020e5cfdf 100644 --- a/src_assets/common/assets/web/configs/tabs/AudioVideo.vue +++ b/src_assets/common/assets/web/configs/tabs/AudioVideo.vue @@ -63,6 +63,14 @@ const config = ref(props.config) + + + Date: Thu, 1 May 2025 06:39:19 +0530 Subject: [PATCH 3/5] change wording to match feedback --- docs/configuration.md | 8 ++++---- src/audio.cpp | 2 +- src/config.cpp | 4 ++-- src/config.h | 2 +- src_assets/common/assets/web/configs/tabs/AudioVideo.vue | 6 +++--- src_assets/common/assets/web/public/assets/locale/en.json | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index da73e1864d3..e006b7da276 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -770,25 +770,25 @@ editing the `conf` file in a text editor. Use the examples as reference.
-### disable_audio +### stream_audio
Description - This option allows to disable streaming audio completely, useful for streaming of headless displays as second monitors + Weather to Stream Audio or Not, Disabling this can be useful for streaming headless displays as second monitors.
Default @code{} - disabled + enabled @endcode
Example @code{} - disable_audio = enabled + stream_audio = disabled @endcode
diff --git a/src/audio.cpp b/src/audio.cpp index c8c01206b6d..7d59b305a26 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -129,7 +129,7 @@ namespace audio { void capture(safe::mail_t mail, config_t config, void *channel_data) { auto shutdown_event = mail->event(mail::shutdown); - if (config::audio.disable){ + if (!config::audio.stream){ shutdown_event->view(); return; } diff --git a/src/config.cpp b/src/config.cpp index d0317a745f5..7147fd6cfdb 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -511,7 +511,7 @@ namespace config { audio_t audio { {}, // audio_sink {}, // virtual_sink - false, // disable audio + true, // stream audio true, // install_steam_drivers }; @@ -1161,7 +1161,7 @@ namespace config { string_f(vars, "audio_sink", audio.sink); string_f(vars, "virtual_sink", audio.virtual_sink); - bool_f(vars, "disable_audio", audio.disable); + bool_f(vars, "stream_audio", audio.stream); bool_f(vars, "install_steam_audio_drivers", audio.install_steam_drivers); string_restricted_f(vars, "origin_web_ui_allowed", nvhttp.origin_web_ui_allowed, {"pc"sv, "lan"sv, "wan"sv}); diff --git a/src/config.h b/src/config.h index b41e61a8200..066b95df182 100644 --- a/src/config.h +++ b/src/config.h @@ -147,7 +147,7 @@ namespace config { struct audio_t { std::string sink; std::string virtual_sink; - bool disable; + bool stream; bool install_steam_drivers; }; diff --git a/src_assets/common/assets/web/configs/tabs/AudioVideo.vue b/src_assets/common/assets/web/configs/tabs/AudioVideo.vue index 79020e5cfdf..27f58365d70 100644 --- a/src_assets/common/assets/web/configs/tabs/AudioVideo.vue +++ b/src_assets/common/assets/web/configs/tabs/AudioVideo.vue @@ -65,10 +65,10 @@ const config = ref(props.config) Date: Thu, 1 May 2025 19:28:39 +0530 Subject: [PATCH 4/5] grammar fixes and syntax --- docs/configuration.md | 2 +- src_assets/common/assets/web/public/assets/locale/en.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index e006b7da276..ef2486436d1 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -776,7 +776,7 @@ editing the `conf` file in a text editor. Use the examples as reference. Description - Weather to Stream Audio or Not, Disabling this can be useful for streaming headless displays as second monitors. + Whether to stream audio or not. Disabling this can be useful for streaming headless displays as second monitors. diff --git a/src_assets/common/assets/web/public/assets/locale/en.json b/src_assets/common/assets/web/public/assets/locale/en.json index e5b55e3c3f5..a9b214b92b7 100644 --- a/src_assets/common/assets/web/public/assets/locale/en.json +++ b/src_assets/common/assets/web/public/assets/locale/en.json @@ -227,8 +227,6 @@ "hevc_mode_desc": "Allows the client to request HEVC Main or HEVC Main10 video streams. HEVC is more CPU-intensive to encode, so enabling this may reduce performance when using software encoding.", "high_resolution_scrolling": "High Resolution Scrolling Support", "high_resolution_scrolling_desc": "When enabled, Sunshine will pass through high resolution scroll events from Moonlight clients. This can be useful to disable for older applications that scroll too fast with high resolution scroll events.", - "stream_audio" : "Stream Audio"" - "stream_audio_desc" : "Weather to Stream Audio or Not, Disabling this can be useful for streaming headless displays as second monitors.", "install_steam_audio_drivers": "Install Steam Audio Drivers", "install_steam_audio_drivers_desc": "If Steam is installed, this will automatically install the Steam Streaming Speakers driver to support 5.1/7.1 surround sound and muting host audio.", "key_repeat_delay": "Key Repeat Delay", @@ -331,6 +329,8 @@ "qsv_slow_hevc": "Allow Slow HEVC Encoding", "qsv_slow_hevc_desc": "This can enable HEVC encoding on older Intel GPUs, at the cost of higher GPU usage and worse performance.", "restart_note": "Sunshine is restarting to apply changes.", + "stream_audio": "Stream Audio", + "stream_audio_desc": "Whether to stream audio or not. Disabling this can be useful for streaming headless displays as second monitors.", "sunshine_name": "Sunshine Name", "sunshine_name_desc": "The name displayed by Moonlight. If not specified, the PC's hostname is used", "sw_preset": "SW Presets", From 5774c8a002b7e28f760f7c9099887d8b5aea9786 Mon Sep 17 00:00:00 2001 From: Clutchnp Date: Thu, 1 May 2025 19:48:37 +0530 Subject: [PATCH 5/5] fix linting --- src/audio.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio.cpp b/src/audio.cpp index 7d59b305a26..0d287071a25 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -129,10 +129,10 @@ namespace audio { void capture(safe::mail_t mail, config_t config, void *channel_data) { auto shutdown_event = mail->event(mail::shutdown); - if (!config::audio.stream){ + if (!config::audio.stream) { shutdown_event->view(); return; - } + } auto stream = stream_configs[map_stream(config.channels, config.flags[config_t::HIGH_QUALITY])]; if (config.flags[config_t::CUSTOM_SURROUND_PARAMS]) { apply_surround_params(stream, config.customStreamParams);