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.
cpal 0.18.0
- New
ErrorKindvariants 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). Devicenow implementsPartialEq,Eq,Hash,Display, andDebugon all backends.realtimefeature 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) andSAMPLE_RATE_48K(48000 Hz) constants.SupportedStreamConfigRange::try_with_standard_sample_rate()andwith_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.StreamConfigandSupportedStreamConfignow implementCopy.BufferSizenow implementsDefault(returnsBufferSize::Default).SupportedBufferSizenow implementsDefault(returnsSupportedBufferSize::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_LATENCYwith therealtimefeature; reportsErrorKind::RealtimeDeniedif not granted. - ALSA:
device_by_id()now accepts PCM shorthand names such ashw:0,0andplughw: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:
F64sample format support.
- Changed per-operation error types (
DevicesError,SupportedStreamConfigsError, etc.) andHostUnavailableinto a unifiedError/ErrorKind. See UPGRADING.md. DeviceTraitnow requiresPartialEq + Eq + Hash + Debug + Displaywith a stable device ID.DeviceTrait::build_*_stream()now takesStreamConfigby value instead of&StreamConfig.StreamInstantAPI changed and extended to mirrorstd::time::Instant/Duration. See UPGRADING.md for migration details.- Streams no longer start automatically on
build_*_stream(); callplay()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_heuristicsnow ranks allSampleFormatvariants;F32>F64> descending integer widths. Default configs may now returnI32orI24on high-precision hardware. See UPGRADING.md.- Bump MSRV to 1.85.
DeviceIdfields are now private; construct withDeviceId::new(host, id)and access with.host()/.id(). See UPGRADING.md.audio_thread_priorityfeature renamed torealtime-dbus.DeviceDescription::extended()now returnsimpl Iterator<Item = &str>instead of&[String]. See UPGRADING.md.HostId::name()now returns a more human-friendly name.DeviceDescriptionBuildersetters now acceptimpl AsRef<str>instead ofimpl Into<String>.- AAudio: Channel enumeration extended to 8 channels.
- AAudio: Buffers with default sizes are now dynamically tuned.
- AAudio:
SupportedBufferSizein enumeration is nowUnknown. - AAudio: Device names now include the device type suffix (e.g.
Speaker (Builtin Speaker)). - AAudio:
supported_input_configs()andsupported_output_configs()now return an error for direction-mismatched devices instead of silently returning an empty list. - ALSA: Stream error callback now receives
ErrorKind::DeviceNotAvailableon device disconnection. - ALSA: Callback timestamps use
LinkSynchronizedhardware 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
realtimefeature 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::StreamInvalidatedonkAsioResyncRequestor 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, andcurrent_callback_flagare no longerpub. - AudioWorklet:
BufferSize::Fixednow setsrenderSizeHinton theAudioContext. - 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::StreamInvalidatedon any sample rate change on macOS, and on iOS on route changes that require a stream rebuild. - CoreAudio: Stream error callback now receives
ErrorKind::DeviceNotAvailableon iOS when media services are lost. - CoreAudio: Stream error callback now receives
ErrorKind::DeviceChangedwhen 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::DeviceNotAvailableon server shutdown. - JACK: Stream error callback now receives
ErrorKind::RealtimeDeniedonce if the process callback is not running at real-time scheduling priority. - JACK:
Stream::connect_to_system_outputs()andconnect_to_system_inputs()now returnResult<(), 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:
FriendlyNameis now preferred as device name overDeviceDesc. - WASAPI:
Device::immdevice()now returnsOption<Audio::IMMDevice>. - WASAPI: Raise
windowsdependency 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.
StreamInstant::add()andsub()replaced bychecked_add()/+andchecked_sub()/-.- Removed deprecated
DeviceTrait::name(). - ALSA:
Defaultimplementation forDevice. - ALSA:
AlsaHostis no longer re-exported fromcpal::platform. - Emscripten: Removed broken host; use the WebAudio host instead.
- WASAPI: Removed
U24incorrectly listed as a supported sample format.
channels: 0,sample_rate: 0, orBufferSize::Fixed(0)now returnErrorKind::InvalidInputconsistently across all backends (previouslyUnsupportedConfigor a panic).- Output buffers are now zero-filled before the callback runs across all backends.
- Poisoned mutex guards now return
ErrorKind::StreamInvalidatedinstead of panicking (AAudio, ASIO, CoreAudio, JACK, WASAPI). - Fix callbacks firing before
build_*_streamreturns theStreamhandle (ALSA, ASIO, WASAPI). - Fix
buffer_capacity_in_framesinteger 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_ratevalues abovei32::MAXpanicking. - AAudio: Fix stream errors not forwarded to
error_callback. - AAudio: Return
ErrorKind::BackendErrorinstead 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 outsideCOMMON_SAMPLE_RATES. - ALSA: Fix
BufferSize::Fixedvalidation opening the PCM device a second time. - ALSA: Fix poll timeout overflow panic for stream durations exceeding ~24 days.
- ALSA: Fix
build_*_stream_rawreturningUnsupportedConfiginstead ofUnsupportedOperationfor 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::Fixedwith a size not aligned to the driver's step constraint not returningErrorKind::UnsupportedConfig. - AudioWorklet: Fix
default_output_device()returning non-Nonewhen AudioWorklet is unavailable. - AudioWorklet: Fix channel count silently clamped below
destination.maxChannelCount. - AudioWorklet: Fix
supported_output_configs()reportingFrameCount::MAXas the buffer size upper bound (correct:floor(6 * sample_rate)per spec). - AudioWorklet: Fix
supported_output_configs()reporting 128 as the minimum render quantum whenrenderQuantumSizeis 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::Fixedproducing cryptic backend errors when not validated against the hardware buffer range. - CoreAudio (iOS): Fix
BufferSize::Fixednot 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: 0orsample_rate: 0silently using PipeWire-negotiated values instead of returningErrorKind::InvalidInput. - PulseAudio: Fix
supported_output_configs()anddefault_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: 0withBufferSize::Fixedcausing a divide-by-zero panic. - WASAPI: Fix
supported_input/output_configs()anddefault_input/output_config()reporting an unconstrained buffer range on software audio stacks. - WASAPI: Fix
I24not enumerated and 24-bit devices misidentified asI32. - 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()returningSomewhen WebAudio is unavailable. - WebAudio: Fix channel count silently clamped when exceeding
destination.maxChannelCount.
asio-sys 0.3.0
- Added
Driver::latencies()to query input and output stream latencies - Added
BufferPreferenceenum with the driver's preferred buffer size and valid-size constraints
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 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 unused
SampleRatestruct - Removed
DriverStatefrom the public API
cpal 0.17.2
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.
- 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.
- 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
- ALSA:
Defaultimplementation forDevice(returns the ALSA "default" device). - CI: Checks default/no-default/all feature sets with platform-dependent MSRV for JACK.
- 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).
- ALSA: Devices now report direction from hint metadata and physical hardware probing.
cpal 0.17.0
DeviceTrait::idmethod that returns a stable audio device ID.HostTrait::device_by_idto select a device by its stable ID.DisplayandFromStrimplementations forHostId.- Support for custom
Hosts,Devices, andStreams. Sample::bits_per_samplemethod.Copyimplementation toInputCallbackInfoandOutputCallbackInfo.StreamError::StreamInvalidatedvariant for when stream must be rebuilt.StreamError::BufferUnderrunvariant for buffer underrun/overrun notifications.Hashimplementation toDevicefor all backends.- AAudio:
SendandSyncimplementations toStream. - AAudio: Support for 12 and 24 kHz sample rates.
- ALSA:
I24andU24sample 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:
EqandPartialEqimplementations toDevice. - CI: Native ARM64 Linux support in GitHub Actions.
- CoreAudio:
i8,i32andI24sample format support (24-bit samples stored in 4 bytes). - CoreAudio: Support for loopback recording (recording system audio output) on macOS > 14.6.
- CoreAudio:
Sendimplementation toStream. - Emscripten:
BufferSize::Fixedvalidation against supported range. - iOS: Complete AVAudioSession integration for device enumeration and buffer size control.
- JACK: Support for macOS and Windows platforms.
- JACK:
BufferSize::Fixedvalidation to reject requests that don't match server buffer size. - WASAPI: Expose
IMMDevicefrom WASAPI host Device. - WASAPI:
I24andU24sample format support (24-bit samples stored in 4 bytes). - WASAPI:
SendandSyncimplementations toStream. - WebAudio:
SendandSyncimplementations toStream. - WebAudio:
BufferSize::Fixedvalidation against supported range.
- MSRV depends on the platform and at minimum 1.77.
- Set examples to Rust 2021.
SampleRatefrom struct tou32type alias.- Update
audio_thread_priorityto 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::Fixedprecision and audio callback performance. - ALSA:
BufferSize::Defaultto use the device defaults. - ALSA: Card enumeration to work like
aplay -Ldoes. - ALSA: Update
alsato 0.10. - ALSA: Pass
silent=truetoPCM.try_recover, so it doesn't write to stderr. - ALSA: Report buffer underruns/overruns via
StreamError::BufferUnderrun. - ASIO: Share
sys::Asioinstance across allHostinstances. - 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 updatesyntax for compatibility with Cargo 1.70 (use-pflag instead of positional argument). - CoreAudio:
Device::supported_configsto return a single element containing the available sample rate range when all elements have the samemMinimumandmMaximumvalues. - 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
Cloneimplementation fromStream. - JACK: Use
StreamError::StreamInvalidatedfor JACK server sample rate changes. - JACK: Report buffer underruns/overruns via
StreamError::BufferUnderrun. - WASAPI: Update
windowsto >= 0.59, <= 0.62.
- ALSA: Format selection to probe hardware endianness instead of assuming native byte order.
- ALSA: Data race in stream shutdown.
- ASIO: Handling for
kAsioResetRequestmessage 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.
- WebAudio: Optional
wee-allocfeature for security reasons.