feat(coreaudio): report device transport as InterfaceType - #1345
Open
jplot wants to merge 1 commit into
Open
Conversation
interface_type() was only set for aggregate devices on macOS; everything else, including built-in microphones and USB interfaces, reported Unknown. kAudioDevicePropertyTransportType names the connection, and InterfaceType already has variants for nearly every value it returns. The WASAPI backend fills the same field from its endpoint properties, so this closes an asymmetry rather than adding an API. is_aggregate_device() stays as a fallback: TransportType reports "grup" for aggregates too, and the two agree where both apply.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The property query introduces undefined behavior and omits the supported AVB network transport.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced
Comment on lines
+448
to
+462
| const AIRPLAY: u32 = u32::from_be_bytes(*b"airp"); | ||
|
|
||
| match transport { | ||
| BUILT_IN => Some(InterfaceType::BuiltIn), | ||
| USB => Some(InterfaceType::Usb), | ||
| BLUETOOTH | BLUETOOTH_LE => Some(InterfaceType::Bluetooth), | ||
| VIRTUAL => Some(InterfaceType::Virtual), | ||
| AGGREGATE => Some(InterfaceType::Aggregate), | ||
| THUNDERBOLT => Some(InterfaceType::Thunderbolt), | ||
| HDMI => Some(InterfaceType::Hdmi), | ||
| DISPLAY_PORT => Some(InterfaceType::DisplayPort), | ||
| FIREWIRE => Some(InterfaceType::FireWire), | ||
| PCI => Some(InterfaceType::Pci), | ||
| AIRPLAY => Some(InterfaceType::Network), | ||
| _ => None, |
Comment on lines
+418
to
+428
| let data_size = size_of::<u32>() as u32; | ||
|
|
||
| // SAFETY: AudioObjectGetPropertyData writes a UInt32 for | ||
| // kAudioDevicePropertyTransportType. The status is checked before use. | ||
| let status = unsafe { | ||
| AudioObjectGetPropertyData( | ||
| self.audio_device_id, | ||
| NonNull::from(&property_address), | ||
| 0, | ||
| null(), | ||
| NonNull::from(&data_size), |
Member
|
Thanks for your contribution! I re-ran the failed Copilot review you requested; if you'd please process those points? |
roderickvd
reviewed
Aug 30, 2026
| - `InputStreamTimestamp`/`OutputStreamTimestamp` merged into `StreamTimestamp`; `capture`/`playback` renamed `device`. | ||
| - Renamed the `wasm-beep` and `audioworklet-beep` examples to `webaudio` and `audioworklet`. | ||
| - **ALSA**: Update `alsa` dependency to 0.12. | ||
| - **CoreAudio**: `DeviceDescription::interface_type()` now reports the device transport (built-in, USB, Bluetooth, Thunderbolt, HDMI, and others) instead of only marking aggregate devices. |
Member
There was a problem hiding this comment.
This could be a bit shorter by removing the examples in the parentheses.
roderickvd
reviewed
Aug 31, 2026
| } | ||
|
|
||
| // Four-character codes from AudioHardwareBase.h. | ||
| const BUILT_IN: u32 = u32::from_be_bytes(*b"bltn"); |
Member
There was a problem hiding this comment.
The following are already exported by objc2_core_audio:
pub const kAudioDeviceTransportTypeUnknown: u32 = 0;
pub const kAudioDeviceTransportTypeBuiltIn: u32 = 0x626c746e;
pub const kAudioDeviceTransportTypeAggregate: u32 = 0x67727570;
pub const kAudioDeviceTransportTypeVirtual: u32 = 0x76697274;
pub const kAudioDeviceTransportTypePCI: u32 = 0x70636920;
pub const kAudioDeviceTransportTypeUSB: u32 = 0x75736220;
pub const kAudioDeviceTransportTypeFireWire: u32 = 0x31333934;
pub const kAudioDeviceTransportTypeBluetooth: u32 = 0x626c7565;
pub const kAudioDeviceTransportTypeBluetoothLE: u32 = 0x626c6561;
pub const kAudioDeviceTransportTypeHDMI: u32 = 0x68646d69;
pub const kAudioDeviceTransportTypeDisplayPort: u32 = 0x64707274;
pub const kAudioDeviceTransportTypeAirPlay: u32 = 0x61697270;
pub const kAudioDeviceTransportTypeAVB: u32 = 0x65617662;
pub const kAudioDeviceTransportTypeThunderbolt: u32 = 0x7468756e;
pub const kAudioDeviceTransportTypeContinuityCaptureWired: u32 = 0x63637764;
pub const kAudioDeviceTransportTypeContinuityCaptureWireless: u32 = 0x6363776c;
pub const kAudioDeviceTransportTypeContinuityCapture: u32 = 0x63636170;
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.
Motivation
On macOS,
interface_type()is only set for aggregate devices — built-inmicrophones, USB interfaces and Bluetooth headsets all report
Unknown.The WASAPI backend already fills this field from its endpoint properties.
CoreAudio exposes the same information through
kAudioDevicePropertyTransportType,and
InterfaceTypealready has variants for nearly every value it returns, sothis closes the asymmetry without an API change.
Result
Same machine, before and after — all four are ordinary devices, not edge cases:
UnknownBuiltInUnknownBuiltInUnknownVirtualUnknownVirtualNotes
Option, so an unmapped transport leaves the field unset rather thanclaiming
Unknown.is_aggregate_device()is kept as a fallback:TransportTypereportsgrupfor aggregates too, and I would rather not drop a path I cannot reproduce.
airp(AirPlay) maps toNetwork— the one mapping I would gladly change.and DisplayPort arms are unverified: no such hardware here.