Skip to content

Platform Audio: device-selection capability + explicit mobile no-op#1156

Open
MaxHeimbrock wants to merge 3 commits into
mainfrom
max/platform-audio-device-selection
Open

Platform Audio: device-selection capability + explicit mobile no-op#1156
MaxHeimbrock wants to merge 3 commits into
mainfrom
max/platform-audio-device-selection

Conversation

@MaxHeimbrock

Copy link
Copy Markdown
Contributor

Summary

Makes platform-audio device selection behave explicitly per platform and exposes a capability flag clients can query.

  • PlatformAudioInfo.device_selection_supported (new proto field) — surfaced so bindings/clients can hide device-picker UI where selection has no effect.
  • PlatformAudio::supports_device_selection()false on iOS/Android, true on desktop.
  • Explicit mobile no-op: set_recording_device / set_playout_device / switch_recording_device / switch_playout_device short-circuit to Ok(()) on iOS/Android before touching native, instead of relying on native device-reporting quirks (iOS RecordingDeviceName returns -1; Android reports a single GUID-less device).
  • Desktop is now strict: webrtc-sys set_*_device_by_guid no longer falls back to index 0 on a GUID miss — an unknown GUID returns falseDeviceNotFound. This lets a caller detect "the saved device is gone" instead of silently landing on the default. Mobile never reaches this path now.

Why

The previous "no-op on mobile" was accidental — it fell out of the index-0 fallback in audio_device_controller.cpp, which conflated the mobile-unsupported case with a legitimate desktop error (stale GUID).

Notes

  • Branch is based on the commit currently pinned by the Unity SDK submodule (an ancestor of main); may need a rebase onto main before merge.
  • The Unity-side consumer (regenerated C# proto, PlatformAudio.IsDeviceSelectionSupported, sample + tests) is a stacked PR in client-sdk-unity that bumps the submodule to this commit.
  • cargo fmt applied; cargo build -p livekit-ffi clean.

🤖 Generated with Claude Code

Device selection is only meaningful on desktop; on iOS/Android the OS owns
audio routing (AVAudioSession / AudioManager). Previously the "no-op on mobile"
was accidental — a fallback in the native layer selected index 0 whenever a
GUID didn't match — which also silently swallowed a real desktop error (a saved
device that no longer exists).

- proto: add PlatformAudioInfo.device_selection_supported.
- PlatformAudio::supports_device_selection() — false on iOS/Android, true on
  desktop. Lets clients hide device-picker UI where selection has no effect.
- set_/switch_ recording/playout device short-circuit to Ok(()) on mobile before
  touching native, so the no-op is explicit rather than dependent on native
  device-reporting quirks (iOS RecordingDeviceName -1; Android empty GUID).
- ffi server populates the new field from the accessor.
- webrtc-sys: drop the index-0 fallback in set_*_device_by_guid so an unknown
  GUID returns false -> DeviceNotFound on desktop; mobile never reaches it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Changeset

The following package versions will be affected by this PR:

Package Bump
libwebrtc patch
livekit patch
livekit-ffi patch
webrtc-sys patch

@MaxHeimbrock MaxHeimbrock changed the title platform_audio: device-selection capability + explicit mobile no-op Platform Audio: device-selection capability + explicit mobile no-op Jun 11, 2026
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.

1 participant