@@ -15,6 +15,22 @@ use super::{
15
15
AudioNode , ChannelConfig , ChannelConfigOptions , ChannelCountMode , ChannelInterpretation ,
16
16
} ;
17
17
18
+ /// Assert that the given value number is a valid value for coneOuterGain
19
+ ///
20
+ /// # Panics
21
+ ///
22
+ /// This function will panic if:
23
+ /// - the given value is not finite and lower than zero
24
+ #[ track_caller]
25
+ #[ inline( always) ]
26
+ #[ allow( clippy:: manual_range_contains) ]
27
+ pub ( crate ) fn assert_valid_cone_outer_gain ( value : f64 ) {
28
+ assert ! (
29
+ value >= 0. && value <= 1. ,
30
+ "InvalidStateError - coneOuterGain must be in the range [0, 1]"
31
+ ) ;
32
+ }
33
+
18
34
/// Load the HRTF processor for the given sample_rate
19
35
///
20
36
/// The included data contains the impulse responses at 44100 Hertz, so it needs to be resampled
@@ -405,10 +421,7 @@ impl PannerNode {
405
421
rolloff_factor >= 0. ,
406
422
"RangeError - rolloffFactor cannot be negative"
407
423
) ;
408
- assert ! (
409
- cone_outer_gain >= 0. && cone_outer_gain <= 1. ,
410
- "InvalidStateError - coneOuterGain must be in the range [0, 1]"
411
- ) ;
424
+ assert_valid_cone_outer_gain ( cone_outer_gain) ;
412
425
assert_valid_channel_count ( channel_config. count ) ;
413
426
assert_valid_channel_count_mode ( channel_config. count_mode ) ;
414
427
@@ -610,12 +623,8 @@ impl PannerNode {
610
623
/// # Panics
611
624
///
612
625
/// Panics if the provided value is not in the range [0, 1]
613
- #[ allow( clippy:: manual_range_contains) ]
614
626
pub fn set_cone_outer_gain ( & mut self , value : f64 ) {
615
- assert ! (
616
- value >= 0. && value <= 1. ,
617
- "InvalidStateError - coneOuterGain must be in the range [0, 1]"
618
- ) ;
627
+ assert_valid_cone_outer_gain ( value) ;
619
628
self . cone_outer_gain = value;
620
629
self . registration
621
630
. post_message ( ControlMessage :: ConeOuterGain ( value) ) ;
0 commit comments