RustAudio/cpal
 Watch   
 Star   
 Fork   
9 days ago
cpal

cpal 0.18.1

A quick follow-up to 0.18.0 primarily to fix the docs.rs build failure.

  • docs.rs: Excluded pipewire, whose system dependency isn't available in that sandboxed build environment.
  • WASM: Fixed the audioworklet feature failing to compile on wasm32-wasip1 and other non-browser wasm32 targets.

No API or behavioral changes.

Links

10 days ago
cpal

cpal 0.18.0

Added

  • New ErrorKind variants for the unified error type: BackendError (platform error without a specific mapping); DeviceBusy (retryable device access, e.g. EBUSY/EAGAIN); DeviceChanged (audio route changed to another device); InvalidInput (invalid caller-supplied values); PermissionDenied (OS-level access denial); RealtimeDenied (real-time scheduling refused; previously only printed to stderr); ResourceExhausted (OS thread/memory limits); UnsupportedOperation (backend or device does not implement the operation).
  • Device now implements PartialEq, Eq, Hash, Display, and Debug on all backends.
  • realtime feature for real-time audio thread scheduling without a D-Bus build dependency.
  • StreamTrait::now() to query the current instant on the stream's clock.
  • StreamTrait::buffer_size() to query the stream's current buffer size in frames per callback.
  • SAMPLE_RATE_CD (44100 Hz) and SAMPLE_RATE_48K (48000 Hz) constants.
  • SupportedStreamConfigRange::try_with_standard_sample_rate() and with_standard_sample_rate() to select 48 kHz or 44.1 kHz from a range.
  • SupportedStreamConfigRange::contains_rate() to test whether a sample rate falls within a range.
  • StreamConfig and SupportedStreamConfig now implement Copy.
  • BufferSize now implements Default (returns BufferSize::Default).
  • SupportedBufferSize now implements Default (returns SupportedBufferSize::Unknown).
  • HostTrait::device_by_id() is now backend-dispatched, allowing each host to override the default implementation.
  • DSD512 sample rates added to the common rate probe list.
  • AAudio: Streams now request PERFORMANCE_MODE_LOW_LATENCY with the realtime feature; reports ErrorKind::RealtimeDenied if not granted.
  • 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 BSD via the native PipeWire API.
  • PulseAudio: New host for Linux and BSD via the PulseAudio API.
  • WASAPI: F64 sample format support.

