Skip to content

Commit 4eefd0b

Browse files
Clutchnpqiin2333
authored andcommitted
feat(audio): add an option to disable sound streaming (LizardByte#3833)
1 parent 619f444 commit 4eefd0b

6 files changed

Lines changed: 41 additions & 1 deletion

File tree

docs/configuration.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,30 @@ editing the `conf` file in a text editor. Use the examples as reference.
741741
</tr>
742742
</table>
743743

744-
### [install_steam_audio_drivers](https://localhost:47990/config/#install_steam_audio_drivers)
744+
### stream_audio
745+
746+
<table>
747+
<tr>
748+
<td>Description</td>
749+
<td colspan="2">
750+
Whether to stream audio or not. Disabling this can be useful for streaming headless displays as second monitors.
751+
</td>
752+
</tr>
753+
<tr>
754+
<td>Default</td>
755+
<td colspan="2">@code{}
756+
enabled
757+
@endcode</td>
758+
</tr>
759+
<tr>
760+
<td>Example</td>
761+
<td colspan="2">@code{}
762+
stream_audio = disabled
763+
@endcode</td>
764+
</tr>
765+
</table>
766+
767+
### install_steam_audio_drivers
745768

746769
<table>
747770
<tr>

src/audio.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ namespace audio {
132132
void
133133
capture(safe::mail_t mail, config_t config, void *channel_data) {
134134
auto shutdown_event = mail->event<bool>(mail::shutdown);
135+
if (!config::audio.stream) {
136+
shutdown_event->view();
137+
return;
138+
}
135139
auto stream = stream_configs[map_stream(config.channels, config.flags[config_t::HIGH_QUALITY])];
136140
if (config.flags[config_t::CUSTOM_SURROUND_PARAMS]) {
137141
apply_surround_params(stream, config.customStreamParams);

src/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ namespace config {
409409
audio_t audio {
410410
{}, // audio_sink
411411
{}, // virtual_sink
412+
true, // stream audio
412413
true, // install_steam_drivers
413414
};
414415

@@ -1132,6 +1133,7 @@ namespace config {
11321133

11331134
string_f(vars, "audio_sink", audio.sink);
11341135
string_f(vars, "virtual_sink", audio.virtual_sink);
1136+
bool_f(vars, "stream_audio", audio.stream);
11351137
bool_f(vars, "install_steam_audio_drivers", audio.install_steam_drivers);
11361138

11371139
string_restricted_f(vars, "origin_web_ui_allowed", nvhttp.origin_web_ui_allowed, { "pc"sv, "lan"sv, "wan"sv });

src/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ namespace config {
104104
struct audio_t {
105105
std::string sink;
106106
std::string virtual_sink;
107+
bool stream;
107108
bool install_steam_drivers;
108109
};
109110

src_assets/common/assets/web/configs/tabs/AudioVideo.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ const config = ref(props.config)
6969
</template>
7070
</PlatformLayout>
7171

72+
<!-- Disable Audio -->
73+
<Checkbox class="mb-3"
74+
id="stream_audio"
75+
locale-prefix="config"
76+
v-model="config.stream_audio"
77+
default="true"
78+
></Checkbox>
79+
7280
<AdapterNameSelector
7381
:platform="platform"
7482
:config="config"

src_assets/common/assets/web/public/assets/locale/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@
323323
"resolution_change_windows": "Resolution change",
324324
"resolutions": "Advertised Resolutions",
325325
"restart_note": "Sunshine is restarting to apply changes.",
326+
"stream_audio": "Stream Audio",
327+
"stream_audio_desc": "Whether to stream audio or not. Disabling this can be useful for streaming headless displays as second monitors.",
326328
"sunshine_name": "Sunshine Name",
327329
"sunshine_name_desc": "The name displayed by Moonlight. If not specified, the PC's hostname is used",
328330
"sw_preset": "SW Presets",

0 commit comments

Comments
 (0)