mirror of
https://github.com/mii443/maudio-router.git
synced 2025-08-23 00:15:37 +00:00
wip
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
use std::io::Read;
|
||||
|
||||
use cpal::{traits::{DeviceTrait, HostTrait}, Device};
|
||||
|
||||
use crate::args::Run;
|
||||
|
||||
pub fn run(run: Run) {
|
||||
@ -22,5 +24,76 @@ pub fn run(run: Run) {
|
||||
|
||||
let config: crate::config::Config = serde_yaml::from_str(&buf).unwrap();
|
||||
|
||||
println!("{:?}", config);
|
||||
let host = cpal::default_host();
|
||||
let input_devices: Vec<Device> = host.input_devices().unwrap().collect();
|
||||
let output_devices: Vec<Device> = host.output_devices().unwrap().collect();
|
||||
|
||||
// create virtual devices
|
||||
let mut virtual_devices = Vec::new();
|
||||
for virtual_device in config.virtual_devices {
|
||||
let device = crate::device::virtual_device::VirtualDevice::new(virtual_device.name, virtual_device.channels, virtual_device.sample_rate);
|
||||
virtual_devices.push(device);
|
||||
}
|
||||
|
||||
for input_route in config.routes.input {
|
||||
println!("Input: {}", input_route.name);
|
||||
println!(" Virtual device: {}", input_route.virtual_device);
|
||||
if virtual_devices.iter().any(|device| device.name == input_route.virtual_device) {
|
||||
println!(" Found");
|
||||
} else {
|
||||
println!(" Not found");
|
||||
}
|
||||
|
||||
match input_route.device {
|
||||
crate::config::Device::Local { local } => {
|
||||
println!(" Local device: {}", local.name);
|
||||
if input_devices
|
||||
.iter()
|
||||
.any(|device| device.name().unwrap() == local.name)
|
||||
{
|
||||
println!(" Found");
|
||||
} else {
|
||||
println!(" Not found");
|
||||
}
|
||||
}
|
||||
crate::config::Device::Remote { remote } => {
|
||||
println!(" Remote device: {}", remote.address);
|
||||
println!(" Port: {}", remote.port);
|
||||
println!(" Protocol: {}", remote.protocol);
|
||||
println!(" Buffer: {}", remote.buffer);
|
||||
println!(" Channels: {}", remote.channels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for output_route in config.routes.output {
|
||||
println!("Output: {}", output_route.name);
|
||||
println!(" Virtual device: {}", output_route.input.virtual_device);
|
||||
if virtual_devices.iter().any(|device| device.name == output_route.input.virtual_device) {
|
||||
println!(" Found");
|
||||
} else {
|
||||
println!(" Not found");
|
||||
}
|
||||
|
||||
match output_route.device {
|
||||
crate::config::Device::Local { local } => {
|
||||
println!(" Local device: {}", local.name);
|
||||
if output_devices
|
||||
.iter()
|
||||
.any(|device| device.name().unwrap() == local.name)
|
||||
{
|
||||
println!(" Found");
|
||||
} else {
|
||||
println!(" Not found");
|
||||
}
|
||||
}
|
||||
crate::config::Device::Remote { remote } => {
|
||||
println!(" Remote device: {}", remote.address);
|
||||
println!(" Port: {}", remote.port);
|
||||
println!(" Protocol: {}", remote.protocol);
|
||||
println!(" Buffer: {}", remote.buffer);
|
||||
println!(" Channels: {}", remote.channels);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user