Revert fix(wasapi): do not emit DeviceChanged when not rerouted - #1350
Revert fix(wasapi): do not emit DeviceChanged when not rerouted#1350LastExceed wants to merge 2 commits into
fix(wasapi): do not emit DeviceChanged when not rerouted#1350Conversation
| emit_error( | ||
| error_callback, | ||
| default_device_change_error(run_context.default_device_flow), | ||
| Error::with_message(ErrorKind::DeviceChanged, "Default audio device changed"), |
There was a problem hiding this comment.
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
}
}| - **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. |
There was a problem hiding this comment.
I think this should be a bit more succinct: just document observable behavior, no need to pony up about being wrong or right.
This reverts commit e7d920b.
Closes #1339