Changed

  • Changed per-operation error types (DevicesError, SupportedStreamConfigsError, etc.) and HostUnavailable into a unified Error/ErrorKind. See UPGRADING.md.
  • DeviceTrait now requires PartialEq + Eq + Hash + Debug + Display with a stable device ID.
  • DeviceTrait::build_*_stream() now takes StreamConfig by value instead of &StreamConfig.
  • StreamInstant API changed and extended to mirror std::time::Instant/Duration. See UPGRADING.md for migration details.
  • Streams no longer start automatically on build_*_stream(); call play() explicitly. Previously ALSA, CoreAudio, and JACK auto-started streams on creation.
  • Default output and input configs now prefer 48 kHz, then 44.1 kHz, then the device maximum. Previously the preferred rate was backend-dependent (typically 44.1 kHz or device maximum).
  • SupportedStreamConfigRange::cmp_default_heuristics now ranks all SampleFormat variants; F32 > F64 > descending integer widths. Default configs may now return I32 or I24 on high-precision hardware. See UPGRADING.md.
  • Bump MSRV to 1.85.
  • DeviceId fields are now private; construct with DeviceId::new(host, id) and access with .host() / .id(). See UPGRADING.md.
  • audio_thread_priority feature renamed to realtime-dbus.
  • DeviceDescription::extended() now returns impl Iterator<Item = &str> instead of &[String]. See UPGRADING.md.
  • HostId::name() now returns a more human-friendly name.
  • DeviceDescriptionBuilder setters now accept impl AsRef<str> instead of impl Into<String>.
  • AAudio: Channel enumeration extended to 8 channels.
  • AAudio: Buffers with default sizes are now dynamically tuned.
  • AAudio: SupportedBufferSize in enumeration is now Unknown.
  • AAudio: Device names now include the device type suffix (e.g. Speaker (Builtin Speaker)).
  • AAudio: supported_input_configs() and supported_output_configs() now return an error for direction-mismatched devices instead of silently returning an empty list.
  • ALSA: Stream error callback now receives ErrorKind::DeviceNotAvailable on device disconnection.
  • ALSA: Callback timestamps use LinkSynchronized hardware cross-timestamps for lower jitter on supported devices.
  • ALSA: Try to resume from hardware after a system suspend.
  • ALSA: Loop partial reads and writes to completion.
  • ALSA: Polling errors trigger underrun recovery instead of looping.
  • ALSA: Prevent reentrancy issues with non-reentrant plugins and devices.
  • ALSA: Supported configurations are now enumerated up to 64 channels (AES10 maximum).
  • ALSA: The realtime feature now skips RT promotion for ineligible PCM types (null, I/O plugins, wrapper types).
  • ASIO: Timestamps now include driver-reported hardware latency.
  • ASIO: Stream error callback now receives ErrorKind::StreamInvalidated on kAsioResyncRequest or a sample rate change of 1 Hz or more from the configured rate.
  • ASIO: Hardware latency is re-queried when the driver reports kAsioLatenciesChanged.
  • ASIO: Device::driver, asio_streams, and current_callback_flag are no longer pub.
  • AudioWorklet: BufferSize::Fixed now sets renderSizeHint on the AudioContext.
  • AudioWorklet: Sample rates now enumerated as discrete standard rates in the spec-required range of 3-768 kHz.
  • CoreAudio: Timestamps now include device latency and safety offset.
  • CoreAudio: Physical stream format is now set directly on the hardware device.
  • CoreAudio: Stream error callback now receives ErrorKind::StreamInvalidated on any sample rate change on macOS, and on iOS on route changes that require a stream rebuild.
  • CoreAudio: Stream error callback now receives ErrorKind::DeviceNotAvailable on iOS when media services are lost.
  • CoreAudio: Stream error callback now receives ErrorKind::DeviceChanged when the system default output device changes, or on iOS when headphones are unplugged.
  • CoreAudio: User timeouts are now respected when building a stream.
  • CoreAudio (iOS): default_output_config() now prefers stereo over the maximum channel count.
  • JACK: Timestamps now use the precise hardware deadline.
  • JACK: Stream error callback now receives ErrorKind::DeviceNotAvailable on server shutdown.
  • JACK: Stream error callback now receives ErrorKind::RealtimeDenied once if the process callback is not running at real-time scheduling priority.
  • JACK: Stream::connect_to_system_outputs() and connect_to_system_inputs() now return Result<(), Error> and roll back the port graph on failure.
  • JACK: User timeouts are now respected when building a stream.
  • JACK: Buffer size changes no longer invoke the error callback; internal buffers are resized transparently.
  • JACK: Default client name now includes the process PID.
  • Linux/BSD: Default host priority: PipeWire > PulseAudio > ALSA.
  • WASAPI: Default output and input streams now automatically reroute when the system default device changes; stream error callback receives ErrorKind::DeviceChanged.
  • WASAPI: Timestamps now include hardware pipeline latency.
  • WASAPI: FriendlyName is now preferred as device name over DeviceDesc.
  • WASAPI: Device::immdevice() now returns Option<Audio::IMMDevice>.
  • WASAPI: Raise windows dependency lower bound to 0.61.
  • WebAudio: Timestamps now include base and output latency.
  • WebAudio: Initial buffer scheduling offset now scales with buffer duration.
  • WebAudio: Sample rates now enumerated as discrete standard rates in the spec-required range of 3-768 kHz.

