Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial changes for adding visionOS support #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/coreaudio-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
toolchain: stable
- name: cargo test
run: cargo test --verbose
- name: Run sign example
run: cargo run --example sine
Copy link
Member Author

Choose a reason for hiding this comment

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

This is due to #112.

# TODO: These don't work as of 2020-12-06, but they should.
# - name: cargo test - no features
# run: cargo test --no-default-features --verbose
Expand Down Expand Up @@ -52,6 +50,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
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "coreaudio-rs"
version = "0.12.0"
authors = ["mitchmindtree <[email protected]>", "yupferris <[email protected]>"]
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'
Expand All @@ -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"}
2 changes: 1 addition & 1 deletion src/audio_unit/macos_helpers.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/audio_unit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ pub fn set_property<T>(
/// Gets the value of an **AudioUnit** property.
///
/// **Available** in iOS 2.0 and later.
/// **Available** in visionOS 1.0 and later.
///
/// Parameters
/// ----------
Expand Down Expand Up @@ -414,12 +415,13 @@ pub fn get_property<T>(
/// 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<T>(id: u32) -> Result<T, Error> {
let mut size = ::std::mem::size_of::<T>() as u32;
unsafe {
Expand Down
5 changes: 4 additions & 1 deletion src/audio_unit/render_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
Loading