@@ -11,21 +11,21 @@ use std::mem;
1111use std:: os:: windows:: ffi:: OsStringExt ;
1212use std:: ptr;
1313use std:: slice;
14- use std:: sync:: OnceLock ;
1514use std:: sync:: mpsc:: Sender ;
15+ use std:: sync:: OnceLock ;
1616use std:: sync:: { Arc , Mutex , MutexGuard } ;
1717use std:: time:: Duration ;
1818
1919use super :: com;
2020use super :: { windows_err_to_cpal_err, windows_err_to_cpal_err_message} ;
21- use windows:: core:: Interface ;
2221use windows:: core:: GUID ;
22+ use windows:: core:: { implement, IUnknown , Interface , HRESULT , PCWSTR , PROPVARIANT } ;
2323use windows:: Win32 :: Devices :: Properties ;
2424use windows:: Win32 :: Foundation ;
2525use windows:: Win32 :: Media :: Audio :: IAudioRenderClient ;
2626use windows:: Win32 :: Media :: { Audio , KernelStreaming , Multimedia } ;
2727use windows:: Win32 :: System :: Com ;
28- use windows:: Win32 :: System :: Com :: { StructuredStorage , STGM_READ } ;
28+ use windows:: Win32 :: System :: Com :: { CoTaskMemFree , StringFromIID , StructuredStorage , STGM_READ } ;
2929use windows:: Win32 :: System :: Threading ;
3030use windows:: Win32 :: System :: Variant :: VT_LPWSTR ;
3131
@@ -284,11 +284,11 @@ unsafe fn format_from_waveformatex_ptr(
284284}
285285
286286#[ implement( Audio :: IActivateAudioInterfaceCompletionHandler ) ]
287- struct CompletionHandler ( Sender < WinResult < IUnknown > > ) ;
287+ struct CompletionHandler ( Sender < windows :: core :: Result < IUnknown > > ) ;
288288
289289fn retrieve_result (
290290 operation : & Audio :: IActivateAudioInterfaceAsyncOperation ,
291- ) -> WinResult < IUnknown > {
291+ ) -> windows :: core :: Result < IUnknown > {
292292 let mut result = HRESULT :: default ( ) ;
293293 let mut interface: Option < IUnknown > = None ;
294294 unsafe {
@@ -302,7 +302,7 @@ impl Audio::IActivateAudioInterfaceCompletionHandler_Impl for CompletionHandler
302302 fn ActivateCompleted (
303303 & self ,
304304 operation : Option < & Audio :: IActivateAudioInterfaceAsyncOperation > ,
305- ) -> WinResult < ( ) > {
305+ ) -> windows :: core :: Result < ( ) > {
306306 let result = retrieve_result ( operation. unwrap ( ) ) ;
307307 let _ = self . 0 . send ( result) ;
308308 Ok ( ( ) )
@@ -313,10 +313,10 @@ impl Audio::IActivateAudioInterfaceCompletionHandler_Impl for CompletionHandler
313313unsafe fn ActivateAudioInterfaceSync < P0 , T > (
314314 deviceinterfacepath : P0 ,
315315 activationparams : Option < * const PROPVARIANT > ,
316- ) -> WinResult < T >
316+ ) -> windows :: core :: Result < T >
317317where
318318 P0 : windows:: core:: IntoParam < PCWSTR > ,
319- T : Interface + ComInterface ,
319+ T : Interface ,
320320{
321321 let ( sender, receiver) = std:: sync:: mpsc:: channel ( ) ;
322322 let completion: Audio :: IActivateAudioInterfaceCompletionHandler =
@@ -357,16 +357,16 @@ impl Device {
357357
358358 let prop_variant = & property_value. as_raw ( ) . Anonymous . Anonymous ;
359359
360- // Read the friendly-name from the union data field, expecting a *const u16.
361- if prop_variant. vt != VT_LPWSTR . 0 {
362- let description = format ! (
363- "property store produced invalid data: {:?}" ,
364- prop_variant. vt
365- ) ;
366- let err = BackendSpecificError { description } ;
367- return Err ( err. into ( ) ) ;
368- }
369- let ptr_utf16 = * ( & prop_variant. Anonymous as * const _ as * const * const u16 ) ;
360+ // Read the friendly-name from the union data field, expecting a *const u16.
361+ if prop_variant. vt != VT_LPWSTR . 0 {
362+ let description = format ! (
363+ "property store produced invalid data: {:?}" ,
364+ prop_variant. vt
365+ ) ;
366+ let err = BackendSpecificError { description } ;
367+ return Err ( err. into ( ) ) ;
368+ }
369+ let ptr_utf16 = * ( & prop_variant. Anonymous as * const _ as * const * const u16 ) ;
370370
371371 // Find the length of the friendly name.
372372 let mut len = 0 ;
@@ -1029,7 +1029,6 @@ impl Iterator for Devices {
10291029// }
10301030//}
10311031
1032-
10331032pub fn default_input_device ( ) -> Option < Device > {
10341033 //default_device(Audio::eCapture)
10351034 Some ( Device :: default_input ( ) )
0 commit comments