High Performance Audio
summary
Measured Android output latency falls from >100 ms (four 1,024-frame buffers → ~92 ms) down to sub-20 ms by changing buffer sizes, using an oscilloscope and LED/photodiode rig to timestamp audio vs light, and tracing with systrace. Fixes include using OpenSL ES callbacks, running audio on SCHED_FIFO within a cgroups 5% CPU budget, avoiding blocking calls (no sprintf/mutexes), single-reader single-writer ring buffers, matching native sample rate/buffer (44.1 vs 48 kHz, Nexus 4 native 48 kHz, 240-frame buffer) and thereby eliminating underruns and periodic 16-buffer glitches.
AI-written summary · about
chapters (50)
- 0:00Introduction
- 1:19Glenn Kasten
- 3:06Introducing Rafe
- 4:08Project Butter
- 4:40Latency
- 5:55Measure Everything
- 7:07LED
- 8:39Unoptimized Audio Pipeline
- 9:10Why are the buffers so big
- 10:55Experiment
- 12:03Under Ends
- 14:14Data Collection
- 15:57Jitter
- 16:24Timing
- 17:53Nice Values
- 18:46Context Tracer
- 19:00The Smoking Gun
- 19:22Glenns Contacts
- 19:45Scheduling
- 20:08CPU Pi
- 20:32Timing Diagrams
- 20:48CFS
- 22:08SCHEDFIFO
- 22:51Dima
- 23:17Control Groups
- 23:34Fixed Priority
- 24:13Low Latency
- 24:40Jitter Reduction
- 25:08Audio Subsystem
- 25:36Fast Audio Path
- 26:12Fast Mixer
- 26:53Deep Buffer Path
- 27:40Latency Reduction
- 28:36Random Noise
- 29:17Buffer Size Sample Rate
- 30:13Audible Glitch
- 31:32Audio Playback
- 32:11High Priority
- 33:13systrace
- 33:53glitch
- 34:16UI thread
- 34:57Priority inversion
- 35:41Sprintf
- 36:06Nonblocking techniques
- 36:18Singlewriter ring buffers
- 36:40Using ring buffers
- 37:16Results
- 38:15Kick 7F
- 38:51Hardware partners
- 39:17Website
related talks
39mDemystifying Low Latency Audio on Android
20mLow latency Audio - because your ears are worth it
17mA Brief History of Real Time Audio (or Wasn’t That API Deprecated?)
40mAndroid high performance baby
38mAndroid Audio: Beyond Winning On It
16mUnderstanding and Implementing Audio on Android
36mDeep Dive into Kotlin Flow Buffering and Execution Models Using Real-Time Audio Processing
32mOptimizing Android games performance
