File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -70,17 +70,23 @@ pub fn get_default_device_id(input: bool) -> Option<AudioDeviceID> {
70
70
}
71
71
72
72
/// Find the device id for a device name.
73
- pub fn get_device_id_from_name ( name : & str ) -> Option < AudioDeviceID > {
73
+ /// Set `input` to `true` to find a playback device, or `false` for a capture device.
74
+ pub fn get_device_id_from_name ( name : & str , input : bool ) -> Option < AudioDeviceID > {
75
+ let scope = match input {
76
+ false => Scope :: Output ,
77
+ true => Scope :: Input ,
78
+ } ;
74
79
if let Ok ( all_ids) = get_audio_device_ids ( ) {
75
80
return all_ids
76
81
. iter ( )
77
- . find ( |id| get_device_name ( * * id) . unwrap_or_else ( |_| "" . to_string ( ) ) == name)
82
+ . find ( |id| get_device_name ( * * id) . unwrap_or_default ( ) == name && get_audio_device_supports_scope ( * * id , scope ) . unwrap_or_default ( ) )
78
83
. copied ( ) ;
79
84
}
80
85
None
81
86
}
82
87
83
88
/// Create an AudioUnit instance from a device id.
89
+ /// Set `input` to `true` to create a playback device, or `false` for a capture device.
84
90
pub fn audio_unit_from_device_id (
85
91
device_id : AudioDeviceID ,
86
92
input : bool ,
You can’t perform that action at this time.
0 commit comments