Cleanup part 3: Strip old stuff, unnecessary library

This commit is contained in:
Your Name
2023-02-20 18:39:08 -05:00
parent 3bb1ca9b1c
commit f7fde32897
5 changed files with 8 additions and 24 deletions

View File

@@ -12,13 +12,11 @@ use std::{
io::{BufRead, BufReader},
path::Path,
ptr::null_mut,
sync::{
Arc, Mutex,
},
sync::{Arc, Mutex},
};
use sm_session_notifier::SMSessionNotifier;
use window_change::{win_event_hook_loop, WIN_CHANGE_CHANNEL_TX};
use window_change::{win_event_hook_loop, WIN_CHANGE_CALLBACK};
use windows::{
core::Interface,
Win32::{
@@ -133,9 +131,9 @@ fn main() {
.boot_devices()
.expect("failed to get initial audio devices and sessions");
*WIN_CHANGE_CHANNEL_TX.lock().unwrap() = Some(
Box::new(move |s| muter.lock().unwrap().notify_window_changed(&s))
);
*WIN_CHANGE_CALLBACK.lock().unwrap() = Some(Box::new(move |s| {
muter.lock().unwrap().notify_window_changed(&s)
}));
win_event_hook_loop();
}

View File

@@ -6,7 +6,6 @@ use std::{
use crate::{
device_notification_client::DeviceNotificationClient, session_notification::SessionNotification,
};
use widestring::U16CStr;
use windows::{
core::{Interface, PCWSTR},
Win32::{
@@ -105,11 +104,8 @@ impl SMSessionNotifier {
(self.notification_function)(session);
}
let prop_store = device.OpenPropertyStore(STGM_READ)?;
// this definition isn't in windows-rs yet apparently :(
let prop_var = prop_store.GetValue(&PKEY_Device_FriendlyName)?;
let str = U16CStr::from_ptr_str(prop_var.Anonymous.Anonymous.Anonymous.pwszVal.0)
.to_string_lossy();
println!("Device Added: {} Existing Sessions: {}", str, session_count);
println!("Device Added: {} Existing Sessions: {}", prop_var.Anonymous.Anonymous.Anonymous.pwszVal.to_string()?, session_count);
self.session_managers.push(sm);
Ok(())
}

View File

@@ -14,7 +14,7 @@ use windows::Win32::{
use crate::pid_to_exe::pid_to_exe_path;
pub static WIN_CHANGE_CHANNEL_TX: Mutex<Option<Box<dyn Fn(&str)+Send>>> = Mutex::new(None);
pub static WIN_CHANGE_CALLBACK: Mutex<Option<Box<dyn Fn(&str)+Send>>> = Mutex::new(None);
unsafe extern "system" fn win_event_proc(
_hook: HWINEVENTHOOK,
@@ -33,7 +33,7 @@ unsafe extern "system" fn win_event_proc(
GetWindowThreadProcessId(hwnd, Some(&mut pid));
pid_to_exe_path(pid)
.map(|path|
WIN_CHANGE_CHANNEL_TX
WIN_CHANGE_CALLBACK
.lock()
.unwrap()
.as_ref()