From 340bac5eb004ff13d39f1629d446d63958d7fbad Mon Sep 17 00:00:00 2001 From: JasonLG1979 Date: Fri, 23 Jun 2023 12:40:13 -0500 Subject: [PATCH] Warn the user if the try to set interpolation-quality with 44.1kHz --- src/main.rs | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 95e2f6eb..5590379d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -782,24 +782,6 @@ fn get_setup() -> Setup { exit(1); }); - let interpolation_quality = opt_str(INTERPOLATION_QUALITY) - .as_deref() - .map(|interpolation_quality| { - InterpolationQuality::from_str(interpolation_quality).unwrap_or_else(|_| { - let default_value = &format!("{}", InterpolationQuality::default()); - invalid_error_msg( - INTERPOLATION_QUALITY, - "", - interpolation_quality, - "Low, Medium, High", - default_value, - ); - - exit(1); - }) - }) - .unwrap_or_default(); - let sample_rate = opt_str(SAMPLE_RATE) .as_deref() .map(|sample_rate| { @@ -818,6 +800,32 @@ fn get_setup() -> Setup { }) .unwrap_or_default(); + let interpolation_quality = opt_str(INTERPOLATION_QUALITY) + .as_deref() + .map(|interpolation_quality| match sample_rate { + SampleRate::Hz44100 => { + warn!( + "--{} has no effect with a sample rate of {sample_rate}.", + INTERPOLATION_QUALITY + ); + + InterpolationQuality::default() + } + _ => InterpolationQuality::from_str(interpolation_quality).unwrap_or_else(|_| { + let default_value = &format!("{}", InterpolationQuality::default()); + invalid_error_msg( + INTERPOLATION_QUALITY, + "", + interpolation_quality, + "Low, Medium, High", + default_value, + ); + + exit(1); + }), + }) + .unwrap_or_default(); + let format = opt_str(FORMAT) .as_deref() .map(|format| {