Skip to content

Commit 70f9a23

Browse files
committed
doc(emscripten): improve upgrading guide
1 parent aa4876a commit 70f9a23

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

UPGRADING.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This guide covers breaking changes requiring code updates. See [CHANGELOG.md](CH
1414
- [ ] Update `StreamInstant::new(secs, nanos)` call sites: `secs` is now `u64`.
1515
- [ ] Update `StreamInstant::from_nanos(nanos)` call sites: `nanos` is now `u64`.
1616
- [ ] Update `duration_since` call sites to pass by value (drop the `&`).
17-
- [ ] Change `emscripten` host to `webaudio` in Wasm builds.
17+
- [ ] Migrate `wasm32-unknown-emscripten` to `wasm32-unknown-unknown` if possible.
1818

1919
## 1. Error enums are now `#[non_exhaustive]`
2020

@@ -135,19 +135,29 @@ StreamInstant::new(0_u64, 0);
135135

136136
**Why:** All audio host clocks are positive and monotonic; they are never negative.
137137

138-
## 5. `emscripten` host removed in favor of `webaudio`
138+
## 5. `wasm32-unknown-emscripten` target removed
139139

140-
**What changed:** The `emscripten` host was broken and is now removed. Use the `webaudio` host instead for Wasm builds.
140+
**What changed:** The `emscripten` audio host and the `wasm32-unknown-emscripten` build target are no longer supported.
141141

142-
```rust
142+
Migrate to `wasm32-unknown-unknown` and enable the `wasm-bindgen` feature:
143+
144+
```toml
143145
# Before (v0.17)
144146
cpal = { version = "0.17", features = ["emscripten"] }
145147

146148
# After (v0.18)
147-
cpal = { version = "0.18", features = ["webaudio"] }
149+
cpal = { version = "0.18", features = ["wasm-bindgen"] }
150+
```
151+
152+
Then select the `webaudio` host at runtime:
153+
154+
```rust
155+
let host = cpal::host_from_id(cpal::HostId::WebAudio)?;
148156
```
149157

150-
**Why:** The `webaudio` host uses the modern Web Audio API and is compatible with current Emscripten versions. The old `emscripten` host relied on deprecated APIs that are no longer supported.
158+
If you must target `wasm32-unknown-emscripten` specifically, consider using OpenAL or another audio approach that supports that target, as cpal no longer provides audio on Emscripten.
159+
160+
**Why:** The old `emscripten` host relied on deprecated Emscripten audio APIs that are no longer functional.
151161

152162
---
153163

0 commit comments

Comments
 (0)