Skip to content

Commit

Permalink
Avoid integer overflow by using i64 instead of i32
Browse files Browse the repository at this point in the history
  • Loading branch information
tazz4843 committed Nov 23, 2024
1 parent 5ee4bc5 commit 844437e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripty_audio_handler/src/events/voice_tick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ async fn handle_speakers(ssrc_state: Arc<SsrcMaps>, metrics: Arc<Metrics>, voice
.inc_by((audio.len() * SIZE_OF_I16) as _);

// incredibly useful for figuring out whether we're logging empty audio streams
let rms = ((audio.iter().map(|x| x.pow(2) as i32).sum::<i32>() as f64)
/ audio.len() as f64)
let rms = ((audio.iter().map(|x| x.pow(2) as i64).sum::<i64>() / audio.len() as i64)
as f64)
.sqrt();
trace!(%ssrc, "RMS of audio stream: {}", rms);

Expand Down

0 comments on commit 844437e

Please sign in to comment.