I'm trying to write a mute.fm-like program in Rust, this is my first big project both using rust and winapi. I managed to get IAudioSessionControl, but it doesn't include process ID or name, so there is no way to know which application it is. IAudioSessionControl2 has a GetProcessID method, but I can't find any way to obtain this interface.
It looks like in C# you can get it by just doing IAudioSessionControl2 ctl2 = ctl as IAudioSessionControl2;, where ctl is IAudioSessionControl (found this snippet in this issue), but in Rust that's not as simple. IAudioSessionControl2 can be converted into IAudioSessionControl using From, but not the other way around
This is the code I use, if it helps:
use std::ptr;
use windows::Win32::{Media::Audio::*, System::Com::*};
fn main() {
    unsafe {
        CoInitialize(ptr::null()).unwrap();
        let enumerator: IMMDeviceEnumerator =
            CoCreateInstance(&MMDeviceEnumerator, None, CLSCTX_ALL).unwrap();
        let device = enumerator
            .GetDefaultAudioEndpoint(eRender, eMultimedia)
            .unwrap();
        let manager: IAudioSessionManager2 = device.Activate(CLSCTX_ALL, ptr::null()).unwrap();
        let sessions = manager.GetSessionEnumerator().unwrap();
        for n in 0..sessions.GetCount().unwrap() {
            let session_control = sessions.GetSession(n).unwrap();
        }
        CoUninitialize();
    }
}