Skip to content

Add support for WinRT #69

Open
Open

Description

@LastExceed

Motivation:

For instance, the MediaDevice and DeviceInformation classes can be used to retrieve a device path for use in ActivateAudioInterfaceAsync()

Activity

  1. HEnquist commented on Oct 4, 2026

    @HEnquist
    Owner

    Thanks for the suggestion. Unfortunately I don't think a move to WinRT is something I can do. Several things the crate relies on have no WinRT equivalent that I can find. The capability probe reads the driver's declared data ranges through IDeviceTopology and the KS filter, and I don't see a way to start that from a WinRT device. Session manager and meter access, endpoint properties, the full DeviceState values and the device notifications are in the same position. The endpoint id format would change as well, so it would also be a breaking change.

    The crate does not cache the enumerator or any other COM object globally, so the problem in the cpal issue does not apply here as it is described there. Have you run into an actual problem when using wasapi-rs? If so, please describe it, ideally with a small reproduction. If it turns out to be a real problem, I think a much smaller fix is possible. Device could store the endpoint id as a string and create the IMMDevice on demand on the calling thread.

  2. LastExceed commented on Oct 4, 2026

    @LastExceed
    ContributorAuthor

    Oh I didn't mean replacing the multimedia stuff, with "removes the need for XY" I was just thinking from a user perspective (same goes for the apartment boundary thing, since users might send stuff to other threads without knowing about COMs threading rules). I'd imagine the WinRT APIs being purely additive to the crate.

  3. changed the title [-]Use WinRT[/-] [+]Add support for WinRT[/+] on Oct 5, 2026
  4. LastExceed commented on Oct 5, 2026

    @LastExceed
    ContributorAuthor

    I recognize that my phrasing was pretty misleading, my bad

  5. HEnquist commented on Oct 5, 2026

    @HEnquist
    Owner

    Thanks for clarifying, I misread the suggestion as a replacement. I hadn't considered adding a second way to do the same thing next to the existing one, and I think that is out of scope for this crate. It would be a second set of device types with different ids, and the devices found that way could not use the capability probe or the data ranges. I would rather not duplicate the two overlapping APIs that Windows already has.

    Anyone who needs the WinRT APIs can use them directly from the windows crate, which exposes all of WinRT.

    What I can do is make that combination easier. I would add a constructor that builds an AudioClient from an IAudioClient you have activated yourself, for example through ActivateAudioInterfaceAsync. Then you can enumerate with WinRT and still use the streaming code in this crate.

    Do you know of a use case where this approach would not work?

  6. LastExceed commented on Oct 5, 2026

    @LastExceed
    ContributorAuthor

    I would rather not duplicate the two overlapping APIs that Windows already has.

    Hmm I understand. I'll look into how much would actually have to be duplicated, because I didn't expect it to be that much

    Do you know of a use case where this approach would not work?

    Can't think of anything

  7. HEnquist commented on Nov 20, 2026

    @HEnquist
    Owner

    I realized we can do a bit better than what I did before. #94 adds AudioClient::new_device_interface_client, which takes the Id of a WinRT DeviceInformation and does the activation itself, so no completion handler is needed in the user code. Exclusive mode works on these clients too, and the new playsine_winrt example does the device side purely through WinRT.

    I'll close this once it's released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions