Code cleanup part 2: Huge ass refactor edition
This commit is contained in:
56
src/device_notification_client.rs
Normal file
56
src/device_notification_client.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
use windows::{
|
||||
Win32::{
|
||||
Media::Audio::{
|
||||
IMMNotificationClient, IMMNotificationClient_Impl,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
#[windows::core::implement(IMMNotificationClient)]
|
||||
pub(crate) struct DeviceNotificationClient {
|
||||
pub(crate) callback: Box<dyn Fn(&windows::core::PCWSTR)>
|
||||
}
|
||||
|
||||
impl Drop for DeviceNotificationClient {
|
||||
fn drop(&mut self) {
|
||||
println!("DNC drop");
|
||||
}
|
||||
}
|
||||
|
||||
impl IMMNotificationClient_Impl for DeviceNotificationClient {
|
||||
fn OnDeviceStateChanged(
|
||||
&self,
|
||||
_pwstrdeviceid: &windows::core::PCWSTR,
|
||||
_dwnewstate: u32,
|
||||
) -> windows::core::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn OnDeviceAdded(&self, pwstrdeviceid: &windows::core::PCWSTR) -> windows::core::Result<()> {
|
||||
(self.callback)(pwstrdeviceid);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn OnDeviceRemoved(&self, _pwstrdeviceid: &windows::core::PCWSTR) -> windows::core::Result<()> {
|
||||
println!("OnDeviceRemoved");
|
||||
// TODO: Remove device and all its sessions
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn OnDefaultDeviceChanged(
|
||||
&self,
|
||||
_flow: windows::Win32::Media::Audio::EDataFlow,
|
||||
_role: windows::Win32::Media::Audio::ERole,
|
||||
_pwstrdefaultdeviceid: &windows::core::PCWSTR,
|
||||
) -> windows::core::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn OnPropertyValueChanged(
|
||||
&self,
|
||||
_pwstrdeviceid: &windows::core::PCWSTR,
|
||||
_key: &windows::Win32::UI::Shell::PropertiesSystem::PROPERTYKEY,
|
||||
) -> windows::core::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user