Code cleanup part 2: Huge ass refactor edition
This commit is contained in:
31
src/session_notification.rs
Normal file
31
src/session_notification.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use windows::{
|
||||
core::{Interface},
|
||||
Win32::{
|
||||
Media::Audio::{
|
||||
IAudioSessionControl, IAudioSessionControl2,
|
||||
IAudioSessionNotification, IAudioSessionNotification_Impl,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
#[windows::core::implement(IAudioSessionNotification)]
|
||||
pub(crate) struct SessionNotification {
|
||||
pub(crate) callback: Box<dyn Fn(IAudioSessionControl2)>
|
||||
}
|
||||
|
||||
impl IAudioSessionNotification_Impl for SessionNotification {
|
||||
fn OnSessionCreated(
|
||||
self: &SessionNotification,
|
||||
newsession: &core::option::Option<IAudioSessionControl>,
|
||||
) -> windows::core::Result<()> {
|
||||
let ses: IAudioSessionControl2 = newsession.as_ref().unwrap().cast().unwrap();
|
||||
(self.callback)(ses);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for SessionNotification {
|
||||
fn drop(&mut self) {
|
||||
println!("SN drop");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user