#5935

feat(audio): keep host default sink with keep_default_sink

Openmikefaillewants to merge intofrom

Description

Adds a keep_default_sink audio option (Linux) that lets Sunshine capture a configured audio_sink without making the Sunshine sink the host default.

Mechanism: a sink-routing policy object is resolved from the audio settings and handed to capture_sink. When the option is enabled, capture only sets the requested sink and logs that the host default is being left alone — no swap at startup, no restore at teardown. Adopted (pre-existing) sinks are kept alive on peer teardown rather than unloaded (adopt-don't-unload), so host routing is undisturbed. The option defaults to off, preserving current behavior unless explicitly opted in. Wired through config, the web UI audio tab, and unit tests.

Addresses #4950

Note: this addresses the reported default-sink takeover only when the new option is enabled; existing audio_sink-only configs still swap by default.

Testing

  • ninja test_sunshine (Release, BUILD_TESTS=ON): build exit 0
  • Filtered run --gtest_filter='*Audio*:*Sink*:*KeepDefault*:*Config*': 297 tests from 34 suites, all passed — including KeepDefaultSinkAudioTest.CaptureSinkKeepsHostDefaultSink, NullSinkOwnershipTest.AdoptedSinksSurvivePeerTeardown, SinkRoutingPolicyTest (x2), and KeepDefaultSinkConfigTest (x2)
  • Full suite: 802 tests from 136 suites — 795 passed, 7 skipped (pre-existing platform skips: UtfUtils non-Windows, SystemTrayDisabled, MouseHID x4, Encoder nvenc), 0 failed

AI usage

Heavy — AI generated most of the code changes; reviewed and tested by the author.

Activity

25
mikefaille14d ago

@ReenigneArcher I will review.

mikefaille14d ago

Why doesn't your agent follow the AGENTS.md file?

I reviewed myself and I don't see the issue.

mikefaille13d ago

I tried for a common interface for Linux Mac and Windows but it's would be more sane to split the PR to focus only on Linux as I can't test Windows and Mac right now.

Unless someone want to test this patch directly with Windows and Mac ?

ReenigneArcher13d ago

I tried for a common interface for Linux Mac and Windows but it's would be more sane to split the PR to focus only on Linux as I can't test Windows and Mac right now.

Unless someone want to test this patch directly with Windows and Mac ?

I can test it.