Clean up warnings

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2023-10-13 13:39:34 +09:00
parent f33417573f
commit a250a73dd6
3 changed files with 7 additions and 26 deletions

View file

@ -15,18 +15,6 @@ pub fn fail() {
std::process::exit(1);
}
pub fn average(a: &[i16]) -> f32 {
let mut sum: f32 = 0.0;
let mut avg: f32 = 0.0;
for i in a {
sum = sum + *i as f32;
}
avg = sum / (a.len() as f32);
return avg;
}
pub fn open_card(card: &str) -> alsa::ctl::Ctl {
let ctldev: alsa::ctl::Ctl = match alsa::ctl::Ctl::new(card, false) {
Ok(ctldev) => ctldev,
@ -158,10 +146,7 @@ pub fn lock_el(card: &alsa::ctl::Ctl, el: &alsa::ctl::ElemId, name: &str) {
// alsa:Result<()>
Ok(val) => val,
Err(e) => {
println!(
"Could not lock elem {}. alsa-lib error: {:?}",
name, e
);
println!("Could not lock elem {}. alsa-lib error: {:?}", name, e);
fail();
std::process::exit(1);
}

View file

@ -8,23 +8,19 @@
*/
use std::collections::BTreeMap;
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
use std::time::{Duration, Instant};
use std::{thread::sleep, time};
use std::time::Instant;
use clap::Parser;
use clap_verbosity_flag::{InfoLevel, Verbosity};
use configparser::ini::Ini;
use log;
use log::{debug, error, info, trace, warn};
use log::{debug, info, warn};
use simple_logger::SimpleLogger;
mod helpers;
mod types;
static VERSION: &str = "0.0.1";
const DEFAULT_CONFIG_PATH: &str = "share/speakersafetyd";
const UNLOCK_MAGIC: i32 = 0xdec1be15u32 as i32;
@ -173,8 +169,6 @@ fn main() {
let io = pcm.io_i16().unwrap();
let hwp = pcm.hw_params_current().unwrap();
let mut sample_rate_elem = types::Elem::new(
"Speaker Sample Rate".to_string(),
&ctl,
@ -190,7 +184,7 @@ fn main() {
unlock_elem.write_int(&ctl, UNLOCK_MAGIC);
for (idx, group) in groups.iter_mut() {
for (_idx, group) in groups.iter_mut() {
if cold_boot {
// Preset the gains to no reduction on cold boot
group.speakers.iter_mut().for_each(|s| s.update(&ctl, 0.0));

View file

@ -3,7 +3,7 @@
use alsa::ctl::Ctl;
use configparser::ini::Ini;
use log::{debug, error, info, trace, warn};
use log::{debug, info};
use std::ffi::{CStr, CString};
use crate::helpers;
@ -128,6 +128,7 @@ impl Mixer {
helpers::int_to_db(card, &self.amp_gain.id, val).to_db()
}
/*
fn get_lvl(&mut self, card: &Ctl) -> f32 {
helpers::read_ev(card, &mut self.level.val, &self.level.elem_name);
@ -139,6 +140,7 @@ impl Mixer {
helpers::int_to_db(card, &self.level.id, val).to_db()
}
*/
fn set_lvl(&mut self, card: &Ctl, lvl: f32) {
let new_val: i32 = helpers::db_to_int(card, &self.level.id, lvl);