Skip to content

Conversation

roderickvd
Copy link
Member

Part of the campaign to implement fixed buffer sizes across all hosts.

  • Implemented BufferSize::Fixed using AVAudioSession
  • Query actual sample rates, channel counts, and buffer size ranges from AVAudioSession
  • Consolidated input/output stream setup logic and extracted common buffer processing
  • Added #[inline] to hot-path callback functions

Admission: this came from pure code review - I don't have iOS development hardware myself. @NightBlaze - since you're an iOS user, would you take this for a spin?

- Query actual device buffer size for accurate latency on macOS and iOS
- Use device buffer size instead of callback buffer size when available
- Add documentation and tests clarifying CoreAudio buffer model and behavior
…uffer size

- Use AVAudioSession for device capabilities and buffer size control
- Support BufferSize::Fixed via setPreferredIOBufferDuration
- Query buffer size from both AVAudioSession and RemoteIO for accuracy
- Update supported config queries to reflect AVAudioSession state
- Refactor input/output callbacks to use shared buffer extraction
@roderickvd roderickvd force-pushed the feat/ios-avaudiosession branch from 76a9d5a to 8717290 Compare September 29, 2025 20:25
@NightBlaze
Copy link
Contributor

@roderickvd I think Copilot could handle this task better than I can. I've only worked with audio on iOS at a really basic level and I'm not familiar with a lot of the details.

@roderickvd
Copy link
Member Author

If you would, it’d already be a great help if you could confirm that it actually works 😄 without regressions.

///
/// This queries the current IO buffer duration from AVAudioSession and converts
/// it to frames based on the current sample rate.
fn get_audio_session_buffer_size() -> Result<usize, coreaudio::Error> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Result? It seems never fail.

@NightBlaze
Copy link
Contributor

Tested on sim and real device, everything works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants