File tree Expand file tree Collapse file tree 1 file changed +15
-30
lines changed Expand file tree Collapse file tree 1 file changed +15
-30
lines changed Original file line number Diff line number Diff line change @@ -397,46 +397,31 @@ impl AudioBackendManager for CpalBackend {
397
397
where
398
398
Self : Sized ,
399
399
{
400
- let mut index = 0 ;
401
400
let host = get_host ( ) ;
402
401
403
- let mut inputs : Vec < MediaDeviceInfo > = host
404
- . devices ( )
402
+ let input_devices = host
403
+ . input_devices ( )
405
404
. unwrap ( )
406
- . filter ( |d| d. default_input_config ( ) . is_ok ( ) )
407
- . map ( |d| {
408
- index += 1 ;
405
+ . map ( |d| ( d, MediaDeviceInfoKind :: AudioInput ) ) ;
409
406
410
- MediaDeviceInfo :: new (
411
- format ! ( "{}" , index) ,
412
- None ,
413
- MediaDeviceInfoKind :: AudioInput ,
414
- d. name ( ) . unwrap ( ) ,
415
- Box :: new ( d) ,
416
- )
417
- } )
418
- . collect ( ) ;
419
-
420
- let mut outputs: Vec < MediaDeviceInfo > = host
421
- . devices ( )
407
+ let output_devices = host
408
+ . output_devices ( )
422
409
. unwrap ( )
423
- . filter ( |d| d. default_output_config ( ) . is_ok ( ) )
424
- . map ( |d| {
425
- index += 1 ;
410
+ . map ( |d| ( d, MediaDeviceInfoKind :: AudioOutput ) ) ;
426
411
412
+ input_devices
413
+ . chain ( output_devices)
414
+ . enumerate ( )
415
+ . map ( |( index, ( device, kind) ) | {
427
416
MediaDeviceInfo :: new (
428
- format ! ( "{}" , index) ,
417
+ ( index + 1 ) . to_string ( ) ,
429
418
None ,
430
- MediaDeviceInfoKind :: AudioOutput ,
431
- d . name ( ) . unwrap ( ) ,
432
- Box :: new ( d ) ,
419
+ kind ,
420
+ device . name ( ) . unwrap ( ) ,
421
+ Box :: new ( device ) ,
433
422
)
434
423
} )
435
- . collect ( ) ;
436
-
437
- inputs. append ( & mut outputs) ;
438
-
439
- inputs
424
+ . collect ( )
440
425
}
441
426
}
442
427
You can’t perform that action at this time.
0 commit comments