Skip to content

Add AudioClient::from_device_path - #94

Merged
HEnquist merged 1 commit into
drop-umbrella-windowsfrom
device-id-client
Nov 30, 2026
Merged

HEnquist merged 1 commit into
drop-umbrella-windowsfrom
device-id-client

Conversation

@HEnquist

@HEnquist HEnquist commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Add AudioClient::from_device_path, for devices found through WinRT.

  • Takes a device interface path, such as DeviceInformation.Id, and does the ActivateAudioInterfaceAsync call itself
  • Exclusive mode works on these clients, unlike on the auto-routed default device client
  • New playsine_winrt example, enumerating and picking the device with WinRT only, using bindings generated by tools/bindings
  • README interop section and from_raw docs point to it
  • Device tests for shared and exclusive streaming and the bare endpoint id error

Related to #69.

@HEnquist HEnquist mentioned this pull request Nov 20, 2026
@LastExceed

Copy link
Copy Markdown
Contributor

I think this function needs a different name. Despite being familiar with WASAPI's native API surface, I had to check the implementation to understand what this does, and still took a solid minute to make sense of the name afterwards. From an outside perspective I'd imagine this being pretty cryptic. Granted, WASAPI itself is partially do blame for that, but I'd probably just call it AudioClient::activate and call it a day.

Also, this screams for using async fn, which I am sure would be useful to some consumers. Futures can easily be reverted to synchronous code if necessary, but the reverse is not the case.

@HEnquist

Copy link
Copy Markdown
Owner Author

Thanks yeah the name wasn't great, I changed it to something better (I think). Looking at async, I realized there are quite a few things here that are not Send, that probably could be. I'll look into that first.

@LastExceed

Copy link
Copy Markdown
Contributor

Are you referring to the structs that wrap COM objects? I've dealt a lot with COMs apartment boundaries very recently and might know a thing or two about it

@HEnquist

HEnquist commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner Author

Let's continue the Send discussion in #95. I think async without Send is a bit limiting. I'll keep this PR small and simple, so it stays without async. Async is cool but doesn't feel that important in this particular case. I measured how long activation takes and got about 0.3 ms (median over all 41 endpoints on my machine, worst case 3.5 ms for the very first one).

@HEnquist HEnquist mentioned this pull request Nov 22, 2026
7 of 10 tasks
Activates a client from a device interface path, such as the Id of a WinRT
DeviceInformation, so a caller enumerating with WinRT needs no completion
handler of their own.

- New playsine_winrt example, which finds the device purely through WinRT.
  Its bindings for MediaDevice and DeviceInformation are generated by
  tools/bindings into examples/playsine_winrt/bindings.rs, and need
  windows-future and windows-collections as dev-dependencies.
- Device tests for shared and exclusive streaming and the bare endpoint id
  error, and a test that a path with a nul is rejected.
- The README interop section and the from_raw docs point to it.
@HEnquist
HEnquist changed the base branch from master to drop-umbrella-windows November 30, 2026 22:41
@HEnquist HEnquist changed the title Add AudioClient::new_device_interface_client Add AudioClient::from_device_path Nov 30, 2026
@HEnquist
HEnquist merged commit e4f9094 into drop-umbrella-windows Nov 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants