Repository navigation
Releases: RustAudio/cpal
Release list
cpal 0.18.2
Added
- AAudio: Xruns are now reported as
ErrorKind::Xrun. - CoreAudio: Xruns are now reported as
ErrorKind::Xrun. - PipeWire: Xruns are now reported as
ErrorKind::Xrun. - WASAPI: Capture xruns are now reported as
ErrorKind::Xrun.
Changed
- BSD: Clarify that
realtime-dbushas no effect there. - CoreAudio: Bump
objc2-core-foundationdependency lower bound to 0.3.1. - iOS: Timestamps now include hardware latency and update when the audio route changes.
- JACK: Timestamps now include port latency.
- Linux: Clarify that
realtimealone is a no-op withoutrealtime-dbus. - PipeWire: Devices with multiple ports now get distinct, localized, per-port names.
- WASAPI: The
windowsandwindows-coredependencies are now both pinned to 0.62.
Fixed
- Timestamps now stay monotonic across device and graph changes.
- ALSA: A nonzero but sub-millisecond stream timeout is no longer treated as a non-blocking poll.
- ALSA: Fix compilation on FreeBSD, DragonFly, and NetBSD.
- ASIO: Fix duplex streams silently dropping audio when built from separate
Devicehandles. - AudioWorklet: Fix
Streamoperations to work when called from any thread. - AudioWorklet: Fix stale audio output when a data callback wrote a partial buffer.
- CoreAudio: Fix stale audio output when a data callback wrote a partial buffer.
- CoreAudio: Default-output streams now report xrun status.
- iOS: Streams now resume automatically when an audio session interruption ends.
- JACK: Streams with more channels than physical system ports no longer fail to build.
- JACK: Channel enumeration is no longer capped at the physical system port count.
- JACK:
Device::idno longer embeds the process ID, soDeviceIdis now stable across application restarts. - PipeWire: Fix streams starting audio before
play()is called. - PipeWire: Fix real-time promotion blocking the audio callback thread on Linux.
- PipeWire: Fix rtkit burst limit errors from repeated real-time promotion on quantum jitter.
- PipeWire: Fix 24-bit sample format mapping.
- PipeWire: Nodes with an
/Internalmedia class are now enumerated as devices. - PipeWire: Streams for a specific device no longer auto-reroute if it disappears.
- PipeWire: Build on 32-bit targets without native 64-bit atomics.
- PulseAudio:
NoDataerrors are no longer misreported as buffer xruns. - PulseAudio: Build on 32-bit targets without native 64-bit atomics.
- visionOS: The CoreAudio backend now builds.
- WASAPI:
Stream::drop,play, andpauseno longer panic when the device is lost. - WASAPI: Output streams no longer reject formats that the built-in resampler can convert.
- WASAPI: Fix 24-bit samples not being packed into the upper bits of their sample container.
- WASAPI: Reported buffer sizes are no longer off by one frame.
- WASAPI: Default device changes no longer report
DeviceChanged, which wrongly implied the stream had rerouted automatically. - WebAudio: Fix stale audio output when a data callback wrote a partial buffer.
- WebAudio: Fix unsound
Send + SynconStreamwhen compiled with+atomics. - WebAudio: Fix
Host::is_available()always returningtrue, even in non-window contexts.
Thanks to Our Contributors
14 people contributed to this release, 9 of them for the first time: Andreas (@sandreas), Benoît Rouleau (@benface), @dheijl, Edwin Löffler (@edwloef), Erwan Legrand (@ErwanLegrand), @Jaxx497, Kpqi5858 (@kpqi5858), LastExceed (@LastExceed), Mat Silverstein (@silverstein), @MordechaiHadad, Nicola Vitale (@nivit), Nicolas Franco Gomez (@nico-franco-gomez), SkeletonGamer (@SkeletonGamer), and @the-drunk-coder. Welcome aboard, and thank you all!
asio-sys 0.4.0
Added
- Added
Driver::streams()to access a driver's shared input/output buffer state - Derived
DebugonAsioStreamsandAsioStream
Thanks to Our Contributors
Thanks to MordechaiHadad (@MordechaiHadad), who reported the duplex-stream bug (#1287) that Driver::streams() fixes in this release.
cpal 0.18.1
A quick follow-up to 0.18.0 primarily to fix the docs.rs build failure.
docs.rs: Excludedpipewire, whose system dependency isn't available in that sandboxed build environment.- WASM: Fixed the
audioworkletfeature failing to compile onwasm32-wasip1and other non-browserwasm32targets.
No API or behavioral changes.
Links
cpal 0.18.0
Hey everyone! cpal 0.18.0 is out, bringing two long-requested native Linux backends, a unified error API, and accurate timestamps across every platform.
What's New
Native PipeWire and PulseAudio
Two new first-class backends join the Linux and BSD lineup:
- PipeWire
- PulseAudio
Enable them with the pipewire and pulseaudio Cargo features. When multiple backends are compiled in, cpal selects the best available one at runtime: PipeWire > PulseAudio > ALSA.
Unified Error API
All per-operation error enums (DevicesError, BuildStreamError, StreamError, etc.) are replaced by a single cpal::Error with a kind() getter:
match device.default_output_config() {
Err(e) => match e.kind() {
cpal::ErrorKind::DeviceNotAvailable => { /* ... */ }
cpal::ErrorKind::DeviceBusy => { /* retry */ }
_ => { /* ... */ }
}
}Two new error kinds make previously indistinguishable cases actionable: DeviceBusy (EBUSY/EAGAIN is retryable) and PermissionDenied for OS-level access denials. See the upgrading guide for the mapping table.
Accurate Timestamps and A/V Sync
Timestamps previously reflected when the callback fired rather than when audio would actually reach hardware. This release corrects that across every backend:
- AAudio: pipeline buffer depth accounted for; fallback to zero on error fixed
- ALSA:
LinkSynchronizedhardware cross-timestamps for reduced jitter on supported devices - ASIO: driver-reported hardware latency included; re-queried on
kAsioLatenciesChanged - CoreAudio: device latency and safety offset included
- JACK: precise hardware cycle deadline; input capture timestamps were previously using callback execution time
- WASAPI: hardware pipeline latency included
- WebAudio: base and output latency included
A new StreamTrait::now() method lets you query the stream's clock from outside the callback for A/V sync: read the audio clock at any point and correlate it with your video timeline.
48 kHz is the New Default
default_input_config() and default_output_config() now prefer 48 kHz, then 44.1 kHz, on all backends. Defaulting to 44.1 kHz meant cpal's chosen rate often didn't match the hardware's preferred rate. Pin it explicitly if you need 44.1 kHz.
New API
StreamTrait::buffer_size()queries the stream's current buffer sizeSupportedStreamConfigRange::try_with_standard_sample_rate()/with_standard_sample_rate()snaps to 48 kHz or 44.1 kHz from a supported range
Platform Improvements
-
ALSA:
device_by_id()now accepts PCM shorthand names likehw:0,0andplughw:foo; streams attempt to recover after system suspend; capture streams no longer hang on overruns; backward-stepping timestamps during startup and xrun recovery are fixed. -
ASIO:
collect()on the device iterator no longer stops after the first device; device enumeration and stream creation now work correctly when called from spawned threads; distortion from drivers that fire the buffer callback multiple times per cycle is fixed. -
CoreAudio: the physical stream format is now set directly on the hardware device rather than relying on the HAL mixer; user-specified timeouts are now respected when building a stream.
-
JACK: buffer size changes no longer fire an error callback but resizes internal buffers, avoiding unnecessary stream rebuilds; server shutdown now surfaces as
ErrorKind::DeviceNotAvailable. -
WASAPI: device names now prefer
FriendlyNameoverDeviceDesc, so you see the readable name from system settings; default streams automatically reroute when the system default device changes.
...and a lot more. The changelog has the full picture.
Breaking Changes
- Streams now require an explicit
play()call: ALSA, CoreAudio, and JACK previously auto-started streams on creation. If you never calledplay(), your callback will never fire after upgrading. Errortypes unified: match one.kind()instead of per-operation error enums.StreamConfigpassed by value:StreamConfignow implementsCopy; drop the&atbuild_*_streamcall sites.StreamInstantAPI overhauled: aligns withstd::time::Instant. Changeadd/subtochecked_add/checked_sub(or+/-);duration_sincereturnsDuration(saturating), secs/nanos are nowu64.- Default sample rate is now 48 kHz: pin explicitly if you need 44.1 kHz.
- Default sample format heuristics now fully ranked: floats before integers, higher bit-depth before lower; pin
F32explicitly if you were relying on it as the default. - Emscripten host removed: migrate to
wasm32-unknown-unknownwith thewasm-bindgenfeature.
Full details and migration examples in the upgrading guide.
Looking Ahead to v0.19
The design goals are tracked in #1220. Highlights:
- Extension traits: clean access to platform-specific functionality like RAW mode on WASAPI, control panel on ASIO, identifying stream properties on PipeWire, etc.
- Exclusive mode on CoreAudio and WASAPI
- Duplex stream API
- Input streams on WASM: microphone access from the browser
- Stream lifecycle normalization:
play/pausetostart/pause/stopwith a draining stop - Native DSD on WASAPI
BufferSizerefactor with range support
The feature set may change.
Thanks to Our Contributors
25 people contributed to this release, 19 of them for the first time: Access (@Decodetalkers), atlv (@atlv24), Chandler Newman (@csnewman), Colin Marc (@colinmarc), @DanielHabenicht, @dheijl, Edwin Löffler (@edwloef), GorTech (@gortech), Jerry.Wang (@wangjia184), kibaa (@d3d9), Louis Beaumont (@louis030195), Marin (@marin-m), Mat Silverstein (@silverstein), Mike Hilgendorf (@m-hilgendorf), Mikey (@ahdinosaur), Nicolas Franco Gomez (@nico-franco-gomez), osoftware (@osoftware), Raphael Poss (@knz), Seto Elkahfi (@setoelkahfi), Sintel (@Sin-tel), thewh1teagle (@thewh1teagle), Umer Haider (@umerhd), Worik Stanton (@worikgh), and 时光回忆 (@mikai233). Welcome aboard, and thank you all!
A handful of longstanding reports, some dating back to 2019, also got closed out along the way as fixes elsewhere in this release happened to resolve them too. Thanks to the original reporters for filing them and sticking around: @bspot, @JustAnotherCodemonkey, @knappador, Marc-Antoine ARNAUD (@MarcAntoine-Arnaud), @mitchmindtree, MOZGIII (@MOZGIII), Philippe GASSMANN (@zenria), Przemysław Węgrzyn (@codepainters), TG (@tGrothmannFluffy), @the-drunk-coder, and Will (@will3942).
Support the Project
If you find value in cpal, sponsorships are a heartfelt token of appreciation and help cover the costs of building it: music service subscriptions, hardware for cross-platform compatibility, and tooling. Every contribution helps: sponsor me at GitHub.
Links
- Crate Home & README
- Documentation
- Changelog
- Upgrading Guide
- RustAudio Discord (#cpal channel)
Huge thanks to everyone who contributed to this release!
asio-sys 0.3.0
Added
- Added
Driver::latencies()to query input and output stream latencies - Added
BufferPreferenceenum with the driver's preferred buffer size and valid-size constraints
Changed
Driver::add_message_callbackandDriver::remove_message_callbackreplaced byDriver::add_event_callbackandDriver::remove_event_callbackMessageCallbackrenamed toDriverEventCallback, andMessageCallbackIdrenamed toDriverEventCallbackId.DriverEventCallbackwrapsFn(AsioDriverEvent) -> boolwhereAsioDriverEventis a new enum covering bothasioMessageselector events andsampleRateDidChangenotificationsCallbackIdrenamed toBufferCallbackId- Public-facing
c_longfields and return types replaced withi32 - Public-facing
c_doubleparameters and return types replaced withf64 CallbackInfo::system_timeis nowu64nanosecondsAsioError::ASE_NoMemoryrenamed toAsioError::NoMemory- Extended
BufferSizeRangewith apreferred: BufferPreferencefield AsioTime::reserved,AsioTimeInfo::reserved,AsioTimeCode::futurefields made private.asio_importmodule is nowpub(crate); raw bindgen types are no longer public APIasio_messagenow dispatcheskAsioResyncRequestandkAsioLatenciesChangedto callbacksasio_messagedelegateskAsioSelectorSupportedfor unknown selectors to registered callbacks, so each host decides which capabilities it opts intosample_rate_did_changenow dispatchesAsioDriverEvent::SampleRateChangedto 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 duringset_sample_rate's teardown/reload - Fixed
Asio::load_driverto returnLoadDriverError::LoadDriverFailedinstead of panicking when the driver name contains a null byte - Fixed
Driver::set_sample_rateto 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_messagenot advertisingkAsioSelectorSupporteditself as a supported selector - Fixed rust-analyzer errors on non-Windows targets by using stub instead of ASIO bindings
Removed
- Removed unused
SampleRatestruct - Removed
DriverStatefrom the public API
Thanks to Our Contributors
Thanks to Jerry.Wang (@wangjia184), who fixed the rust-analyzer build on non-Windows targets (#1140).
cpal 0.17.3
Changed
- Reverted SemVer-breaking
DeviceBusyerror variant addition.
Fixed
- ASIO: Fix linker errors.
asio-sys 0.2.6
Fixed
- Link
advapi32to resolve Windows Registry API symbols.
cpal 0.17.2
This release was yanked.
Added
DeviceBusyerror variant for retriable device access errors (EBUSY,EAGAIN).- ALSA:
Debugimplementations forHost,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
alsadependency to 0.11. - ALSA: Bump MSRV to 1.82.
- CoreAudio: Update
core-audio-rsdependency 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.
cpal 0.17.1
Added
- ALSA:
Defaultimplementation forDevice(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.
asio-sys 0.2.5
Fixed
- Fixed ASIO SDK discovery on case sensitive filesystems.