diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-22 01:41:30 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-22 01:42:02 +0800 |
| commit | 38d6036c1c3bff292b8f1d42c9eb0f26c34fe4a7 (patch) | |
| tree | e6f324ee734a94c540b9d67eb24d1400438e3f22 /src/main.rs | |
| parent | e703c9376cd000161672ff225ff8e0f3c167ed9f (diff) | |
feat: add cpal-based auto device detection and configuration
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs index 2aa68ac..87f7657 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,9 @@ pub mod post_proc; mod args; pub use args::*; +mod device_selector; mod output_protocol; + use clap::Parser; use output_protocol::OutputProtocol; use std::path::PathBuf; @@ -220,30 +222,14 @@ async fn main() { // --------------------------------------------------------------- // Find the requested device and start capture // --------------------------------------------------------------- - let device_name = match &args.device_name { - Some(n) => n.as_str(), - None => { - eprintln!( - "[dmvop] No device specified. Use --device=<name> or --list-devices to see available devices." - ); - std::process::exit(1); - } - }; - - let device = devices - .iter() - .find(|d| d.id == device_name || d.name == device_name) - .or_else(|| devices.first()); + let device = device_selector::pick_device(&args.device_name, &devices); match &device { Some(d) => { debug_log!("[dmvop] Using input device: {} (id: {})", d.name, d.id); } None => { - eprintln!( - "[dmvop] Device '{}' not found and no fallback available.", - device_name - ); + eprintln!("[dmvop] No input devices found. Make sure a microphone is connected."); std::process::exit(1); } } |
