mirror of
https://github.com/ivabus/speakersafetyd
synced 2024-11-22 16:25:06 +03:00
main: Handle partial reads
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
e2b3a3ba7f
commit
b12c8b69da
1 changed files with 7 additions and 2 deletions
|
@ -243,6 +243,11 @@ fn main() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
if read != globals.period {
|
||||||
|
warn!("Expected {} samples, got {}", globals.period, read);
|
||||||
|
}
|
||||||
|
|
||||||
|
let buf_read = &buf[0..read * globals.channels];
|
||||||
|
|
||||||
let cur_sample_rate = sample_rate_elem.read_int(&ctl);
|
let cur_sample_rate = sample_rate_elem.read_int(&ctl);
|
||||||
|
|
||||||
|
@ -280,7 +285,7 @@ fn main() {
|
||||||
let gstates = (0..=max_idx)
|
let gstates = (0..=max_idx)
|
||||||
.map(|i| groups[&i].speakers.iter().map(|s| s.s.clone()).collect())
|
.map(|i| groups[&i].speakers.iter().map(|s| s.s.clone()).collect())
|
||||||
.collect();
|
.collect();
|
||||||
bb.push(sample_rate, buf.clone(), gstates);
|
bb.push(sample_rate, buf_read.to_vec(), gstates);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut all_nominal = true;
|
let mut all_nominal = true;
|
||||||
|
@ -288,7 +293,7 @@ fn main() {
|
||||||
let gain = group
|
let gain = group
|
||||||
.speakers
|
.speakers
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.map(|s| s.run_model(&buf, sample_rate as f32))
|
.map(|s| s.run_model(buf_read, sample_rate as f32))
|
||||||
.reduce(f32::min)
|
.reduce(f32::min)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if gain != group.gain {
|
if gain != group.gain {
|
||||||
|
|
Loading…
Reference in a new issue