Removed

  • StreamInstant::add() and sub() replaced by checked_add()/+ and checked_sub()/-.
  • Removed deprecated DeviceTrait::name().
  • ALSA: Default implementation for Device.
  • ALSA: AlsaHost is no longer re-exported from cpal::platform.
  • Emscripten: Removed broken host; use the WebAudio host instead.
  • WASAPI: Removed U24 incorrectly listed as a supported sample format.

Fixed

  • channels: 0, sample_rate: 0, or BufferSize::Fixed(0) now return ErrorKind::InvalidInput consistently across all backends (previously UnsupportedConfig or a panic).
  • Output buffers are now zero-filled before the callback runs across all backends.
  • Poisoned mutex guards now return ErrorKind::StreamInvalidated instead of panicking (AAudio, ASIO, CoreAudio, JACK, WASAPI).
  • Fix callbacks firing before build_*_stream returns the Stream handle (ALSA, ASIO, WASAPI).
  • Fix buffer_capacity_in_frames integer overflow for large fixed buffer sizes (AAudio, ALSA).
  • Fix numeric overflows when constructing StreamInstant (ASIO, CoreAudio, JACK).
  • AAudio: Fix panic in device configuration enumeration for pathological channel counts.
  • AAudio: Fix thread lock when a stream is dropped before it fully starts.
  • AAudio: Fix capture and playback timestamps not accounting for audio pipeline buffer depth, and falling back to zero on error.
  • AAudio: Fix sample_rate values above i32::MAX panicking.
  • AAudio: Fix stream errors not forwarded to error_callback.
  • AAudio: Return ErrorKind::BackendError instead of panicking on sample count overflow in the data callback.
  • ALSA: Fix capture stream hanging or spinning on overruns.
  • ALSA: Fix timestamps stepping backward during startup or after xrun recovery.
  • ALSA: Fix spurious timestamp and timeout errors during stream startup and polling.
  • ALSA: Fix rare panics when dropping the stream is interrupted.
  • ALSA: Fix timestamp overflows on 32-bit platforms.
  • ALSA: Fix silence template not applied for DSD.
  • ALSA: Fix stream corruption on certain drivers with spurious wakeups.
  • ALSA: Fix hang when a device raced to an error state without delivering POLLERR.
  • ALSA: Fix supported_configs() reporting buffer size instead of period size, using the same buffer range for all formats/channels, and dropping sample rates outside COMMON_SAMPLE_RATES.
  • ALSA: Fix BufferSize::Fixed validation opening the PCM device a second time.
  • ALSA: Fix poll timeout overflow panic for stream durations exceeding ~24 days.
  • ALSA: Fix build_*_stream_raw returning UnsupportedConfig instead of UnsupportedOperation for direction-mismatched devices.
  • ASIO: Fix enumeration returning only the first device when using collect().
  • ASIO: Fix device enumeration and stream creation failing from spawned threads.
  • ASIO: Fix buffer size not resizing on kAsioBufferSizeChange.
  • ASIO: Fix latency not updating on kAsioLatenciesChanged.
  • ASIO: Fix distortion when buggy drivers fire the buffer callback multiple times per cycle.
  • ASIO: Fix poisoned callback and buffer-size-change mutexes silently dropping notifications.
  • ASIO: Fix driver.sample_rate() failures at stream creation silently ignored.
  • ASIO: Fix overrun not reported when the driver reports kAsioOverload.
  • ASIO: Fix BufferSize::Fixed with a size not aligned to the driver's step constraint not returning ErrorKind::UnsupportedConfig.
  • AudioWorklet: Fix default_output_device() returning non-None when AudioWorklet is unavailable.
  • AudioWorklet: Fix channel count silently clamped below destination.maxChannelCount.
  • AudioWorklet: Fix supported_output_configs() reporting FrameCount::MAX as the buffer size upper bound (correct: floor(6 * sample_rate) per spec).
  • AudioWorklet: Fix supported_output_configs() reporting 128 as the minimum render quantum when renderQuantumSize is supported (spec minimum is 1).
  • CoreAudio: Fix default output streams silently stopping when the system default device is unplugged; they now reroute or report ErrorKind::DeviceNotAvailable.
  • CoreAudio: Fix undefined behavior and silent failure in loopback device creation.
  • CoreAudio: Fix loopback aggregate device UID collisions between concurrent instances and after crashes.
  • CoreAudio: Fix loopback capture returning silence due to disabled tap auto-start.
  • CoreAudio: Fix crashes on certain drivers due to early initialization.
  • CoreAudio: Fix supported_output/input_configs() collapsing non-continuous hardware rates into a continuous range (regression since v0.17.0).
  • CoreAudio: Fix BufferSize::Fixed producing cryptic backend errors when not validated against the hardware buffer range.
  • CoreAudio (iOS): Fix BufferSize::Fixed not validated against the supported range before stream creation.
  • JACK: Fix input capture timestamp using callback execution time instead of cycle start.
  • JACK: Fix poisoned error callback mutex silently dropping subsequent error notifications.
  • JACK: Fix port registration failure not propagating to stream creation.
  • JACK: Fix activate_async() failure panicking instead of returning an error.
  • JACK: Fix sample rate not validated against the live JACK server at stream creation.
  • JACK: Fix underrun notification blocking the notification thread.
  • JACK: Fix supported_input/output_configs() reporting a hardcoded sparse channel list instead of enumerating all counts up to physical system ports.
  • PipeWire: Fix channels: 0 or sample_rate: 0 silently using PipeWire-negotiated values instead of returning ErrorKind::InvalidInput.
  • PulseAudio: Fix supported_output_configs() and default_output_config() not accounting for PulseAudio's double-buffer.
  • WASAPI: Fix audio worker thread spawn failure panicking instead of returning an error.
  • WASAPI: Fix Communications-class inputs returning non-silence.
  • WASAPI: Fix supported_input_configs() advertising unsupported sample rates on input devices.
  • WASAPI: Fix sample_rate: 0 with BufferSize::Fixed causing a divide-by-zero panic.
  • WASAPI: Fix supported_input/output_configs() and default_input/output_config() reporting an unconstrained buffer range on software audio stacks.
  • WASAPI: Fix I24 not enumerated and 24-bit devices misidentified as I32.
  • WebAudio: Fix overflow with pathological channel counts.
  • WebAudio: Fix duplicated callbacks on repeated play() calls.
  • WebAudio: Fix errors panicking instead of being reported through the callback.
  • WebAudio: Fix default_output_device() returning Some when WebAudio is unavailable.
  • WebAudio: Fix channel count silently clamped when exceeding destination.maxChannelCount.
