diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2020-04-14 11:59:08 +0300 |
---|---|---|
committer | Sebastian Dröge <slomo@coaxion.net> | 2020-04-14 12:22:43 +0300 |
commit | 5435ea1b7c248d35b42235b253afbde8fd6a4597 (patch) | |
tree | adb3bfc210a78bb70cf09770c12f96c36793ef98 /audio | |
parent | 8370fb8a118da205dd58629cb953d9a534fc8d8c (diff) |
Fix/silence some clippy warnings
Diffstat (limited to 'audio')
-rw-r--r-- | audio/audiofx/src/audioloudnorm.rs | 9 | ||||
-rw-r--r-- | audio/audiofx/tests/audioloudnorm.rs | 34 | ||||
-rw-r--r-- | audio/transcribe/src/aws_transcribe_parse.rs | 5 |
3 files changed, 31 insertions, 17 deletions
diff --git a/audio/audiofx/src/audioloudnorm.rs b/audio/audiofx/src/audioloudnorm.rs index 3d62c3747..3a5d204c1 100644 --- a/audio/audiofx/src/audioloudnorm.rs +++ b/audio/audiofx/src/audioloudnorm.rs @@ -1072,7 +1072,14 @@ impl State { // Gain reduction at the new start. Note the plus as the slope is // negative already here. - self.gain_reduction[0] = self.gain_reduction[0] + new_start * old_slope; + // + // Clippy warning ignored here because this is just incidentally the same as + // AssignAdd: we calculate a new adjusted gain reduction here, and override the + // previous one. + #[allow(clippy::assign_op_pattern)] + { + self.gain_reduction[0] = self.gain_reduction[0] + new_start * old_slope; + } // At env_cnt == ATTACK_WINDOW we need the new gain reduction self.gain_reduction[1] = gain_reduction; diff --git a/audio/audiofx/tests/audioloudnorm.rs b/audio/audiofx/tests/audioloudnorm.rs index 164e38a12..a53e83b5b 100644 --- a/audio/audiofx/tests/audioloudnorm.rs +++ b/audio/audiofx/tests/audioloudnorm.rs @@ -138,23 +138,29 @@ fn run_test( let mut num_samples = 0; let mut expected_ts = gst::ClockTime::from(0); for sample in samples.iter() { + use std::cmp::Ordering; + let buf = sample.get_buffer().unwrap(); let ts = buf.get_pts(); - if ts > expected_ts { - assert!( - ts - expected_ts <= gst::ClockTime::from(1), - "TS is {} instead of {}", - ts, - expected_ts - ); - } else if ts < expected_ts { - assert!( - expected_ts - ts <= gst::ClockTime::from(1), - "TS is {} instead of {}", - ts, - expected_ts - ); + match ts.cmp(&expected_ts) { + Ordering::Greater => { + assert!( + ts - expected_ts <= gst::ClockTime::from(1), + "TS is {} instead of {}", + ts, + expected_ts + ); + } + Ordering::Less => { + assert!( + expected_ts - ts <= gst::ClockTime::from(1), + "TS is {} instead of {}", + ts, + expected_ts + ); + } + Ordering::Equal => (), } let map = buf.map_readable().unwrap(); diff --git a/audio/transcribe/src/aws_transcribe_parse.rs b/audio/transcribe/src/aws_transcribe_parse.rs index 37cd669d6..f9be6356a 100644 --- a/audio/transcribe/src/aws_transcribe_parse.rs +++ b/audio/transcribe/src/aws_transcribe_parse.rs @@ -403,10 +403,11 @@ impl Transcriber { "AWS raised an error: {}", message.message ); - Err(gst_error_msg!( + + return Err(gst_error_msg!( gst::StreamError::Failed, ["AWS raised an error: {}", message.message] - ))?; + )); } let mut transcript: Transcript = |