Skip to content
Merged
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
30 changes: 29 additions & 1 deletion .github/workflows/platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env:
# MSRV varies by backend due to platform-specific dependencies
MSRV_AAUDIO: "1.85"
MSRV_ALSA: "1.82"
MSRV_COREAUDIO: "1.80"
MSRV_COREAUDIO: "1.85"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please document this MSRV and mach2 bump in the changelog.

MSRV_JACK: "1.82"
MSRV_PIPEWIRE: "1.85"
MSRV_PULSEAUDIO: "1.88"
Expand Down Expand Up @@ -405,6 +405,33 @@ jobs:
working-directory: examples/ios-feedback
run: xcodebuild -scheme cpal-ios-example -configuration Debug -derivedDataPath build -sdk iphonesimulator -arch arm64

# tvOS (Tier 3 target, requires nightly + build-std)
tvos:
runs-on: macOS-latest
env:
TARGET: aarch64-apple-tvos
steps:
- uses: actions/checkout@v5

- name: Install Rust nightly (for build-std)
uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: tvos

- name: Check examples (default features)
run: cargo +nightly check --examples --workspace --verbose --target ${{ env.TARGET }} -Z build-std

- name: Check examples (no default features)
run: cargo +nightly check --examples --no-default-features --workspace --verbose --target ${{ env.TARGET }} -Z build-std

- name: Check examples (all features)
run: cargo +nightly check --examples --all-features --workspace --verbose --target ${{ env.TARGET }} -Z build-std

# WebAssembly - wasm-bindgen
wasm-bindgen:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -546,6 +573,7 @@ jobs:
- macos
- android
- ios
- tvos
- wasm-bindgen
- wasm-audioworklet
- wasm-wasip1
Expand Down
35 changes: 28 additions & 7 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,33 @@ jobs:
run: cargo clippy --all --target ${{ matrix.target }} ${{ matrix.features }} -- -D warnings

lints-nightly:
name: clippy-WASM-worklet
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# WASM - AudioWorklet (requires atomics + build-std)
- target: wasm32-unknown-unknown
name: WASM-worklet
features: --features audioworklet
os: ubuntu-latest
build_std: std,panic_abort
rustflags: -C target-feature=+atomics,+bulk-memory,+mutable-globals

# tvOS - CoreAudio (Tier 3 target)
- target: aarch64-apple-tvos
name: tvOS
features: ""
os: macOS-latest
build_std: std
rustflags: ""

