Skip to content

Conversation

@roderickvd
Copy link
Member

Add Eq and Hash implementations for Device across ALSA, WASAPI, WebAudio, CoreAudio (macOS/iOS), AudioWorklet, and Null. Hashing is based on backend device identifiers and, for ALSA, PCM ID + direction. WASAPI hashes the COM device ID string obtained via GetId.

Add Eq/Hash implementations for Device across ALSA, WASAPI,
WebAudio, CoreAudio (macOS/iOS), AudioWorklet, and Null. Hashing is
based on backend device identifiers and, for ALSA, PCM ID + direction.
WASAPI hashes the COM device ID string obtained via GetId.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Hash and Eq trait implementations for the Device type across all audio backends (ALSA, WASAPI, WebAudio, CoreAudio for macOS/iOS, AudioWorklet, and Null). This enables Device instances to be used in hash-based collections like HashMap and HashSet.

Key Changes:

  • Simple derive macro additions for backends with trivial device types (WebAudio, Null, AudioWorklet, iOS)
  • Custom Hash/Eq/PartialEq implementations for ALSA based on PCM ID and direction
  • Custom Hash implementation for WASAPI based on COM device ID string
  • Derive macro addition for CoreAudio macOS which hashes the AudioDeviceID field

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/host/webaudio/mod.rs Added Hash derive to Device struct for WebAudio backend
src/host/wasapi/device.rs Implemented custom Hash trait using COM device ID string, consistent with existing PartialEq implementation
src/host/null/mod.rs Added Hash derive to Device struct for Null backend
src/host/coreaudio/macos/device.rs Added Hash derive to Device struct, enabling hashing of AudioDeviceID field
src/host/coreaudio/ios/mod.rs Added Hash derive to Device struct for iOS CoreAudio backend
src/host/audioworklet/mod.rs Added Hash derive to Device struct for AudioWorklet backend
src/host/alsa/mod.rs Implemented custom Hash, PartialEq, and Eq traits based on PCM ID and direction fields
CHANGELOG.md Documented the new Hash/Eq implementations and updated wording for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

alsa::Direction doesn't implement Hash, so map Capture/Playback/None to distinct u8 values when
hashing the Device to keep Hash consistent with PartialEq.
@roderickvd roderickvd merged commit e32ee65 into master Dec 9, 2025
30 checks passed
@roderickvd roderickvd deleted the feat/device-traits branch December 9, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants