use std::fmt::Debug;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde-config", derive(serde::Serialize, serde::Deserialize))]
pub enum BackendType {
Cpal,
Alsa,
PipeWire,
Jack,
Null,
}
impl BackendType {
pub fn name(&self) -> &'static str {
match self {
BackendType::Cpal => "CPAL",
BackendType::Alsa => "ALSA",
BackendType::PipeWire => "PipeWire",
BackendType::Jack => "JACK",
BackendType::Null => "Null",
}
}
pub fn is_available(&self) -> bool {
match self {
BackendType::Cpal => true,
BackendType::Alsa => cfg!(target_os = "linux"),
BackendType::PipeWire => cfg!(target_os = "linux"),
BackendType::Jack => cfg!(any(target_os = "linux", target_os = "macos")),
BackendType::Null => true,
}
}
}
#[derive(Debug, Clone)]
pub struct DeviceInfo {
pub name: String,
pub backend: BackendType,
pub is_default: bool,
pub max_input_channels: u32,
pub max_output_channels: u32,
pub supported_sample_rates: Vec<u32>,
pub supported_buffer_sizes: Vec<u32>,
}