mirror of
https://github.com/mii443/maudio-router.git
synced 2025-08-22 16:05:35 +00:00
config loading
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
use std::io::Read;
|
||||
|
||||
use crate::args::Run;
|
||||
|
||||
fn reshape_audio_data<T>(input: &[T], channels: usize) -> Vec<Vec<T>>
|
||||
@ -28,6 +30,25 @@ where
|
||||
output
|
||||
}
|
||||
|
||||
pub fn run(args: Run) {
|
||||
pub fn run(run: Run) {
|
||||
let config = std::path::Path::new(&run.config);
|
||||
|
||||
}
|
||||
if !config.exists() {
|
||||
eprintln!("Config file does not exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
let mut buf = String::default();
|
||||
let mut config = if let Ok(config) = std::fs::File::open(&config) {
|
||||
config
|
||||
} else {
|
||||
eprintln!("Cannot open config file.");
|
||||
return;
|
||||
};
|
||||
|
||||
config.read_to_string(&mut buf).unwrap();
|
||||
|
||||
let config: crate::config::Config = serde_yaml::from_str(&buf).unwrap();
|
||||
|
||||
println!("{:?}", config);
|
||||
}
|
||||
|
@ -1,52 +1,52 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct RoutesConfig {
|
||||
routes: Routes,
|
||||
pub struct Config {
|
||||
pub routes: Routes,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct Routes {
|
||||
input: Vec<Input>,
|
||||
output: Vec<Output>,
|
||||
pub struct Routes {
|
||||
pub input: Vec<Input>,
|
||||
pub output: Vec<Output>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct Input {
|
||||
name: String,
|
||||
virtual_device: String,
|
||||
device: Device,
|
||||
pub struct Input {
|
||||
pub name: String,
|
||||
pub virtual_device: String,
|
||||
pub device: Device,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct Output {
|
||||
name: String,
|
||||
input: OutputInput,
|
||||
device: Device,
|
||||
pub struct Output {
|
||||
pub name: String,
|
||||
pub input: OutputInput,
|
||||
pub device: Device,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct OutputInput {
|
||||
virtual_device: String,
|
||||
pub struct OutputInput {
|
||||
pub virtual_device: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum Device {
|
||||
pub enum Device {
|
||||
Local { local: LocalDevice },
|
||||
Remote { remote: RemoteDevice },
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct LocalDevice {
|
||||
name: String,
|
||||
pub struct LocalDevice {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct RemoteDevice {
|
||||
address: String,
|
||||
port: u16,
|
||||
protocol: String,
|
||||
buffer: usize,
|
||||
channels: u8,
|
||||
pub struct RemoteDevice {
|
||||
pub address: String,
|
||||
pub port: u16,
|
||||
pub protocol: String,
|
||||
pub buffer: usize,
|
||||
pub channels: u8,
|
||||
}
|
||||
|
Reference in New Issue
Block a user