Skip to content

feat(audio): keep host default sink with keep_default_sink - #5935

Open
mikefaille wants to merge 8 commits into
LizardByte:masterfrom
mikefaille:feat/audio-keep-default-sink
Open

mikefaille wants to merge 8 commits into
LizardByte:masterfrom
mikefaille:feat/audio-keep-default-sink

Conversation

@mikefaille

@mikefaille mikefaille commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

Screenshot

The change adds a "Keep Default Sink" checkbox to the Audio/Video settings
tab. Screenshot to be attached by the author.

Issues Fixed or Closed

Roadmap Issues

None.

Testing

  • cmake --build build -j2 (Release, Ninja, CUDA enabled): exit 0
  • Filtered run --gtest_filter='*Audio*:*Sink*:*KeepDefault*:*Config*':
    299 tests from 35 suites, all passed — including
    KeepDefaultSinkAudioTest.CaptureSinkKeepsHostDefaultSink,
    NullSinkOwnershipTest.AdoptedSinksSurvivePeerTeardown,
    SinkRoutingPolicyTest (x2), AudioControlAdapterTest, and
    KeepDefaultSinkConfigTest (x2)
  • Full suite: 852 tests from 149 suites — 846 passed, 6 skipped
    (pre-existing platform skips: UtfUtils non-Windows, SystemTrayDisabled,
    MouseHID x4), 0 failed
  • uv run --locked lb-update-clang-format: no changes (format clean)
  • SonarCloud Quality Gate: passed, 0 new issues
  • GitHub Actions CI has not run on this PR (fork workflows await maintainer approval)

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

AI-assisted implementation and tests; reviewed and tested by the author.

… host default

Adds the keep_default_sink config key controlling whether audio capture swaps the host default sink.

- Config: new keep_default_sink key (default disabled) with validation.
- Policy: when enabled, capture keeps the host default sink untouched; teardown restores only state this session changed.
- UI: AudioVideo tab toggle plus locale strings.
- Docs: configuration.md documents the new key.
- Tests: config, audio, and linux audio unit coverage.
Rename shadowed module field (S1669), extract adopt_sink/ensure_sink
helpers from the duplicated sink setup blocks (S3776), shrink the
oversized enumeration lambda (S1188), and guard destructor teardown
against throwing unloads (S1048). Behavior unchanged.
Give the destructor's catch-all a log statement so the intentionally
suppressed unload path is not an empty handler (S2486). Teardown
stays non-throwing.

@ReenigneArcher ReenigneArcher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mikefaille

Copy link
Copy Markdown
Contributor Author

@ReenigneArcher I will review.

@mikefaille

Copy link
Copy Markdown
Contributor Author

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

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

@ReenigneArcher

Copy link
Copy Markdown
Member

When asked to create an issue or pull request, use the templates provided by the LizardByte/.github repo or

https://docs.lizardbyte.dev/latest/developers/contributing.html

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants