Skip to content

Commit

Permalink
windows 0.52 -> 0.54 (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
ameknite authored Mar 2, 2024
1 parent f894781 commit 4502781
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ clap = { version = "4.0", features = ["derive"] }
ndk-glue = "0.7"

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.52.0", features = [
windows = { version = "0.54.0", features = [
"Win32_Media_Audio",
"Win32_Foundation",
"Win32_Devices_Properties",
Expand Down
23 changes: 11 additions & 12 deletions src/host/wasapi/com.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ thread_local!(static COM_INITIALIZED: ComInitialized = {
// That's OK though since COM ensures thread-safety/compatibility through marshalling when
// necessary.
let result = CoInitializeEx(None, COINIT_APARTMENTTHREADED);
match result.clone().map_err(|e| e.code()) {
Ok(_) |
Err(RPC_E_CHANGED_MODE) => {
ComInitialized {
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));
if result.is_ok() || result == RPC_E_CHANGED_MODE {
ComInitialized {
result,
_ptr: PhantomData,
}
} else {
// COM initialization failed in another way, something is really wrong.
panic!(
"Failed to initialize COM: {}",
IoError::from_raw_os_error(result.0)
);
}
}
});
Expand All @@ -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
// object.
struct ComInitialized {
result: windows::core::Result<()>,
result: windows::core::HRESULT,
_ptr: PhantomData<*mut ()>,
}

Expand Down
6 changes: 3 additions & 3 deletions src/host/wasapi/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::time::Duration;

use super::com;
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::Win32::Devices::Properties;
use windows::Win32::Foundation;
Expand Down Expand Up @@ -297,10 +297,10 @@ impl Device {
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.
if prop_variant.vt != VT_LPWSTR {
if prop_variant.vt != VT_LPWSTR.0 {
let description = format!(
"property store produced invalid data: {:?}",
prop_variant.vt
Expand Down
7 changes: 2 additions & 5 deletions src/host/wasapi/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,8 @@ fn wait_for_handle_signal(handles: &[Foundation::HANDLE]) -> Result<usize, Backe
)
};
if result == Foundation::WAIT_FAILED {
let err = match unsafe { Foundation::GetLastError() } {
Ok(()) => windows::core::Error::OK,
Err(err) => err,
};
let description = format!("`WaitForMultipleObjectsEx failed: {}", err);
let err = unsafe { Foundation::GetLastError() };
let description = format!("`WaitForMultipleObjectsEx failed: {:?}", err);
let err = BackendSpecificError { description };
return Err(err);
}
Expand Down

0 comments on commit 4502781

Please sign in to comment.