Skip to content

android: Optimize Oboe audio implementation for ultra-low latency - #119

Merged
winnerspiros merged 1 commit into
masterfrom
android-oboe-optimization-13753788320681443518
Mar 30, 2026
Merged

android: Optimize Oboe audio implementation for ultra-low latency#119
winnerspiros merged 1 commit into
masterfrom
android-oboe-optimization-13753788320681443518

Conversation

@google-labs-jules

Copy link
Copy Markdown

This PR optimizes the Oboe audio implementation on Android to achieve ultra-low latency (<10ms) and eliminate audio artifacts ("crusty" sound) caused by buffer underruns on modern devices like the Samsung S23 Ultra.

The optimization strategy includes:

  1. Zero-Copy Rendering: Instead of summing audio samples in C#, we now use a BassMix master mixer that renders directly into Oboe's native memory. This bypasses the C# garbage collector and P/Invoke overhead during the audio callback.
  2. Sample Rate Sync: We now synchronize BASS's internal processing rate with the hardware's native sample rate (e.g., 48kHz), eliminating resampling latency.
  3. Stability Tuning: The hardware buffer is now tuned to 2x the burst size, which provides a reliable safety margin for the MMAP (Direct-to-Hardware) path without adding perceptible delay.
  4. Performance Hints: Leveraged the Android Dynamic Performance Framework (ADPF) to ensure the audio thread receives maximum priority from the kernel.

PR created automatically by Jules for task 13753788320681443518 started by @winnerspiros

This overhaul transitions the Oboe audio path to a zero-copy "Direct Render" approach, significantly reducing latency and fixing the "crusty" sound (buffer underruns) on high-end devices like the S23 Ultra.

Key changes:
- Synchronized BASS initialization to the hardware sample rate (detected via Oboe).
- Implemented a BASS master mixer to offload summation to native code.
- Switched to zero-copy delivery: BASS now renders directly into Oboe's native memory.
- Tuned hardware buffer to 2x burst for stable MMAP (Direct-to-Hardware) pathing.
- Enabled ADPF (Android Dynamic Performance Framework) for improved thread priority.
@google-labs-jules

Copy link
Copy Markdown
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@winnerspiros
winnerspiros merged commit 4835806 into master Mar 30, 2026
0 of 14 checks passed
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