@@ -11,21 +11,21 @@ use std::mem;
11
11
use std:: os:: windows:: ffi:: OsStringExt ;
12
12
use std:: ptr;
13
13
use std:: slice;
14
- use std:: sync:: OnceLock ;
15
14
use std:: sync:: mpsc:: Sender ;
15
+ use std:: sync:: OnceLock ;
16
16
use std:: sync:: { Arc , Mutex , MutexGuard } ;
17
17
use std:: time:: Duration ;
18
18
19
19
use super :: com;
20
20
use super :: { windows_err_to_cpal_err, windows_err_to_cpal_err_message} ;
21
- use windows:: core:: Interface ;
22
21
use windows:: core:: GUID ;
22
+ use windows:: core:: { implement, IUnknown , Interface , HRESULT , PCWSTR , PROPVARIANT } ;
23
23
use windows:: Win32 :: Devices :: Properties ;
24
24
use windows:: Win32 :: Foundation ;
25
25
use windows:: Win32 :: Media :: Audio :: IAudioRenderClient ;
26
26
use windows:: Win32 :: Media :: { Audio , KernelStreaming , Multimedia } ;
27
27
use windows:: Win32 :: System :: Com ;
28
- use windows:: Win32 :: System :: Com :: { StructuredStorage , STGM_READ } ;
28
+ use windows:: Win32 :: System :: Com :: { CoTaskMemFree , StringFromIID , StructuredStorage , STGM_READ } ;
29
29
use windows:: Win32 :: System :: Threading ;
30
30
use windows:: Win32 :: System :: Variant :: VT_LPWSTR ;
31
31
@@ -284,11 +284,11 @@ unsafe fn format_from_waveformatex_ptr(
284
284
}
285
285
286
286
#[ implement( Audio :: IActivateAudioInterfaceCompletionHandler ) ]
287
- struct CompletionHandler ( Sender < WinResult < IUnknown > > ) ;
287
+ struct CompletionHandler ( Sender < windows :: core :: Result < IUnknown > > ) ;
288
288
289
289
fn retrieve_result (
290
290
operation : & Audio :: IActivateAudioInterfaceAsyncOperation ,
291
- ) -> WinResult < IUnknown > {
291
+ ) -> windows :: core :: Result < IUnknown > {
292
292
let mut result = HRESULT :: default ( ) ;
293
293
let mut interface: Option < IUnknown > = None ;
294
294
unsafe {
@@ -302,7 +302,7 @@ impl Audio::IActivateAudioInterfaceCompletionHandler_Impl for CompletionHandler
302
302
fn ActivateCompleted (
303
303
& self ,
304
304
operation : Option < & Audio :: IActivateAudioInterfaceAsyncOperation > ,
305
- ) -> WinResult < ( ) > {
305
+ ) -> windows :: core :: Result < ( ) > {
306
306
let result = retrieve_result ( operation. unwrap ( ) ) ;
307
307
let _ = self . 0 . send ( result) ;
308
308
Ok ( ( ) )
@@ -313,10 +313,10 @@ impl Audio::IActivateAudioInterfaceCompletionHandler_Impl for CompletionHandler
313
313
unsafe fn ActivateAudioInterfaceSync < P0 , T > (
314
314
deviceinterfacepath : P0 ,
315
315
activationparams : Option < * const PROPVARIANT > ,
316
- ) -> WinResult < T >
316
+ ) -> windows :: core :: Result < T >
317
317
where
318
318
P0 : windows:: core:: IntoParam < PCWSTR > ,
319
- T : Interface + ComInterface ,
319
+ T : Interface ,
320
320
{
321
321
let ( sender, receiver) = std:: sync:: mpsc:: channel ( ) ;
322
322
let completion: Audio :: IActivateAudioInterfaceCompletionHandler =
@@ -357,16 +357,16 @@ impl Device {
357
357
358
358
let prop_variant = & property_value. as_raw ( ) . Anonymous . Anonymous ;
359
359
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 ) ;
370
370
371
371
// Find the length of the friendly name.
372
372
let mut len = 0 ;
@@ -1029,7 +1029,6 @@ impl Iterator for Devices {
1029
1029
// }
1030
1030
//}
1031
1031
1032
-
1033
1032
pub fn default_input_device ( ) -> Option < Device > {
1034
1033
//default_device(Audio::eCapture)
1035
1034
Some ( Device :: default_input ( ) )
0 commit comments