diff --git a/Cargo.lock b/Cargo.lock
index 4dfcc90..2e1ec73 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6,7 +6,6 @@ version = 3
name = "auto_mute_tool"
version = "0.1.0"
dependencies = [
- "widestring",
"windows",
]
@@ -45,12 +44,6 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
-[[package]]
-name = "widestring"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8"
-
[[package]]
name = "windows"
version = "0.44.0"
diff --git a/Cargo.toml b/Cargo.toml
index 04c87f2..62bda75 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,9 +5,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-[dependencies]
-widestring = "1.0.2"
-
[dependencies.windows]
version = "0.44.0"
features = [
diff --git a/src/main.rs b/src/main.rs
index 864cc2f..1d39759 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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();
}
diff --git a/src/sm_session_notifier.rs b/src/sm_session_notifier.rs
index cd6822e..82e0121 100644
--- a/src/sm_session_notifier.rs
+++ b/src/sm_session_notifier.rs
@@ -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(())
}
diff --git a/src/window_change.rs b/src/window_change.rs
index 2d759a8..b6914b0 100644
--- a/src/window_change.rs
+++ b/src/window_change.rs
@@ -14,7 +14,7 @@ use windows::Win32::{
use crate::pid_to_exe::pid_to_exe_path;
-pub static WIN_CHANGE_CHANNEL_TX: Mutex