Object-Oriented Design of an AirPods Audio Route Manager
Last updated: November 29, 2026
Quick Overview
Design the classes that decide which output device (AirPods, Bluetooth speaker, CarPlay, wired, built-in speaker) is the active audio route as devices connect, disconnect, and leave the ear.
Apple
November 29, 20260
0
0 solved
Design the classes that decide which output device (AirPods, Bluetooth speaker, CarPlay, wired, built-in speaker) is the active audio route as devices connect, disconnect, and leave the ear.
Apple's audio stack has to pick routes automatically and still respect a user's manual choice from Control Center. The interviewer looks for clean modeling of devices and policy, deterministic tie-breaking, and observer notifications for the UI and playback engine.
What the Interviewer Expects
- Separates the device model from the routing policy so the policy can change
- Defines a deterministic priority: device kind, then recency of connection
- Honors a manual selection until that device disappears or becomes unusable
- Notifies observers only when the active route actually changes
- Covers in-ear detection, the always-present built-in speaker, and duplicate connect events
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you support routing calls and media to different devices at the same time?
- How would automatic switching between a user's iPhone, iPad, and Mac fit into this design?
- How would you unit test the policy without real Bluetooth hardware?
- Where would you put per-app overrides, such as a navigation app that wants the car speaker?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
- Track connected devices and expose one active route.
- Automatic choice: AirPods in ear beat other Bluetooth, which beats wired, which beats CarPlay, which beats the speaker. Ties go to the most rec...
High-Level Design
Kind(IntEnum) encodes priority so ordering is data, not if-chains.AudioDeviceis a dataclass with anis_usable()rule.AudioRouteManagerowns devices, connection order, the manual choi...