File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -366,6 +366,18 @@ pub trait AudioNode {
366
366
}
367
367
}
368
368
369
+ #[ track_caller]
370
+ #[ inline( always) ]
371
+ pub ( create) fn assert_greater_then_f64 ( value : f64 , minimum_bound : f64 ) {
372
+ if !value. is_finite ( ) {
373
+ panic ! ( "TypeError - The provided value is non-finite." ) ;
374
+ }
375
+
376
+ if value < 0. {
377
+ panic ! ( "RangeError - The offset value ({:?}) is less than the minimum bound (0)." , value, minimum_bound) ;
378
+ }
379
+ }
380
+
369
381
/// Interface of source nodes, controlling start and stop times.
370
382
/// The node will emit silence before it is started, and after it has ended.
371
383
pub trait AudioScheduledSourceNode : AudioNode {
@@ -477,3 +489,25 @@ impl<R: AudioBufferIter> AudioProcessor for MediaStreamRenderer<R> {
477
489
!self . finished
478
490
}
479
491
}
492
+
493
+ #[ cfg( test) ]
494
+ mod tests {
495
+ use super :: * ;
496
+
497
+ #[ test]
498
+ #[ should_panic]
499
+ fn test_assert_positive_f64_1 ( ) {
500
+ assert_positive_f64 ( f64:: NAN ) ;
501
+ }
502
+
503
+ #[ test]
504
+ #[ should_panic]
505
+ fn test_assert_positive_f64_1 ( ) {
506
+ assert_positive_f64 ( -1. ) ;
507
+ }
508
+
509
+ #[ test]
510
+ fn test_assert_positive_f64_1 ( ) {
511
+ assert_positive_f64 ( 1. ) ;
512
+ }
513
+ }
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ enum ControlMessage {
174
174
#[ inline( always) ]
175
175
fn assert_valid_channel_count ( count : usize ) {
176
176
if count > 2 {
177
- panic ! ( "NotSupportedError: PannerNode channel count cannot be greater than two" ) ;
177
+ panic ! ( "NotSupportedError - PannerNode channel count cannot be greater than two" ) ;
178
178
}
179
179
}
180
180
@@ -189,7 +189,7 @@ fn assert_valid_channel_count(count: usize) {
189
189
#[ inline( always) ]
190
190
fn assert_valid_channel_count_mode ( mode : ChannelCountMode ) {
191
191
if mode == ChannelCountMode :: Max {
192
- panic ! ( "NotSupportedError: PannerNode channel count mode cannot be set to max" ) ;
192
+ panic ! ( "NotSupportedError - PannerNode channel count mode cannot be set to max" ) ;
193
193
}
194
194
}
195
195
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ impl Default for StereoPannerOptions {
44
44
#[ inline( always) ]
45
45
fn assert_valid_channel_count ( count : usize ) {
46
46
if count > 2 {
47
- panic ! ( "NotSupportedError: StereoPannerNode channel count cannot be greater than two" ) ;
47
+ panic ! ( "NotSupportedError - StereoPannerNode channel count cannot be greater than two" ) ;
48
48
}
49
49
}
50
50
@@ -59,7 +59,7 @@ fn assert_valid_channel_count(count: usize) {
59
59
#[ inline( always) ]
60
60
fn assert_valid_channel_count_mode ( mode : ChannelCountMode ) {
61
61
if mode == ChannelCountMode :: Max {
62
- panic ! ( "NotSupportedError: StereoPannerNode channel count mode cannot be set to max" ) ;
62
+ panic ! ( "NotSupportedError - StereoPannerNode channel count mode cannot be set to max" ) ;
63
63
}
64
64
}
65
65
You can’t perform that action at this time.
0 commit comments