Skip to content

feat(audio): AudioManager audio session management#1108

Draft
hiroshihorie wants to merge 2 commits into
mainfrom
hiroshi/audio-manager-api
Draft

feat(audio): AudioManager audio session management#1108
hiroshihorie wants to merge 2 commits into
mainfrom
hiroshi/audio-manager-api

Conversation

@hiroshihorie

@hiroshihorie hiroshihorie commented Jun 12, 2026

Copy link
Copy Markdown
Member

What

First-class, process-wide audio session control on AudioManager — replacing session/routing behavior that was scattered across Hardware, track/audio_management.dart, and implicit native defaults.

API

Typed session configurationAudioSessionOptions with communication() / media() presets and per-platform escape hatches:

await AudioManager.instance.setAudioSessionOptions(
  const AudioSessionOptions.communication(),
);
  • AppleAudioSessionConfiguration: category / mode / category options
  • AndroidAudioSessionConfiguration: audio mode, focus mode, stream type, audio attributes usage/content types

Automatic vs manual managementAudioSessionManagementMode. Default automatic preserves today's behavior (the SDK tracks local/remote audio presence and configures the session). manual lets apps that own their audio lifecycle drive it themselves.

Android session backend — a new AudioSwitch-based LKAudioSwitchManager in the native plugin handles device routing, audio focus acquisition/release, and communication-device management, driven by configureAndroidAudioSession / stopAndroidAudioSession channel methods.

Unified speakerphone/routingsetSpeakerphoneOn, preferSpeakerOutput, forceSpeakerOutput move to AudioManager with consistent Apple (overrideOutputAudioPort) and Android (AudioSwitch) implementations.

Compatibility

Hardware's audio members become deprecated forwarders to AudioManager — migration, not removal. Room uses AudioManager internally; no behavior change for apps that touch nothing.

Why AudioManager

Platform audio sessions are global to the app process — they cannot be per-Room or per-track. This is the second half of making AudioManager the home for process-wide audio: #1107 added the engine-wide processing state read-back, this adds session/routing control — mirroring the Swift SDK's AudioManager.

Notes

Process-wide audio session control on AudioManager: session options and
management modes (automatic/manual), Android audio session configuration
(mode/focus/routing) backed by an AudioSwitch-based manager in the native
plugin, Apple speakerphone routing, and speaker output preferences.
Platform audio sessions are global to the app process, so this lives on
AudioManager rather than Room.
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