cpal icon indicating copy to clipboard operation
cpal copied to clipboard

`NoDevice` error on web

Open lylythechosenone opened this issue 1 year ago • 2 comments

Overview

I'm attempting to play audio on wasm32-unknown-unknown. Going through rodio, I receive a NoDevice error when attempting to create an OutputStream. Through some investigation, I believe this comes from cpal::default_host().default_device() returning None. My program works correctly on all native platforms (that I've tried), it only fails on web.

Steps to reproduce

Attempt to get a device via cpal::default_host().default_device() on wasm32-unknown-unknown.

I was able to reproduce this issue on both Chrome and Safari, but could not test on Firefox because I could not get WebGPU to work.

Versions

cpal - v0.15.3 rodio - v0.17.3 Chrome - 124.0.6367.62 Safari - 17.4.1 (19618.1.15.11.14)

rustc:

rustc 1.79.0-nightly (3a36386dc 2024-04-25)
binary: rustc
commit-hash: 3a36386dc1075018dc7ca2640a2656adb31a61fe
commit-date: 2024-04-25
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.4

MacOS:

System Version:	macOS 14.4.1 (23E224)
Kernel Version:	Darwin 23.4.0

lylythechosenone avatar May 03 '24 15:05 lylythechosenone

I have the same issue, did you figure this out? I'm gonna try just running web-sys AudioContext directly

Jelmerta avatar Oct 10 '24 15:10 Jelmerta

I just tracked down a similar issue. In my case, it was because cpal looks for the wasm-bindgen feature flag when determining whether to use the webaudio Host implementation. Adding cpal = {version = "0.15.3", features = ["wasm-bindgen"] } to my dependencies fixed it.

unplannedlunch avatar Jan 25 '25 06:01 unplannedlunch