diff --git a/Cargo.toml b/Cargo.toml index 7b00ce902..e1bbb0460 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ ndk-glue = "0.7" [target.'cfg(target_os = "windows")'.dependencies] windows = { version = "0.54.0", features = [ + "implement", "Win32_Media_Audio", "Win32_Foundation", "Win32_Devices_Properties", diff --git a/src/host/wasapi/device.rs b/src/host/wasapi/device.rs index 8389071c8..865469e07 100644 --- a/src/host/wasapi/device.rs +++ b/src/host/wasapi/device.rs @@ -18,14 +18,14 @@ use std::time::Duration; use super::com; use super::{windows_err_to_cpal_err, windows_err_to_cpal_err_message}; -use windows::core::Interface; +use windows::core::{HRESULT, implement, Interface, IUnknown, PCWSTR, PROPVARIANT}; use windows::core::GUID; use windows::Win32::Devices::Properties; use windows::Win32::Foundation; use windows::Win32::Media::Audio::IAudioRenderClient; use windows::Win32::Media::{Audio, KernelStreaming, Multimedia}; use windows::Win32::System::Com; -use windows::Win32::System::Com::{StructuredStorage, STGM_READ}; +use windows::Win32::System::Com::{StructuredStorage, STGM_READ, CoTaskMemFree, StringFromIID}; use windows::Win32::System::Threading; use windows::Win32::System::Variant::VT_LPWSTR; @@ -284,11 +284,11 @@ unsafe fn format_from_waveformatex_ptr( } #[implement(Audio::IActivateAudioInterfaceCompletionHandler)] -struct CompletionHandler(Sender>); +struct CompletionHandler(Sender>); fn retrieve_result( operation: &Audio::IActivateAudioInterfaceAsyncOperation, -) -> WinResult { +) -> windows::core::Result { let mut result = HRESULT::default(); let mut interface: Option = None; unsafe { @@ -302,7 +302,7 @@ impl Audio::IActivateAudioInterfaceCompletionHandler_Impl for CompletionHandler fn ActivateCompleted( &self, operation: Option<&Audio::IActivateAudioInterfaceAsyncOperation>, - ) -> WinResult<()> { + ) -> windows::core::Result<()> { let result = retrieve_result(operation.unwrap()); let _ = self.0.send(result); Ok(()) @@ -313,10 +313,10 @@ impl Audio::IActivateAudioInterfaceCompletionHandler_Impl for CompletionHandler unsafe fn ActivateAudioInterfaceSync( deviceinterfacepath: P0, activationparams: Option<*const PROPVARIANT>, -) -> WinResult +) -> windows::core::Result where P0: windows::core::IntoParam, - T: Interface + ComInterface, + T: Interface, { let (sender, receiver) = std::sync::mpsc::channel(); let completion: Audio::IActivateAudioInterfaceCompletionHandler =