Skip to content

Commit

Permalink
Switch from windows to windows-sys and update to 0.48.
Browse files Browse the repository at this point in the history
  • Loading branch information
kinetiknz authored and padenot committed Nov 2, 2023
1 parent e9f8847 commit c73488f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ default = ["with_dbus"]
mach = "0.3"
libc = "0.2"

[target.'cfg(target_os = "windows")'.dependencies.windows]
version = "^0.32.0"
[target.'cfg(target_os = "windows")'.dependencies.windows-sys]
version = "0.48"
features = [
"Win32_Foundation",
"Win32_System_Threading",
Expand Down
16 changes: 8 additions & 8 deletions src/rt_win.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use windows::Win32::Foundation::GetLastError;
use windows::Win32::Foundation::HANDLE;
use windows::Win32::Foundation::PSTR;
use windows::Win32::System::Threading::{
use windows_sys::s;
use windows_sys::Win32::Foundation::GetLastError;
use windows_sys::Win32::Foundation::FALSE;
use windows_sys::Win32::Foundation::HANDLE;
use windows_sys::Win32::System::Threading::{
AvRevertMmThreadCharacteristics, AvSetMmThreadCharacteristicsA,
};

Expand All @@ -28,7 +29,7 @@ pub fn demote_current_thread_from_real_time_internal(
rt_priority_handle: RtPriorityHandleInternal,
) -> Result<(), AudioThreadPriorityError> {
let rv = unsafe { AvRevertMmThreadCharacteristics(rt_priority_handle.task_handle) };
if !rv.as_bool() {
if rv == FALSE {
return Err(AudioThreadPriorityError::new(&format!(
"Unable to restore the thread priority ({:?})",
unsafe { GetLastError() }
Expand All @@ -49,11 +50,10 @@ pub fn promote_current_thread_to_real_time_internal(
) -> Result<RtPriorityHandleInternal, AudioThreadPriorityError> {
let mut task_index = 0u32;

let handle =
unsafe { AvSetMmThreadCharacteristicsA(PSTR("Audio\0".as_ptr()), &mut task_index) };
let handle = unsafe { AvSetMmThreadCharacteristicsA(s!("Audio"), &mut task_index) };
let handle = RtPriorityHandleInternal::new(task_index, handle);

if handle.task_handle.is_invalid() {
if handle.task_handle == 0 {
return Err(AudioThreadPriorityError::new(&format!(
"Unable to restore the thread priority ({:?})",
unsafe { GetLastError() }
Expand Down

0 comments on commit c73488f

Please sign in to comment.