MCPcopy Create free account
hub / github.com/PerroEngine/Perro / stream_clip

Method stream_clip

perro_source/audio_stack/perro_pawdio/src/mic.rs:587–605  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

585 if let Some(index) = match_device_index(&names, wanted) {
586 return devices.get(index);
587 }
588 }
589 devices
590 .iter()
591 .find(|device| device.is_default)
592 .or_else(|| devices.first())
593}
594
595/// Index of `wanted`: exact match first, then trimmed case-insensitive match.
596fn match_device_index(names: &[&str], wanted: &str) -> Option<usize> {
597 let wanted = wanted.trim();
598 if wanted.is_empty() {
599 return None;
600 }
601 names.iter().position(|name| *name == wanted).or_else(|| {
602 names
603 .iter()
604 .position(|name| name.trim().eq_ignore_ascii_case(wanted))
605 })
606}
607
608/// Scan the input devices the OS exposes right now.

Callers 2

mic_stream_clipMethod · 0.45
stream_bytesMethod · 0.45

Calls 5

okMethod · 0.80
to_vecMethod · 0.80
as_refMethod · 0.45
minMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected