Skip to content

Commit ab30c5f

Browse files
committed
chore: bump version to 0.17.0 and add upgrade guide
1 parent e32ee65 commit ab30c5f

3 files changed

Lines changed: 207 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Unreleased
1+
# Version 0.17.0 (2025-12-08)
22

33
- Add `DeviceTrait::id` method that returns a stable audio device ID.
44
- Add `HostTrait::device_by_id` to select a device by its stable ID.
@@ -28,11 +28,12 @@
2828
- ASIO: Fix linker flags for MinGW cross-compilation.
2929
- ASIO: Add packed(4) to representation of ASIO time structs in bindings.
3030
- ASIO: Add handling for `kAsioResetRequest` message to prevent driver UI becoming unresponsive.
31-
- CI: Added native ARM64 Linux support in GitHub Actions.
31+
- CI: Add native ARM64 Linux support in GitHub Actions.
3232
- CI: Fix cargo publish to trigger on GitHub releases instead of every master commit.
3333
- CI: Replace cargo install commands with cached tool installation for faster builds.
3434
- CI: Update actions to latest versions (checkout@v5, rust-cache@v2).
3535
- CI: Verify compatibility with windows crates since v0.59.
36+
- CI: Add sanitization checks on Linux and macOS.
3637
- CoreAudio: Change `Device::supported_configs` to return a single element containing the available sample rate range when all elements have the same `mMinimum` and `mMaximum` values.
3738
- CoreAudio: Change default audio device detection to be lazy when building a stream, instead of during device enumeration.
3839
- CoreAudio: Add `i8`, `i32` and `I24` sample format support (24-bit samples stored in 4 bytes).
@@ -55,8 +56,9 @@
5556
- WASAPI: Add `I24` and `U24` sample format support (24-bit samples stored in 4 bytes).
5657
- WASAPI: Update `windows` to >= 0.59, <= 0.62.
5758
- WASAPI: Add `Send` and `Sync` implementations to `Stream`.
58-
- WebAudio: Removed optional `wee-alloc` feature for security reasons.
59+
- WebAudio: Remove optional `wee-alloc` feature for security reasons.
5960
- WebAudio: Add `Send` and `Sync` implementations to `Stream`.
61+
- WebAudio: Add AudioWorklet-based Host for lower latency when Wasm atomics are enabled.
6062
- WebAudio: Add `BufferSize::Fixed` validation against supported range.
6163

6264
# Version 0.16.0 (2025-06-07)

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cpal"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
description = "Low-level cross-platform audio I/O library in pure Rust."
55
repository = "https://github.com/RustAudio/cpal"
66
documentation = "https://docs.rs/cpal"

