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
48 changes: 12 additions & 36 deletions .github/workflows/platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ jobs:
- name: Check examples (default features)
run: cargo +${{ env.MSRV_ALSA }} check --examples --workspace --verbose

- name: Run tests (no default features)
run: cargo +${{ env.MSRV_ALSA }} test --no-default-features --workspace --verbose

- name: Check examples (no default features)
run: cargo +${{ env.MSRV_ALSA }} check --examples --no-default-features --workspace --verbose

- name: Run tests (all features)
run: cargo +${{ steps.msrv.outputs.all-features }} test --all-features --workspace --verbose

Expand Down Expand Up @@ -151,17 +145,11 @@ jobs:
- name: Check examples (default features)
run: cross +${{ env.MSRV_ALSA }} check --examples --workspace --verbose --target ${{ env.TARGET }}

- name: Run tests (no default features)
run: cross +${{ env.MSRV_ALSA }} test --no-default-features --workspace --verbose --target ${{ env.TARGET }}

- name: Check examples (no default features)
run: cross +${{ env.MSRV_ALSA }} test --no-default-features --workspace --verbose --target ${{ env.TARGET }}

- name: Run tests (all features)
run: cross +${{ steps.msrv.outputs.all-features }} test --features=jack,pulseaudio --workspace --verbose --target ${{ env.TARGET }}

- name: Check examples (all features)
run: cross +${{ steps.msrv.outputs.all-features }} test --features=jack,pulseaudio --workspace --verbose --target ${{ env.TARGET }}
run: cross +${{ steps.msrv.outputs.all-features }} check --examples --features=jack,pulseaudio --workspace --verbose --target ${{ env.TARGET }}

pipewire-bookworm:
name: pipewire-bookworm
Expand Down Expand Up @@ -241,12 +229,6 @@ jobs:
- name: Check examples (default features)
run: cargo +${{ env.MSRV_WINDOWS }} check --examples --workspace --verbose

- name: Run tests (no default features)
run: cargo +${{ env.MSRV_WINDOWS }} test --no-default-features --workspace --verbose

- name: Check examples (no default features)
run: cargo +${{ env.MSRV_WINDOWS }} check --examples --no-default-features --workspace --verbose

- name: Run tests (all features)
run: cargo +${{ steps.msrv.outputs.all-features }} test --workspace --all-features --verbose

Expand Down Expand Up @@ -293,12 +275,6 @@ jobs:
- name: Check examples (default features)
run: cargo +${{ env.MSRV_COREAUDIO }} check --examples --workspace --verbose

- name: Run tests (no default features)
run: cargo +${{ env.MSRV_COREAUDIO }} test --no-default-features --workspace --verbose

- name: Check examples (no default features)
run: cargo +${{ env.MSRV_COREAUDIO }} check --no-default-features --examples --workspace --verbose

- name: Run tests (all features)
run: cargo +${{ steps.msrv.outputs.all-features }} test --all-features --workspace --verbose

Expand Down Expand Up @@ -342,9 +318,6 @@ jobs:
- name: Check examples (default features)
run: cargo +${{ env.MSRV_AAUDIO }} check --examples --workspace --verbose --target ${{ env.TARGET }}

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

- name: Check examples (all features)
run: cargo +${{ steps.msrv.outputs.all-features }} check --examples --all-features --workspace --verbose --target ${{ env.TARGET }}

Expand Down Expand Up @@ -391,9 +364,6 @@ jobs:
- name: Check examples (default features)
run: cargo +${{ env.MSRV_COREAUDIO }} check --examples --workspace --verbose --target ${{ env.TARGET }}

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

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

Expand Down Expand Up @@ -429,9 +399,6 @@ jobs:
- 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

Expand Down Expand Up @@ -459,6 +426,9 @@ jobs:
with:
key: wasm-bindgen

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

- name: Check examples (wasm-bindgen feature)
run: cargo +${{ env.MSRV_WASM }} check --examples --features wasm-bindgen --workspace --verbose --target ${{ env.TARGET }}

Expand Down Expand Up @@ -496,9 +466,15 @@ jobs:
with:
key: wasm-audioworklet

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

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

- name: Check all features
run: cargo +nightly check --workspace --all-features --verbose -Z build-std=std,panic_abort --target ${{ env.TARGET }}

- name: Build audioworklet-beep example
working-directory: ./examples/audioworklet-beep
run: trunk build
Expand Down Expand Up @@ -527,8 +503,8 @@ jobs:
- name: Check examples (default features)
run: cargo +${{ env.MSRV_WASIP1 }} check --examples --workspace --target ${{ env.TARGET }} --verbose

- name: Check examples (no default features)
run: cargo +${{ env.MSRV_WASIP1 }} check --examples --no-default-features --workspace --verbose --target ${{ env.TARGET }}
- name: Check all features
run: cargo +${{ env.MSRV_WASIP1 }} check --workspace --all-features --verbose --target ${{ env.TARGET }}

