Add public audio output routing API surface - #370
Draft
MaxHeimbrock wants to merge 1 commit into
Draft
Conversation
Define the phase-A routing API on PlatformAudio, purely in C# and shaped identically to the planned FFI-backed implementation so app code written against it survives the plumbing swap: - AudioOutputKind enum (values mirror the planned FFI proto enum 1:1) - AudioDevice.Kind / AudioDevice.IsSelected - OutputPreference ranked policy (default BT > wired > speaker > earpiece) - IsSpeakerOutputPreferred as documented sugar over the list order - SelectOutput / ClearOutputOverride sticky override - DevicesChanged event (playout, recording) on the Unity main thread - internal IRouteController seam with desktop (FFI enumeration/GUID selection) and unsupported-mobile implementations; Android/iOS backends plug into the seam in follow-up work Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MaxHeimbrock
requested review from
cloudwebrtc,
ladvoc and
xianshijing-lk
as code owners
August 14, 2026 09:43
MaxHeimbrock
marked this pull request as draft
August 14, 2026 09:59
This was referenced Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
First card of the platform-audio routing redesign's phase A (PAR-019): apps need a supported, cross-platform way to influence audio output routing (speaker vs. earpiece, ranked device-kind preferences, explicit device overrides, device-change notifications) instead of reaching into platform APIs themselves. This PR defines that public API surface on
PlatformAudio, purely in C#, shaped identically to what the later FFI-backed implementation will expose — so nothing written against it is throwaway when the plumbing is swapped underneath.Changes
AudioOutputKindenum (Unknown,Earpiece,Speaker,WiredHeadset,Bluetooth,Usb,HearingAid); numeric values mirror the planned FFI protocol enum one-to-one.AudioDevicegainsKindandIsSelected(documented as not yet populated — no backend reports them).PlatformAudio:OutputPreference— ranked automatic output policy; defaultBluetooth > WiredHeadset > Speaker > Earpiece.IsSpeakerOutputPreferred— documented precedence rule: the bool is sugar that only rewrites the relative order ofSpeaker/EarpieceinsideOutputPreference; the list is the single source of truth.SelectOutput(AudioDevice)/ClearOutputOverride()— sticky override of the automatic policy; bogus devices throwArgumentException.DevicesChangedevent (playout, recording), raised on the Unity main thread; safe to (un)subscribe acrossDispose.IRouteControllerbackend seam with per-platform registration:DesktopRouteControllerwraps the existing FFI enumeration/GUID selection;UnsupportedRouteControllercovers Android/iOS until their phase-A backends land (documented throws/no-ops — no silent fake success anywhere).SelectOutputthrows,DevicesChangedsubscribe/unsubscribe safe across dispose.