Skip to content

feat(audio): add lossless HDMI passthrough - #20

Merged
FengZeng merged 8 commits into
FengZeng:mainfrom
cjohnsto-nz:agent/audio-passthrough-pr
Aug 16, 2026
Merged

feat(audio): add lossless HDMI passthrough#20
FengZeng merged 8 commits into
FengZeng:mainfrom
cjohnsto-nz:agent/audio-passthrough-pr

Conversation

@cjohnsto-nz

@cjohnsto-nz cjohnsto-nz commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • add a minimal audio output selector and Passthrough toggle to Settings and the player audio quick menu
  • pass AC-3, E-AC-3, TrueHD/Atmos, DTS, and DTS-HD through unchanged when supported by the selected device
  • reattempt passthrough after output-device and mode changes by refreshing playback at the current demux position
  • distinguish requested settings from observed mpv output so passthrough is only reported after audio-out-params/format becomes spdif-*
  • replace the volume control with a passive dotted-speaker indicator while passthrough is active
  • use a shared custom dropdown component for Settings and player controls
  • add concise hover hints to the quick output selector and Passthrough toggle
  • group the controls under Audio immediately after Rendering

Why

Soia currently decodes all audio through the PC mixer. This adds an explicit path for sending supported encoded streams unchanged to an HDMI receiver while keeping the normal PCM path as the default.

Runtime

This branch pins the official mpv v0.41.0-r16 release, produced after FengZeng/mpv#3 enabled and verified FFmpeg's SPDIF muxer.

The normal compact dynamic-runtime architecture is unchanged. This does not introduce a conditional runtime source, fork-specific dependency, static binary overlay, or bundled diagnostic artifact.

The PR remains draft while the rewritten branch completes CI and final review.

Product behavior

  • PCM remains the default.
  • Passthrough uses the selected output device and automatically uses WASAPI exclusive mode for eligible encoded tracks.
  • Changing the device or toggling Passthrough back on creates a fresh SPDIF attempt.
  • A zero-distance exact seek restarts the SPDIF decoder at a valid demux boundary, avoiding intermittent TrueHD parser failures after route changes.
  • Failed encoded negotiation is reported instead of decoded PCM being presented as successful passthrough.
  • Unsupported codecs such as FLAC, AAC, and Opus continue through decoded PCM without disabling the preference for future eligible tracks.
  • Volume, mute, and speed changes are unavailable while encoded passthrough is active.
  • Device identifiers remain internal; only readable descriptions are displayed.
  • Existing development settings migrate to the minimal mode plus outputDevice contract.

Validation

  • pnpm build
  • 12 focused Rust audio tests passed
  • hardware validation confirmed reliable TrueHD passthrough after startup, mode toggles, and output-device changes
  • mpv release CI passed for Windows, macOS, and Linux on x64 and ARM64: https://github.com/FengZeng/mpv/actions/runs/30737604752
  • pnpm setup:libs resolved and installed the official r16 Windows x64 release
  • local integration built successfully with pnpm bundle:win:release

The full Rust suite currently has three unrelated upstream failures. All reproduce on upstream/main: two playlist/core state assertions and the existing Windows path-separator assertion.

…ality

- Added audio settings management to the UI state, allowing for persistence of audio configurations.
- Introduced a new `useAudioOutput` composable for handling audio device states and settings.
- Enhanced the `MpvHandle` to accept audio settings and configure mpv options accordingly.
- Created a dedicated audio settings section in the settings panel, including device selection and passthrough toggle.
- Updated player controls to reflect audio passthrough status and manage volume accordingly.
- Implemented UI components for audio device selection and passthrough indication.
- Added tests to ensure audio settings are correctly serialized and deserialized.
- Refactored audio-related types and utility functions for better maintainability.
@cjohnsto-nz
cjohnsto-nz force-pushed the agent/audio-passthrough-pr branch from 04176bb to cfb9deb Compare August 2, 2026 06:10
@cjohnsto-nz
cjohnsto-nz force-pushed the agent/audio-passthrough-pr branch from a71dfe9 to fde01fa Compare August 2, 2026 07:41
@FengZeng

FengZeng commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@cjohnsto-nz The new release of mpv v0.41.0-r16 with spdif muxer enabled in ffmpeg is ready now

Also have two small suggestions for the Settings page:

  1. Maybe rename the Audio Output section to Audio, so we have a place to add more audio related settings in the future.
  2. Maybe move this section a bit higher, for example right after Rendering, since audio settings are important for many users.

@cjohnsto-nz
cjohnsto-nz force-pushed the agent/audio-passthrough-pr branch from 8d5002f to 5631d54 Compare August 2, 2026 08:31
@cjohnsto-nz

Copy link
Copy Markdown
Author

@FengZeng I have addressed your feedback, and pushed a couple of additional fixes.
I am happy for this to be kept open for a few days so I can test in real world use.

@cjohnsto-nz
cjohnsto-nz marked this pull request as ready for review August 2, 2026 08:50
@FengZeng
FengZeng merged commit 95c7538 into FengZeng:main Aug 16, 2026
4 checks passed
@FengZeng

Copy link
Copy Markdown
Owner

There are still a few bugs on macOS. I’m also planning to redesign the Audio popup in the Playback UI, so I temporarily removed the audio passthrough settings from it

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.

3 participants