# Windows crate version compatibility
windows-versions:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Exclude `pipewire` from the `docs.rs` build; system dependency not available in its environment.
- Fix `wasm-bindgen` causing compile errors on non-browser `wasm32` targets such as `wasm32-wasip1`.

## [0.18.0] - 2026-06-06

Expand Down
14 changes: 12 additions & 2 deletions src/host/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub(crate) mod alsa;
pub(crate) mod asio;

#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen",
feature = "audioworklet",
target_feature = "atomics"
Expand Down Expand Up @@ -72,7 +74,11 @@ pub(crate) mod pulseaudio;
#[cfg(windows)]
pub(crate) mod wasapi;

#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
pub(crate) mod webaudio;

#[cfg(feature = "custom")]
Expand All @@ -86,7 +92,11 @@ pub(crate) mod custom;
target_os = "netbsd",
target_vendor = "apple",
target_os = "android",
all(target_arch = "wasm32", feature = "wasm-bindgen"),
all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
),
)))]
pub(crate) mod null;

Expand Down
51 changes: 43 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,23 @@
#![cfg_attr(docsrs, feature(doc_cfg))]

// Extern crate declarations with `#[macro_use]` must unfortunately be at crate root.
#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
extern crate js_sys;
#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
extern crate wasm_bindgen;
#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
extern crate web_sys;

pub use device_description::{
Expand All @@ -180,7 +192,11 @@ pub use platform::{
SupportedInputConfigs, SupportedOutputConfigs, ALL_HOSTS,
};
pub use sample_format::{FromSample, Sample, SampleFormat, SizedSample, I24, U24};
#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
use wasm_bindgen::prelude::*;

pub mod device_description;
Expand Down Expand Up @@ -375,14 +391,22 @@ pub enum BufferSize {
Fixed(FrameCount),
}

#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
impl wasm_bindgen::describe::WasmDescribe for BufferSize {
fn describe() {
<Option<FrameCount> as wasm_bindgen::describe::WasmDescribe>::describe();
}
}

#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
impl wasm_bindgen::convert::IntoWasmAbi for BufferSize {
type Abi = <Option<FrameCount> as wasm_bindgen::convert::IntoWasmAbi>::Abi;

Expand All @@ -395,7 +419,11 @@ impl wasm_bindgen::convert::IntoWasmAbi for BufferSize {
}
}

#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
impl wasm_bindgen::convert::FromWasmAbi for BufferSize {
type Abi = <Option<FrameCount> as wasm_bindgen::convert::FromWasmAbi>::Abi;

Expand All @@ -412,7 +440,14 @@ impl wasm_bindgen::convert::FromWasmAbi for BufferSize {
/// The sample format is omitted in favour of using a sample type.
///
/// See also [`BufferSize`] for details on buffer size behavior and latency considerations.
#[cfg_attr(all(target_arch = "wasm32", feature = "wasm-bindgen"), wasm_bindgen)]
#[cfg_attr(
all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
),
wasm_bindgen
)]
#[derive(Clone, Debug, Eq, PartialEq, Copy)]
pub struct StreamConfig {
pub channels: ChannelCount,
Expand Down
12 changes: 10 additions & 2 deletions src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,11 @@ mod platform_impl {
}
}

#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
mod platform_impl {
#[cfg(all(feature = "audioworklet", target_feature = "atomics"))]
use crate::host::audioworklet::Host as AudioWorkletHost;
Expand Down Expand Up @@ -936,7 +940,11 @@ mod platform_impl {
target_os = "netbsd",
target_vendor = "apple",
target_os = "android",
all(target_arch = "wasm32", feature = "wasm-bindgen"),
all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
),
)))]
mod platform_impl {
use crate::host::null::Host as NullHost;
Expand Down
15 changes: 13 additions & 2 deletions src/sample_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ pub use dasp_sample::I24;
/// the actual bit depth (24) vs [`SampleFormat::sample_size`] for storage size (4 bytes).
pub use dasp_sample::U24;
pub use dasp_sample::{FromSample, Sample};
#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
#[cfg(all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
))]
use wasm_bindgen::prelude::*;

// I48 and U48 are not currently supported by cpal but available in dasp_sample:
Expand All @@ -49,7 +53,14 @@ use wasm_bindgen::prelude::*;
///
/// [`is_float`]: SampleFormat::is_float
/// [`supported_input_configs`]: crate::traits::DeviceTrait::supported_input_configs
#[cfg_attr(all(target_arch = "wasm32", feature = "wasm-bindgen"), wasm_bindgen)]
#[cfg_attr(
all(
target_arch = "wasm32",
target_os = "unknown",
feature = "wasm-bindgen"
),
wasm_bindgen
)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
pub enum SampleFormat {
Expand Down
Loading