name: clippy-${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5

- name: Cache Linux audio packages
if: runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libasound2-dev libjack-jackd2-dev libjack-jackd2-0 libdbus-1-dev libpipewire-0.3-dev
Expand All @@ -128,14 +149,14 @@ jobs:
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy, rust-src
targets: wasm32-unknown-unknown
targets: ${{ matrix.target }}

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: clippy-wasm32-worklet
key: clippy-${{ matrix.target }}-${{ matrix.name }}

- name: Run clippy (audioworklet)
- name: Run clippy
env:
RUSTFLAGS: -C target-feature=+atomics,+bulk-memory,+mutable-globals
run: cargo +nightly clippy --all --target wasm32-unknown-unknown --features audioworklet -Z build-std=std,panic_abort -- -D warnings
RUSTFLAGS: ${{ matrix.rustflags }}
run: cargo +nightly clippy --all --target ${{ matrix.target }} ${{ matrix.features }} -Z build-std=${{ matrix.build_std }} -- -D warnings
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
backends to override it.
- `StreamTrait::now()` to query the current instant on the stream's clock.
- **ALSA**: `device_by_id()` now accepts PCM shorthand names such as `hw:0,0` and `plughw:foo`.
- **CoreAudio**: tvOS target support (Tier 3, requires nightly).
- **PipeWire**: New host for Linux and some BSDs using the PipeWire API.
- **PulseAudio**: New host for Linux and some BSDs using the PulseAudio API.

Expand Down Expand Up @@ -50,6 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **ASIO**: Stream error callback now receives `StreamError::StreamInvalidated` when the driver
reports a sample rate change (`sampleRateDidChange`) of 1 Hz or more from the configured rate.
- **AudioWorklet**: `BufferSize::Fixed` now sets `renderSizeHint` on the `AudioContext`.
- **CoreAudio**: Bump MSRV to 1.85.
- **CoreAudio**: Bump `mach2` to 0.6 (uses `core::ffi` instead of `libc`, enables tvOS builds).
- **CoreAudio**: Timestamps now include device latency and safety offset.
- **CoreAudio**: Poisoned stream mutex in stream functions now propagate panics.
- **CoreAudio**: Physical stream format is now set directly on the hardware device.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ futures = { version = "0.3", optional = true }
pipewire = { version = "0.9", optional = true, features = ["v0_3_53"] }

[target.'cfg(target_vendor = "apple")'.dependencies]
mach2 = "0.5"
mach2 = "0.6"
coreaudio-rs = { version = "0.14", default-features = false, features = [
"core_audio",
"audio_toolbox",
Expand Down Expand Up @@ -147,7 +147,7 @@ objc2 = { version = "0.6" }
[target.'cfg(target_os = "macos")'.dependencies]
jack = { version = "0.13", optional = true }

[target.'cfg(target_os = "ios")'.dependencies]
[target.'cfg(any(target_os = "ios", target_os = "tvos"))'.dependencies]
block2 = "0.6"
objc2-foundation = { version = "0.3", features = [
"block2",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The minimum Rust version required depends on which audio backend and features yo

- **AAudio (Android):** Rust **1.85**
- **ALSA (Linux/BSD):** Rust **1.82**
- **CoreAudio (macOS/iOS):** Rust **1.80**
- **CoreAudio (macOS/iOS/tvOS):** Rust **1.85**
- **JACK (Linux/BSD/macOS/Windows):** Rust **1.82**
- **PipeWire (Linux/BSD):** Rust **1.85**
- **PulseAudio (Linux/BSD):** Rust **1.88**
Expand Down
8 changes: 5 additions & 3 deletions src/host/coreaudio/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! CoreAudio backend implementation.
//!
//! Default backend on macOS and iOS.
//! Default backend on macOS, iOS, and tvOS.

use objc2_core_audio_types::{
kAudioFormatFlagIsFloat, kAudioFormatFlagIsPacked, kAudioFormatFlagIsSignedInteger,
Expand All @@ -12,12 +12,14 @@ use crate::{BuildStreamError, SupportedStreamConfigsError};

use crate::{BackendSpecificError, SampleFormat, StreamConfig};

#[cfg(target_os = "ios")]
// iOS and tvOS share the same CoreAudio / AudioUnit surface (RemoteIO,
// AVAudioSession), so both target the `ios` submodule.
#[cfg(not(target_os = "macos"))]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How does this work on tvOS? Does that use the same API surface as iOS?

mod ios;
#[cfg(target_os = "macos")]
mod macos;

#[cfg(target_os = "ios")]
#[cfg(not(target_os = "macos"))]
#[allow(unused_imports)]
pub use self::ios::{
enumerate::{Devices, SupportedInputConfigs, SupportedOutputConfigs},
Expand Down
5 changes: 2 additions & 3 deletions src/host/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) mod asio;
pub(crate) mod audioworklet;
#[cfg(windows)]
pub(crate) mod com;
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(target_vendor = "apple")]
pub(crate) mod coreaudio;
#[cfg(all(
feature = "jack",
Expand Down Expand Up @@ -66,8 +66,7 @@ pub(crate) mod custom;
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "macos",
target_os = "ios",
target_vendor = "apple",
target_os = "android",
all(target_arch = "wasm32", feature = "wasm-bindgen"),
)))]
Expand Down
10 changes: 4 additions & 6 deletions src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,9 +811,9 @@ mod platform_impl {
}
}

#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(target_vendor = "apple")]
mod platform_impl {
#[cfg_attr(docsrs, doc(cfg(any(target_os = "macos", target_os = "ios"))))]
#[cfg_attr(docsrs, doc(cfg(target_vendor = "apple")))]
pub use crate::host::coreaudio::Host as CoreAudioHost;
#[cfg(all(feature = "jack", target_os = "macos"))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "jack", target_os = "macos"))))]
Expand Down Expand Up @@ -915,8 +915,7 @@ mod platform_impl {
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "macos",
target_os = "ios",
target_vendor = "apple",
target_os = "android",
all(target_arch = "wasm32", feature = "wasm-bindgen"),
)))]
Expand All @@ -929,8 +928,7 @@ mod platform_impl {
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "macos",
target_os = "ios",
target_vendor = "apple",
target_os = "android",
all(target_arch = "wasm32", feature = "wasm-bindgen")
))))
Expand Down
Loading