Skip to content

feat(wasapi): auto-rerouting of default device streams#1183

Open
roderickvd wants to merge 5 commits intomasterfrom
feat/wasapi-default-rerouting
Open

feat(wasapi): auto-rerouting of default device streams#1183
roderickvd wants to merge 5 commits intomasterfrom
feat/wasapi-default-rerouting

Conversation

@roderickvd
Copy link
Copy Markdown
Member

This takes all the work by @philpax from #1027 and @sidit77 before him with #754 to support seamless rerouting of default device streams. When it does, it fires an ErrorKind::DeviceChanged event on the error callback.

Before, we were stuck in dependency hell. windows v0.59 and v0.60 are over a year old now, so for cpal v0.18 I think it's time to move on.

As I'm not a Windows user myself, this PR was prepared with Claude Code in hand. Real-world verification necessary!

Supersedes:

This comment was marked as resolved.

@philpax
Copy link
Copy Markdown

philpax commented Apr 27, 2026

Happy to see the tiebreak in favour of updating windows! Time solves all problems 🙂

I'd appreciate a Co-Authored-By on the commit if possible (and sidit might, too).

Anyhow, I notice that this PR adds a notification listener for device switching, and wires it up for the stream; if you're doing this, you can skip the entire ActivateAudioInterfaceAsync dance and implement audio switching through the notification mechanism, as Chromium does (there's more to the picture here, but this is what I vaguely remember from my own investigation).

This would also mean that it would work on pre-Windows-8 installs. The reason I didn't do this is because I didn't feel comfortable doing the required refactoring for the stream (iirc), but you may be more empowered to do so (or, at least, Claude might 😆)

Co-Authored-By: sidit77 <sidit77@gmail.com>
Co-Authored-By: philpax <me@philpax.me>
@roderickvd roderickvd force-pushed the feat/wasapi-default-rerouting branch from 173537a to 04624e9 Compare April 27, 2026 20:59
@roderickvd
Copy link
Copy Markdown
Member Author

I'd appreciate a Co-Authored-By on the commit if possible (and sidit might, too).

Absolutely! Done. Should have done that in the first place.

Anyhow, I notice that this PR adds a notification listener for device switching, and wires it up for the stream; if you're doing this, you can skip the entire ActivateAudioInterfaceAsync dance and implement audio switching through the notification mechanism, as Chromium does (there's more to the picture here, but this is what I vaguely remember from my own investigation).

This would also mean that it would work on pre-Windows-8 installs. The reason I didn't do this is because I didn't feel comfortable doing the required refactoring for the stream (iirc), but you may be more empowered to do so (or, at least, Claude might 😆)

Appreciate you reading along, and for those direct pointers to Chromium.

If I understand well, that's a different mechanism indeed: it doesn't let the OS reroute, but does so manually in the run loop by tearing down and re-creating a stream. I am doubting whether that's what we want:

  • it differs from what the other hosts do
  • it could cause a slight gap between teardown and reinitialization
  • it would not transparently deal with format changes

With Windows 8 from 2012 and Vista before it from 2007, I'd be OK with not supporting Vista and older.

This comment was marked as resolved.

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.

3 participants