10 days ago
cpal

asio-sys 0.3.0

Added

  • Added Driver::latencies() to query input and output stream latencies
  • Added BufferPreference enum with the driver's preferred buffer size and valid-size constraints

Changed

  • Driver::add_message_callback and Driver::remove_message_callback replaced by Driver::add_event_callback and Driver::remove_event_callback
  • MessageCallback renamed to DriverEventCallback, and MessageCallbackId renamed to DriverEventCallbackId. DriverEventCallback wraps Fn(AsioDriverEvent) -> bool whereAsioDriverEvent is a new enum covering both asioMessage selector events and sampleRateDidChange notifications
  • CallbackId renamed to BufferCallbackId
  • Public-facing c_long fields and return types replaced with i32
  • Public-facing c_double parameters and return types replaced with f64
  • CallbackInfo::system_time is now u64 nanoseconds
  • AsioError::ASE_NoMemory renamed to AsioError::NoMemory
  • Extended BufferSizeRange with a preferred: BufferPreference field
  • AsioTime::reserved, AsioTimeInfo::reserved, AsioTimeCode::future fields made private.
  • asio_import module is now pub(crate); raw bindgen types are no longer public API
  • asio_message now dispatches kAsioResyncRequest and kAsioLatenciesChanged to callbacks
  • asio_message delegates kAsioSelectorSupported for unknown selectors to registered callbacks, so each host decides which capabilities it opts into
  • sample_rate_did_change now dispatches AsioDriverEvent::SampleRateChanged to registered callbacks when the reported rate differs from the last known rate

