Skip to content

Revert fix(wasapi): do not emit DeviceChanged when not rerouted - #1350

Open
LastExceed wants to merge 2 commits into
RustAudio:stable-0.18from
LastExceed:reallow-wasapi-rerouting
Open

Revert fix(wasapi): do not emit DeviceChanged when not rerouted#1350
LastExceed wants to merge 2 commits into
RustAudio:stable-0.18from
LastExceed:reallow-wasapi-rerouting

Conversation

@LastExceed

@LastExceed LastExceed commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This reverts commit e7d920b.

Closes #1339

Comment thread src/host/wasapi/stream.rs
emit_error(
error_callback,
default_device_change_error(run_context.default_device_flow),
Error::with_message(ErrorKind::DeviceChanged, "Default audio device changed"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems to throw out more than #1339 needs. StreamInvalidated is wrong when a replacement device exists, but default_device_change_error's other branch serves a different purpose:

OnDeviceStateChanged and OnDeviceRemoved only SetEvent when get_current_default(self.flow).is_none() (see the comment above them), so they only ever wake this code up for the no-replacement case. After this revert that case gets reported as DeviceChanged too, which contradicts its definition: "the stream remains active and no rebuild is required." There's nothing to route to there, so that isn't true.

I think the fix should be smaller than a full revert: keep default_device_change_error, just fix the one arm that was actually wrong:

fn default_device_change_error(flow: Option<Audio::EDataFlow>) -> Error {
    match flow.and_then(get_current_default) {
        None => ErrorKind::DeviceNotAvailable.into(),
        Some(_) => ErrorKind::DeviceChanged.into(), // was StreamInvalidated
    }
}

Comment thread CHANGELOG.md
- **AudioWorklet**: Fix stale output when the data callback grows Wasm memory.
- **JACK**: Channel enumeration is capped at the physical system port count again.
- **WASAPI**: Device enumeration no longer panics if the COM enumerator fails to initialize.
- **WASAPI**: Revert "Default device changes no longer report `DeviceChanged`" as it was misinformed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be a bit more succinct: just document observable behavior, no need to pony up about being wrong or right.

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