windows 0.52 -> 0.54 (#855)

This commit is contained in:
Ame 2024-03-02 17:33:25 -06:00 • committed by GitHub
parent f894781e7e
commit 4502781298
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 21 deletions

View file

@ -26,7 +26,7 @@ clap = { version = "4.0", features = ["derive"] }
ndk-glue = "0.7" ndk-glue = "0.7"
[target.'cfg(target_os = "windows")'.dependencies] [target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.52.0", features = [ windows = { version = "0.54.0", features = [
"Win32_Media_Audio", "Win32_Media_Audio",
"Win32_Foundation", "Win32_Foundation",
"Win32_Devices_Properties", "Win32_Devices_Properties",

View file

@ -15,18 +15,17 @@ thread_local!(static COM_INITIALIZED: ComInitialized = {
// That's OK though since COM ensures thread-safety/compatibility through marshalling when // That's OK though since COM ensures thread-safety/compatibility through marshalling when
// necessary. // necessary.
let result = CoInitializeEx(None, COINIT_APARTMENTTHREADED); let result = CoInitializeEx(None, COINIT_APARTMENTTHREADED);
match result.clone().map_err(|e| e.code()) { if result.is_ok() || result == RPC_E_CHANGED_MODE {
Ok(_) | ComInitialized {
Err(RPC_E_CHANGED_MODE) => { result,
ComInitialized { _ptr: PhantomData,
result,
_ptr: PhantomData,
}
},
Err(e) => {
// COM initialization failed in another way, something is really wrong.
panic!("Failed to initialize COM: {}", IoError::from_raw_os_error(e.0));
} }
} else {
// COM initialization failed in another way, something is really wrong.
panic!(
"Failed to initialize COM: {}",
IoError::from_raw_os_error(result.0)
);
} }
} }
}); });
@ -36,7 +35,7 @@ thread_local!(static COM_INITIALIZED: ComInitialized = {
// We store a raw pointer because it's the only way at the moment to remove `Send`/`Sync` from the // We store a raw pointer because it's the only way at the moment to remove `Send`/`Sync` from the
// object. // object.
struct ComInitialized { struct ComInitialized {
result: windows::core::Result<()>, result: windows::core::HRESULT,
_ptr: PhantomData<*mut ()>, _ptr: PhantomData<*mut ()>,
} }

View file

@ -17,7 +17,7 @@ use std::time::Duration;
use super::com; use super::com;
use super::{windows_err_to_cpal_err, windows_err_to_cpal_err_message}; use super::{windows_err_to_cpal_err, windows_err_to_cpal_err_message};
use windows::core::ComInterface; use windows::core::Interface;
use windows::core::GUID; use windows::core::GUID;
use windows::Win32::Devices::Properties; use windows::Win32::Devices::Properties;
use windows::Win32::Foundation; use windows::Win32::Foundation;
@ -297,10 +297,10 @@ impl Device {
DeviceNameError::from(err) DeviceNameError::from(err)
})?; })?;
let prop_variant = &property_value.Anonymous.Anonymous; let prop_variant = &property_value.as_raw().Anonymous.Anonymous;
// Read the friendly-name from the union data field, expecting a *const u16. // Read the friendly-name from the union data field, expecting a *const u16.
if prop_variant.vt != VT_LPWSTR { if prop_variant.vt != VT_LPWSTR.0 {
let description = format!( let description = format!(
"property store produced invalid data: {:?}", "property store produced invalid data: {:?}",
prop_variant.vt prop_variant.vt

View file

@ -243,11 +243,8 @@ fn wait_for_handle_signal(handles: &[Foundation::HANDLE]) -> Result<usize, Backe
) )
}; };
if result == Foundation::WAIT_FAILED { if result == Foundation::WAIT_FAILED {
let err = match unsafe { Foundation::GetLastError() } { let err = unsafe { Foundation::GetLastError() };
Ok(()) => windows::core::Error::OK, let description = format!("`WaitForMultipleObjectsEx failed: {:?}", err);
Err(err) => err,
};
let description = format!("`WaitForMultipleObjectsEx failed: {}", err);
let err = BackendSpecificError { description }; let err = BackendSpecificError { description };
return Err(err); return Err(err);
} }