Fixed

  • Fixed TOCTOU race condition when creating streams concurrently
  • Fixed data race where channels, latencies, sample_rate, and related query methods could call ASIO concurrently during set_sample_rate's teardown/reload
  • Fixed Asio::load_driver to return LoadDriverError::LoadDriverFailed instead of panicking when the driver name contains a null byte
  • Fixed Driver::set_sample_rate to perform a dummy buffer cycle and driver reload when the driver does not apply the rate change immediately, as required by some drivers (e.g. Steinberg)
  • Fixed asio_message not advertising kAsioSelectorSupported itself as a supported selector
  • Fixed rust-analyzer errors on non-Windows targets by using stub instead of ASIO bindings

Removed

  • Removed unused SampleRate struct
  • Removed DriverState from the public API
2026-02-19 04:49:26
cpal

asio-sys 0.2.6

Fixed

  • Link advapi32 to resolve Windows Registry API symbols.
2026-02-19 04:49:26
cpal

cpal 0.17.3

Changed

  • Reverted SemVer-breaking DeviceBusy error variant addition.

Fixed

  • ASIO: Fix linker errors.
2026-02-09 05:52:28
cpal

cpal 0.17.2

Added

  • DeviceBusy error variant for retriable device access errors (EBUSY, EAGAIN).
  • ALSA: Debug implementations for Host, Device, Stream, and internal types.
  • ALSA: Example demonstrating ALSA error suppression during enumeration.
  • WASAPI: Enable as-necessary resampling in the WASAPI server process.

Changed

  • Bump overall MSRV to 1.78.
  • ALSA: Update alsa dependency to 0.11.
  • ALSA: Bump MSRV to 1.82.
  • CoreAudio: Update core-audio-rs dependency to 0.14.

Fixed

  • ALSA: Enumerating input and output devices no longer interferes with each other.
  • ALSA: Device handles are no longer exclusively held between operations.
  • ALSA: Reduce Valgrind memory leak reports from ALSA global configuration cache.
  • ALSA: Fix possible race condition on drop.
  • ALSA: Fix audio callback stalling when start threshold is not met.
2026-01-04 22:30:55
cpal

cpal 0.17.1

Added

  • ALSA: Default implementation for Device (returns the ALSA "default" device).
  • CI: Checks default/no-default/all feature sets with platform-dependent MSRV for JACK.

Fixed

  • ALSA: Device enumeration now includes both hints and physical cards.
  • JACK: No longer builds on iOS.
  • WASM: WasmBindgen no longer crashes (regression from 0.17.0).

Changed

  • ALSA: Devices now report direction from hint metadata and physical hardware probing.
2026-01-04 22:30:55
cpal

asio-sys 0.2.5

Fixed

  • Fixed ASIO SDK discovery on case sensitive filesystems.
2025-12-21 03:14:17
cpal

cpal 0.17.0

