Skip to content

Commit

Permalink
Avoid socketserver panic when calculating time points
Browse files Browse the repository at this point in the history
  • Loading branch information
HEnquist committed Sep 15, 2023
1 parent 58a0bca commit 3e3026d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "camilladsp"
version = "2.0.0-alpha2"
version = "2.0.0-alpha3"
authors = ["Henrik Enquist <[email protected]>"]
edition = "2021"
description = "A flexible tool for processing audio"
Expand Down
12 changes: 8 additions & 4 deletions src/socketserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1320,8 +1320,9 @@ fn clamped_volume(vol: f32) -> f32 {
}

fn playback_signal_peak_since(shared_data: &SharedData, time: f32) -> Vec<f32> {
let clamped_time = time.clamp(0.0, 1000.0);
let time_instant = Instant::now()
.checked_sub(Duration::from_secs_f32(time))
.checked_sub(Duration::from_secs_f32(clamped_time))
.unwrap();
let res = shared_data
.playback_status
Expand All @@ -1338,8 +1339,9 @@ fn playback_signal_peak_since(shared_data: &SharedData, time: f32) -> Vec<f32> {
}

fn playback_signal_rms_since(shared_data: &SharedData, time: f32) -> Vec<f32> {
let clamped_time = time.clamp(0.0, 1000.0);
let time_instant = Instant::now()
.checked_sub(Duration::from_secs_f32(time))
.checked_sub(Duration::from_secs_f32(clamped_time))
.unwrap();
let res = shared_data
.playback_status
Expand All @@ -1356,8 +1358,9 @@ fn playback_signal_rms_since(shared_data: &SharedData, time: f32) -> Vec<f32> {
}

fn capture_signal_peak_since(shared_data: &SharedData, time: f32) -> Vec<f32> {
let clamped_time = time.clamp(0.0, 1000.0);
let time_instant = Instant::now()
.checked_sub(Duration::from_secs_f32(time))
.checked_sub(Duration::from_secs_f32(clamped_time))
.unwrap();
let res = shared_data
.capture_status
Expand All @@ -1374,8 +1377,9 @@ fn capture_signal_peak_since(shared_data: &SharedData, time: f32) -> Vec<f32> {
}

fn capture_signal_rms_since(shared_data: &SharedData, time: f32) -> Vec<f32> {
let clamped_time = time.clamp(0.0, 1000.0);
let time_instant = Instant::now()
.checked_sub(Duration::from_secs_f32(time))
.checked_sub(Duration::from_secs_f32(clamped_time))
.unwrap();
let res = shared_data
.capture_status
Expand Down

0 comments on commit 3e3026d

Please sign in to comment.