Skip to content

Commit c06804a

Browse files
committed
Fix: run assertions on PannerNode ctor, not only when updating values
1 parent a78691e commit c06804a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/node/panner.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,25 @@ impl PannerNode {
393393
panning_model,
394394
} = options;
395395

396+
assert!(
397+
ref_distance >= 0.,
398+
"RangeError - refDistance cannot be negative"
399+
);
400+
assert!(
401+
max_distance > 0.,
402+
"RangeError - maxDistance must be positive"
403+
);
404+
assert!(
405+
rolloff_factor >= 0.,
406+
"RangeError - rolloffFactor cannot be negative"
407+
);
408+
assert!(
409+
cone_outer_gain >= 0. && cone_outer_gain <= 1.,
410+
"InvalidStateError - coneOuterGain must be in the range [0, 1]"
411+
);
412+
assert_valid_channel_count(channel_config.count);
413+
assert_valid_channel_count_mode(channel_config.count_mode);
414+
396415
// position params
397416
let (param_px, render_px) = context.create_audio_param(PARAM_OPTS, &registration);
398417
let (param_py, render_py) = context.create_audio_param(PARAM_OPTS, &registration);
@@ -540,7 +559,7 @@ impl PannerNode {
540559
///
541560
/// Panics if the provided value is negative.
542561
pub fn set_max_distance(&mut self, value: f64) {
543-
assert!(value >= 0., "RangeError - maxDistance cannot be negative");
562+
assert!(value > 0., "RangeError - maxDistance must be positive");
544563
self.max_distance = value;
545564
self.registration
546565
.post_message(ControlMessage::MaxDistance(value));

0 commit comments

Comments
 (0)