From e6d8ba0914b07a7a4efb7235e3665a6e9a03f181 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 21 Jan 2025 20:13:18 -0500 Subject: [PATCH 1/3] chore: satisfy `clippy::missing_transmute_annotations` --- src/rt_win.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rt_win.rs b/src/rt_win.rs index 480c5bd..d728cec 100644 --- a/src/rt_win.rs +++ b/src/rt_win.rs @@ -94,14 +94,16 @@ mod avrt_lib { pub(super) fn try_new() -> Result { let module = OwnedLibrary::try_new(w!("avrt.dll"))?; let av_set_mm_thread_characteristics_w = unsafe { - std::mem::transmute::<_, AvSetMmThreadCharacteristicsWFn>( - module.get_proc(s!("AvSetMmThreadCharacteristicsW"))?, - ) + std::mem::transmute::< + unsafe extern "system" fn() -> isize, + AvSetMmThreadCharacteristicsWFn, + >(module.get_proc(s!("AvSetMmThreadCharacteristicsW"))?) }; let av_revert_mm_thread_characteristics = unsafe { - std::mem::transmute::<_, AvRevertMmThreadCharacteristicsFn>( - module.get_proc(s!("AvRevertMmThreadCharacteristics"))?, - ) + std::mem::transmute::< + unsafe extern "system" fn() -> isize, + AvRevertMmThreadCharacteristicsFn, + >(module.get_proc(s!("AvRevertMmThreadCharacteristics"))?) }; Ok(Self { module, From 30f46a8d164f7489d3fd9d6fecb2e69ea4c10bf9 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 21 Jan 2025 20:13:18 -0500 Subject: [PATCH 2/3] chore: satisfy `clippy::doc_lazy_continuation` --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6006f79..de4f807 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -454,7 +454,7 @@ pub extern "C" fn atp_set_real_time_limit(audio_buffer_frames: u32, /// # Arguments /// /// * `audio_buffer_frames` - the exact or an upper limit on the number of frames that have to be -/// rendered each callback, or 0 for a sensible default value. +/// rendered each callback, or 0 for a sensible default value. /// * `audio_samplerate_hz` - the sample-rate for this audio stream, in Hz. /// /// # Return value @@ -476,7 +476,7 @@ pub fn promote_current_thread_to_real_time( /// # Arguments /// /// * `handle` - An opaque struct returned from a successful call to -/// `promote_current_thread_to_real_time`. +/// `promote_current_thread_to_real_time`. /// /// # Return value /// @@ -496,7 +496,7 @@ pub struct atp_handle(RtPriorityHandle); /// # Arguments /// /// * `audio_buffer_frames` - the exact or an upper limit on the number of frames that have to be -/// rendered each callback, or 0 for a sensible default value. +/// rendered each callback, or 0 for a sensible default value. /// * `audio_samplerate_hz` - the sample-rate for this audio stream, in Hz. /// /// # Return value @@ -524,7 +524,7 @@ pub extern "C" fn atp_promote_current_thread_to_real_time( /// # Arguments /// /// * `atp_handle` - An opaque struct returned from a successful call to -/// `atp_promote_current_thread_to_real_time`. +/// `atp_promote_current_thread_to_real_time`. /// /// # Return value /// @@ -554,7 +554,7 @@ pub unsafe extern "C" fn atp_demote_current_thread_from_real_time(handle: *mut a /// # Arguments /// /// * `atp_handle` - An opaque struct returned from a successful call to -/// `atp_promote_current_thread_to_real_time`. +/// `atp_promote_current_thread_to_real_time`. /// /// # Return value /// From cfffed39397b18c39a680f3b05be61c10c1c96c7 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 21 Jan 2025 16:40:58 -0500 Subject: [PATCH 3/3] =?UTF-8?q?build:=20upgrade=20`windows-sys`=200.52=20?= =?UTF-8?q?=E2=86=92=200.59?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 +- src/rt_win.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 13e047c..66bc36a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ mach = "0.3" libc = "0.2" [target.'cfg(target_os = "windows")'.dependencies.windows-sys] -version = "0.52" +version = "0.59" features = [ "Win32_Foundation", "Win32_System_LibraryLoader", diff --git a/src/rt_win.rs b/src/rt_win.rs index d728cec..237b180 100644 --- a/src/rt_win.rs +++ b/src/rt_win.rs @@ -137,7 +137,7 @@ mod avrt_lib { let task_handle = unsafe { (self.av_set_mm_thread_characteristics_w)(task_name, &mut mmcss_task_index) }; - win32_error_if(task_handle == 0)?; + win32_error_if(task_handle.is_null())?; Ok((mmcss_task_index, task_handle)) } @@ -174,7 +174,7 @@ mod win32_utils { impl OwnedLibrary { pub(super) fn try_new(lib_file_name: PCWSTR) -> Result { let module = unsafe { LoadLibraryW(lib_file_name) }; - win32_error_if(module == 0)?; + win32_error_if(module.is_null())?; Ok(Self(module)) } @@ -201,6 +201,9 @@ mod win32_utils { } } } + + unsafe impl Send for OwnedLibrary {} + unsafe impl Sync for OwnedLibrary {} } #[cfg(test)]