UPGRADING.md

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# Upgrading from v0.16 to v0.17
2+
3+
This guide covers breaking changes requiring code updates. See [CHANGELOG.md](CHANGELOG.md) for the complete list of changes and improvements.
4+
5+
## Breaking Changes Checklist
6+
7+
- [ ] Replace `SampleRate(n)` with plain `n` values
8+
- [ ] Update `windows` crate to >= 0.59, <= 0.62 (Windows only)
9+
- [ ] Update `alsa` crate to 0.10 (Linux only)
10+
- [ ] Remove `wee_alloc` feature from Wasm builds (if used)
11+
- [ ] Wrap CoreAudio streams in `Arc` if you were cloning them (macOS only)
12+
- [ ] Handle `BuildStreamError::StreamConfigNotSupported` for `BufferSize::Fixed` (JACK, strict validation)
13+
- [ ] Update device name matching if using ALSA (Linux only)
14+
15+
**Recommended migrations:**
16+
- [ ] Replace deprecated `device.name()` calls with `device.description()` or `device.id()`
17+
18+
---
19+
20+
## 1. SampleRate is now a u32 type alias
21+
22+
**What changed:** `SampleRate` changed from a struct to a `u32` type alias.
23+
24+
```rust
25+
// Before (v0.16)
26+
use cpal::SampleRate;
27+
let config = StreamConfig {
28+
channels: 2,
29+
sample_rate: SampleRate(44100),
30+
buffer_size: BufferSize::Default,
31+
};
32+
33+
// After (v0.17)
34+
let config = StreamConfig {
35+
channels: 2,
36+
sample_rate: 44100,
37+
buffer_size: BufferSize::Default,
38+
};
39+
```
40+
41+
**Impact:** Remove `SampleRate()` constructor calls. The type is now just `u32`, so use integer literals or variables directly.
42+
43+
---
44+
45+
## 2. Device::name() deprecated (soft deprecation)
46+
47+
**What changed:** `Device::name()` is deprecated in favor of `id()` and `description()`.
48+
49+
```rust
50+
// Old (still works but shows deprecation warning)
51+
let name = device.name()?;
52+
53+
// New: For user-facing display
54+
let desc = device.description()?;
55+
println!("Device: {}", desc); // or desc.name() for just the name
56+
57+
// New: For stable identification and persistence
58+
let id = device.id()?;
59+
let id_string = id.to_string(); // Save this
60+
// Later...
61+
let device = host.device_by_id(&id_string.parse()?)?;
62+
```
63+
64+
**Impact:** Deprecation warnings only. The old API still works in v0.17. Update when convenient to prepare for future versions.
65+
66+
**Why:** Separates stable device identification (`id()`) from human-readable names (`description()`).
67+
68+
---
69+
70+
## 3. CoreAudio Stream no longer Clone (macOS)
71+
72+
**What changed:** On macOS, `Stream` no longer implements `Clone`. Use `Arc` instead.
73+
74+
```rust
75+
// Before (v0.16) - macOS only
76+
let stream = device.build_output_stream(&config, data_fn, err_fn, None)?;
77+
let stream_clone = stream.clone();
78+
79+
// After (v0.17) - all platforms
80+
let stream = Arc::new(device.build_output_stream(&config, data_fn, err_fn, None)?);
81+
let stream_clone = Arc::clone(&stream);
82+
```
83+
84+
**Why:** Removed as part of making `Stream` implement `Send` on macOS.
85+
86+
---
87+
88+
## 4. BufferSize behavior changes
89+
90+
### BufferSize::Default now uses host defaults
91+
92+
**What changed:** `BufferSize::Default` now defers to the audio host/device defaults instead of applying cpal's opinionated defaults.
93+
94+
**Impact:** Buffer sizes may differ from v0.16, affecting latency characteristics:
95+
- **Lower latency** in most cases (hosts typically choose sensible defaults)
96+
- **May underrun** on resource-constrained systems previously relying on larger cpal defaults
97+
- **Better integration** with system audio configuration (e.g., PulseAudio, PipeWire, JACK)
98+
99+
**Migration:** If you experience underruns or need specific latency, use `BufferSize::Fixed(size)` instead of relying on defaults.
100+
101+
**Platform-specific notes:**
102+
- **ALSA:** Previously used cpal's hardcoded 25ms periods / 100ms buffer, now uses device defaults
103+
- **All platforms:** Default buffer sizes now match what the host audio system expects
104+
105+
### BufferSize::Fixed validation stricter
106+
107+
**What changed:** Several backends now reject invalid `BufferSize::Fixed` requests instead of silently adjusting:
108+
109+
- **ALSA:** Validates against hardware constraints (was: rounded to nearest)
110+
- **JACK:** Must exactly match server buffer size (was: silently ignored)
111+
- **Emscripten/WebAudio:** Validates min/max range
112+
- **ASIO:** Stricter lower bound validation
113+
114+
```rust
115+
// Handle validation errors
116+
let mut config = StreamConfig {
117+
channels: 2,
118+
sample_rate: 44100,
119+
buffer_size: BufferSize::Fixed(512),
120+
};
121+
122+
match device.build_output_stream(&config, data_fn, err_fn, None) {
123+
Ok(stream) => { /* success */ },
124+
Err(BuildStreamError::StreamConfigNotSupported) => {
125+
config.buffer_size = BufferSize::Default; // Fallback
126+
device.build_output_stream(&config, data_fn, err_fn, None)?
127+
},
128+
Err(e) => return Err(e),
129+
}
130+
```
131+
132+
**JACK users:** Use `BufferSize::Default` to automatically match the server's configured size.
133+
134+
---
135+
136+
## 5. Dependency updates
137+
138+
Update these dependencies if you use them directly:
139+
140+
```rust
141+
[dependencies]
142+
cpal = "0.17"
143+
144+
# Platform-specific (if used directly):
145+
alsa = "0.10" # Linux only
146+
windows = { version = ">=0.58, <=0.62" } # Windows only
147+
audio_thread_priority = "0.34" # All platforms
148+
```
149+
150+
---
151+
152+
## 6. ALSA device enumeration changed (Linux)
153+
154+
**What changed:** Device enumeration now returns all devices from `aplay -L`. v0.16 had a regression that only returned card names, missing all device variants.
155+
156+
```rust
157+
# v0.16: Only card names ("Loopback", "HDA Intel PCH")
158+
# v0.17: All aplay -L devices (default, hw:CARD=X,DEV=Y, plughw:, front:, surround51:, etc.)
159+
```
160+
161+
**Impact:** Many more devices will be enumerated. Device names/IDs will be much more detailed. Update any code that matches specific ALSA device names.
162+
163+
---
164+
165+
## 7. Wasm wee_alloc feature removed
166+
167+
**What changed:** The optional `wee_alloc` feature was removed for security reasons.
168+
169+
```rust
170+
# Before (v0.16)
171+
cpal = { version = "0.16", features = ["wasm-bindgen", "wee_alloc"] }
172+
173+
# After (v0.17)
174+
cpal = { version = "0.17", features = ["wasm-bindgen"] }
175+
```
176+
177+
---
178+
179+
## Notable Non-Breaking Improvements
180+
181+
v0.17 also includes significant improvements that don't require code changes:
182+
183+
- **Stable device IDs:** New `device.id()` returns persistent device identifiers that survive reboots/reconnections. Use `host.device_by_id()` to reliably select saved devices.
184+
- **Streams are Send+Sync everywhere:** All platforms now support moving/sharing streams across threads
185+
- **24-bit sample formats:** Added `I24`/`U24` support on ALSA, CoreAudio, WASAPI, ASIO
186+
- **Custom host support:** Implement your own `Host`/`Device`/`Stream` for proprietary platforms
187+
- **WebAudio AudioWorklet:** Lower latency web audio backend when Wasm atomics are enabled
188+
- **Predictable buffer sizes:** CoreAudio and AAudio now ensure consistent callback buffer sizes
189+
- **Expanded sample rate support:** ALSA supports 12, 24, 352.8, 384, 705.6, and 768 kHz
190+
- **WASAPI advanced interop:** Exposed `IMMDevice` for Windows COM interop scenarios
191+
- **Platform improvements:** macOS loopback recording (14.6+), better ALSA performance, improved timestamp accuracy, iOS AVAudioSession integration, JACK on all platforms
192+
193+
See [CHANGELOG.md](CHANGELOG.md) for complete details and [examples/](examples/) for updated usage patterns.
194+
195+
---
196+
197+
## Getting Help
198+
199+
- Full details: [CHANGELOG.md](CHANGELOG.md)
200+
- Examples: [examples/](examples/)
201+
- Issues: https://github.com/RustAudio/cpal/issues

0 commit comments

Comments
 (0)