-
Notifications
You must be signed in to change notification settings - Fork 442
Open
Description
Current behavior
I am using rodio
to play audio on Windows 11. When I change the output device on Windows, the audio continues to play on the old device.
There is a similar issue for macOS. But that is fixed in RustAudio/rodio#327.
The behavior I expected
On Windows, if user creates a device with Device::default_output_device()
and plays audio through it, when user changes Windows's output device, the audio should play on the new device.
Document:
https://learn.microsoft.com/en-us/windows/win32/coreaudio/device-events
-
Add
implement
feature towindows
crate:[target.'cfg(target_os = "windows")'.dependencies] windows = { ..., features = [..., "implement"] }
-
Implement IMMNotificationClient:
#[implement(windows::Win32::Media::Audio::IMMNotificationClient)] struct IMMNotificationClientWrapper {} impl windows::Win32::Media::Audio::IMMNotificationClient_Impl for IMMNotificationClientWrapper { ... fn OnDefaultDeviceChanged(&self, flow: EDataFlow, role: ERole, pwstrdefaultdeviceid: &PCWSTR, ) -> Result<(), windows::core::Error> { todo!("Handle default device changed event"); } }
-
Register the
IMMNotificationClientWrapper
insrc\host\wasapi\device.rs
:ENUMERATOR.0.RegisterEndpointNotificationCallback(IMM_NOTIFICATION_CLIENT_WRAPPER);
ZacharyL2, phwoo, SupernaviX, JerwuQu, zeyonaut and 2 more
Metadata
Metadata
Assignees
Labels
No labels