Added

  • DeviceTrait::id method that returns a stable audio device ID.
  • HostTrait::device_by_id to select a device by its stable ID.
  • Display and FromStr implementations for HostId.
  • Support for custom Hosts, Devices, and Streams.
  • Sample::bits_per_sample method.
  • Copy implementation to InputCallbackInfo and OutputCallbackInfo.
  • StreamError::StreamInvalidated variant for when stream must be rebuilt.
  • StreamError::BufferUnderrun variant for buffer underrun/overrun notifications.
  • Hash implementation to Device for all backends.
  • AAudio: Send and Sync implementations to Stream.
  • AAudio: Support for 12 and 24 kHz sample rates.
  • ALSA: I24 and U24 sample format support (24-bit samples stored in 4 bytes).
  • ALSA: Support for 12, 24, 352.8, 384, 705.6, and 768 kHz sample rates.
  • ALSA: Eq and PartialEq implementations to Device.
  • CI: Native ARM64 Linux support in GitHub Actions.
  • CoreAudio: i8, i32 and I24 sample format support (24-bit samples stored in 4 bytes).
  • CoreAudio: Support for loopback recording (recording system audio output) on macOS > 14.6.
  • CoreAudio: Send implementation to Stream.
  • Emscripten: BufferSize::Fixed validation against supported range.
  • iOS: Complete AVAudioSession integration for device enumeration and buffer size control.
  • JACK: Support for macOS and Windows platforms.
  • JACK: BufferSize::Fixed validation to reject requests that don't match server buffer size.
  • WASAPI: Expose IMMDevice from WASAPI host Device.
  • WASAPI: I24 and U24 sample format support (24-bit samples stored in 4 bytes).
  • WASAPI: Send and Sync implementations to Stream.
  • WebAudio: Send and Sync implementations to Stream.
  • WebAudio: BufferSize::Fixed validation against supported range.

Changed

  • MSRV depends on the platform and at minimum 1.77.
  • Set examples to Rust 2021.
  • SampleRate from struct to u32 type alias.
  • Update audio_thread_priority to 0.34.
  • Migrate CHANGELOG to Keep a Changelog format.
  • AAudio: Configure buffer to ensure consistent callback buffer sizes.
  • AAudio: Buffer size range detection to query the AudioService property correctly.
  • ALSA: Improve BufferSize::Fixed precision and audio callback performance.
  • ALSA: BufferSize::Default to use the device defaults.
  • ALSA: Card enumeration to work like aplay -L does.
  • ALSA: Update alsa to 0.10.
  • ALSA: Pass silent=true to PCM.try_recover, so it doesn't write to stderr.
  • ALSA: Report buffer underruns/overruns via StreamError::BufferUnderrun.
  • ASIO: Share sys::Asio instance across all Host instances.
  • CI: Fix cargo publish to trigger on GitHub releases instead of every master commit.
  • CI: Replace cargo install commands with cached tool installation for faster builds.
  • CI: Update actions to latest versions (checkout@v5, rust-cache@v2).
  • CI: Verify compatibility with windows crates since v0.59.
  • CI: Test platforms on appropriate MSRV per backend.
  • CI: Fix cargo update syntax for compatibility with Cargo 1.70 (use -p flag instead of positional argument).
  • CoreAudio: Device::supported_configs to return a single element containing the available sample rate range when all elements have the same mMinimum and mMaximum values.
  • CoreAudio: Default audio device detection to be lazy when building a stream, instead of during device enumeration.
  • CoreAudio: Configure device buffer to ensure predictable callback buffer sizes.
  • CoreAudio: Remove Clone implementation from Stream.
  • JACK: Use StreamError::StreamInvalidated for JACK server sample rate changes.
  • JACK: Report buffer underruns/overruns via StreamError::BufferUnderrun.
  • WASAPI: Update windows to >= 0.59, <= 0.62.

Fixed

  • ALSA: Format selection to probe hardware endianness instead of assuming native byte order.
  • ALSA: Data race in stream shutdown.
  • ASIO: Handling for kAsioResetRequest message to prevent driver UI becoming unresponsive.
  • ASIO: Buffer silencing logic to work with non-conformant drivers (e.g., FL Studio ASIO).
  • CoreAudio: Timestamp accuracy.
  • CoreAudio: Segfaults when enumerating devices.
  • CoreAudio: Undefined behavior related to null pointers and aligned reads.
  • CoreAudio: Unnecessary microphone permission requests when using output devices only.
  • iOS: Example by properly activating audio session.

Removed

  • WebAudio: Optional wee-alloc feature for security reasons.
2025-12-21 03:00:00
cpal

asio-sys 0.2.4

Fixed

  • Fixed docs.rs documentation build by generating stub bindings when building for docs.rs
  • Fixed buffer switch detection to work correctly with non-conformant ASIO drivers