fix: remove default() and new() where not cross-platform compatible#1212
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes recently-added Default impls and new() constructors from several host/backend-specific types where they’re not meant to be relied on cross-platform, and adjusts call sites accordingly (e.g., constructing devices/iterators directly instead of via Default/new()).
Changes:
- Removed
Defaultderives / impls andnew()constructors from various backendHost/Device/iterator types (WebAudio, AudioWorklet, Null, WASAPI, CoreAudio macOS/iOS, AAudio, ALSA). - Replaced
Default-based construction with explicit construction (e.g.,Devices(is_available)/Device(None)). - ALSA default device creation now reuses the host’s existing context instead of creating a new one via
Default.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/host/webaudio/mod.rs |
Removes Default/new() and constructs Devices explicitly based on WebAudio availability. |
src/host/wasapi/mod.rs |
Removes Default derive from WASAPI Host. |
src/host/null/mod.rs |
Removes Default/new() from Null backend types and updates devices() accordingly. |
src/host/coreaudio/macos/mod.rs |
Removes Default derive from CoreAudio macOS Host. |
src/host/coreaudio/ios/mod.rs |
Removes Default/new() usage and constructs Devices directly (currently introduces a privacy/constructability issue). |
src/host/coreaudio/ios/enumerate.rs |
Removes Devices::new()/Default for iOS enumerator iterator. |
src/host/audioworklet/mod.rs |
Removes Default/new() and constructs Devices explicitly from availability. |
src/host/alsa/mod.rs |
Removes Default for ALSA Device; adds Host::default_device() using the host context. |
src/host/aaudio/mod.rs |
Removes Default/new() for AAudio Device and replaces call sites with Device(None). |
CHANGELOG.md |
Updates changelog entries to reflect removed Default/new() additions and related fixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Revert most of #1211 where
Defaultandnewwere not cross-compatible and/or non-idiomatic for private use.