diff --git a/.github/workflows/coreaudio-rs.yml b/.github/workflows/coreaudio-rs.yml index 2889171f8..7e58123b6 100644 --- a/.github/workflows/coreaudio-rs.yml +++ b/.github/workflows/coreaudio-rs.yml @@ -52,6 +52,30 @@ jobs: - name: Build iphonesimulator feedback example run: cd examples/ios && xcodebuild ONLY_ACTIVE_ARCH=NO ARCHS=x86_64 -scheme coreaudio-ios-example -configuration Debug -derivedDataPath build -sdk iphonesimulator + apple-tier-3-check: + runs-on: macOS-14 + strategy: + matrix: + target: [ + aarch64-apple-visionos, + aarch64-apple-visionos-sim, + ] + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly + components: rust-src + + - name: Install Xcode Command Line Tools + # TODO: Remove this when xcode 15.2 or later is the default in + # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer + + - name: Build for visionOS target ${{matrix.target}} + run: cargo +nightly build -Z build-std --target=${{matrix.target}} + # Build the docs with all features to make sure docs.rs will work. macos-docs: runs-on: macOS-latest diff --git a/Cargo.toml b/Cargo.toml index 8ce822e7a..68254f0cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "coreaudio-rs" version = "0.12.0" authors = ["mitchmindtree ", "yupferris "] description = "A friendly rust interface for Apple's CoreAudio API." -keywords = ["core", "audio", "unit", "osx", "ios"] +keywords = ["core", "audio", "unit", "osx", "ios", "visionos"] readme = "README.md" license = "MIT/Apache-2.0" edition = '2018' @@ -30,3 +30,6 @@ core-foundation-sys = "0.8.3" all-features = true default-target = "x86_64-apple-darwin" targets = ["x86_64-apple-darwin", "x86_64-apple-ios"] + +[patch.crates-io] +coreaudio-sys = { git = "https://github.com/simlay/coreaudio-sys.git", branch = "tier-3-more-apple-targets"} diff --git a/src/audio_unit/macos_helpers.rs b/src/audio_unit/macos_helpers.rs index bdffd7545..a328fad20 100644 --- a/src/audio_unit/macos_helpers.rs +++ b/src/audio_unit/macos_helpers.rs @@ -1,5 +1,5 @@ /// This is a collection of helper functions for performing common tasks on macOS. -/// These functions are only implemented for macOS, not iOS. +/// These functions are only implemented for macOS, not iOS or visionOS. use crate::error::Error; use std::collections::VecDeque; use std::ffi::CStr; diff --git a/src/audio_unit/mod.rs b/src/audio_unit/mod.rs index 05695f052..d9d154c6a 100644 --- a/src/audio_unit/mod.rs +++ b/src/audio_unit/mod.rs @@ -382,6 +382,7 @@ pub fn set_property( /// Gets the value of an **AudioUnit** property. /// /// **Available** in iOS 2.0 and later. +/// **Available** in visionOS 1.0 and later. /// /// Parameters /// ---------- @@ -414,12 +415,13 @@ pub fn get_property( /// Gets the value of a specified audio session property. /// /// **Available** in iOS 2.0 and later. +/// **Available** in visionOS 1.0 and later. /// /// Parameters /// ---------- /// /// - **id**: The identifier of the property. -#[cfg(target_os = "ios")] +#[cfg(any(target_os = "ios", target_os = "visionos"))] pub fn audio_session_get_property(id: u32) -> Result { let mut size = ::std::mem::size_of::() as u32; unsafe { diff --git a/src/audio_unit/render_callback.rs b/src/audio_unit/render_callback.rs index 57c2628bf..26ad07b8c 100644 --- a/src/audio_unit/render_callback.rs +++ b/src/audio_unit/render_callback.rs @@ -559,7 +559,10 @@ impl AudioUnit { let buffer_frame_size: u32 = self.get_property(id, Scope::Global, Element::Output)?; buffer_frame_size }; - #[cfg(target_os = "ios")] + + // TODO: watchOS and tvOS. It's unclear how to get the frame buffer size on watchOS or + // tvOS. + #[cfg(any(target_os = "ios", target_os = "visionos"))] let mut buffer_frame_size: u32 = { let id = sys::kAudioSessionProperty_CurrentHardwareIOBufferDuration; let seconds: f32 = super::audio_session_get_property(id)?;