26 lines
748 B
Rust
26 lines
748 B
Rust
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(())
|
|
}
|
|
}
|