X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/f5cbae9d09cc58d8b549c36111c7a57a16b9a822..c74046ba58c5fed4c1efc2a4e06ea12325d1d4cd:/m17codec2/src/tx.rs diff --git a/m17codec2/src/tx.rs b/m17codec2/src/tx.rs index c0eb596..a54d864 100644 --- a/m17codec2/src/tx.rs +++ b/m17codec2/src/tx.rs @@ -134,6 +134,33 @@ impl Codec2TxAdapter { tx: self.event_tx.clone(), } } + + /// List sound cards supported for audio input. + /// + /// M17RT will handle any card with 1 or 2 channels and 16-bit output. + pub fn supported_input_cards() -> Vec { + let mut out = vec![]; + let host = cpal::default_host(); + let Ok(input_devices) = host.input_devices() else { + return out; + }; + for d in input_devices { + let Ok(mut configs) = d.supported_input_configs() else { + continue; + }; + if configs.any(|config| { + (config.channels() == 1 || config.channels() == 2) + && config.sample_format() == SampleFormat::I16 + }) { + let Ok(name) = d.name() else { + continue; + }; + out.push(name); + } + } + out.sort(); + out + } } enum Event {