Skip to content

Commit b7c0eac

Browse files
authored
feat(ios): add AVAudioSession integration and refactor implementation (#1026)
* feat: add AVAudioSession integration for iOS device enumeration and buffer 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 * perf: inline performance-critical CoreAudio functions * refactor: simplify iOS CoreAudio error handling - Simplify error handling for device and stream config queries. - Remove unnecessary AudioUnit buffer size queries; use AVAudioSession. - Rename buffer size configuration function for clarity.
1 parent c9d8e2e commit b7c0eac

File tree

5 files changed

+314
-234
lines changed

5 files changed

+314
-234
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- CoreAudio: Configure device buffer to ensure predictable callback buffer sizes.
2424
- CoreAudio: Fix timestamp accuracy.
2525
- iOS: Fix example by properly activating audio session.
26+
- iOS: Add complete AVAudioSession integration for device enumeration and buffer size control.
2627
- WASAPI: Expose `IMMDevice` from WASAPI host Device.
2728
- WASAPI: Add `I24` and `U24` sample format support (24-bit samples stored in 4 bytes).
2829
- WASAPI: Update `windows` to >= 0.58, <= 0.62.

Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ libc = "0.2"
5454
audio_thread_priority = { version = "0.34.0", optional = true }
5555
jack = { version = "0.13.0", optional = true }
5656

57-
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
58-
mach2 = "0.5" # For access to mach_timebase type.
59-
6057
[target.'cfg(target_vendor = "apple")'.dependencies]
58+
mach2 = "0.5"
6159
coreaudio-rs = { version = "0.13.0", default-features = false, features = [
6260
"core_audio",
6361
"audio_toolbox",
@@ -82,6 +80,12 @@ objc2-core-foundation = { version = "0.3.1" }
8280
objc2-foundation = { version = "0.3.1" }
8381
objc2 = { version = "0.6.2" }
8482

83+
[target.'cfg(target_os = "ios")'.dependencies]
84+
objc2-avf-audio = { version = "0.3.1", default-features = false, features = [
85+
"std",
86+
"AVAudioSession",
87+
] }
88+
8589
[target.'cfg(target_os = "emscripten")'.dependencies]
8690
wasm-bindgen = { version = "0.2.89" }
8791
wasm-bindgen-futures = "0.4.33"

src/host/coreaudio/ios/enumerate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub type SupportedOutputConfigs = ::std::vec::IntoIter<SupportedStreamConfigRang
1212
pub struct Devices(VecIntoIter<Device>);
1313

1414
impl Devices {
15-
pub fn new() -> Result<Self, DevicesError> {
16-
Ok(Self::default())
15+
pub fn new() -> Self {
16+
Self::default()
1717
}
1818
}
1919

0 commit comments

Comments
 (0)