@@ -4,13 +4,18 @@ use std::f32::consts::PI;
4
4
use std:: sync:: { Arc , Mutex , OnceLock } ;
5
5
6
6
use crate :: context:: { AudioContextRegistration , ConcreteBaseAudioContext } ;
7
- use crate :: events:: { ErrorEvent , Event , EventHandler , EventPayload , EventType } ;
7
+ use crate :: events:: { ErrorEvent , EventHandler , EventPayload , EventType } ;
8
8
use crate :: message:: ControlMessage ;
9
9
use crate :: render:: {
10
10
AudioParamValues , AudioProcessor , AudioRenderQuantum , AudioWorkletGlobalScope ,
11
11
} ;
12
12
use crate :: AudioBufferIter ;
13
13
14
+ // traits
15
+ mod scheduled_source;
16
+ pub use scheduled_source:: * ;
17
+
18
+ // nodes
14
19
mod analyser;
15
20
pub use analyser:: * ;
16
21
mod audio_buffer_source;
@@ -53,7 +58,6 @@ mod stereo_panner;
53
58
pub use stereo_panner:: * ;
54
59
mod waveshaper;
55
60
pub use waveshaper:: * ;
56
- //use worklet::*;
57
61
58
62
pub ( crate ) const TABLE_LENGTH_USIZE : usize = 8192 ;
59
63
pub ( crate ) const TABLE_LENGTH_BY_4_USIZE : usize = TABLE_LENGTH_USIZE / 4 ;
@@ -434,61 +438,6 @@ pub trait AudioNode {
434
438
}
435
439
}
436
440
437
- /// Interface of source nodes, controlling start and stop times.
438
- /// The node will emit silence before it is started, and after it has ended.
439
- pub trait AudioScheduledSourceNode : AudioNode {
440
- /// Play immediately
441
- ///
442
- /// # Panics
443
- ///
444
- /// Panics if the source was already started
445
- fn start ( & mut self ) ;
446
-
447
- /// Schedule playback start at given timestamp
448
- ///
449
- /// # Panics
450
- ///
451
- /// Panics if the source was already started
452
- fn start_at ( & mut self , when : f64 ) ;
453
-
454
- /// Stop immediately
455
- ///
456
- /// # Panics
457
- ///
458
- /// Panics if the source was already stopped
459
- fn stop ( & mut self ) ;
460
-
461
- /// Schedule playback stop at given timestamp
462
- ///
463
- /// # Panics
464
- ///
465
- /// Panics if the source was already stopped
466
- fn stop_at ( & mut self , when : f64 ) ;
467
-
468
- /// Register callback to run when the source node has stopped playing
469
- ///
470
- /// For all [`AudioScheduledSourceNode`]s, the ended event is dispatched when the stop time
471
- /// determined by stop() is reached. For an [`AudioBufferSourceNode`], the event is also
472
- /// dispatched because the duration has been reached or if the entire buffer has been played.
473
- ///
474
- /// Only a single event handler is active at any time. Calling this method multiple times will
475
- /// override the previous event handler.
476
- fn set_onended < F : FnOnce ( Event ) + Send + ' static > ( & self , callback : F ) {
477
- let callback = move |_| callback ( Event { type_ : "ended" } ) ;
478
-
479
- self . context ( ) . set_event_handler (
480
- EventType :: Ended ( self . registration ( ) . id ( ) ) ,
481
- EventHandler :: Once ( Box :: new ( callback) ) ,
482
- ) ;
483
- }
484
-
485
- /// Unset the callback to run when the source node has stopped playing
486
- fn clear_onended ( & self ) {
487
- self . context ( )
488
- . clear_event_handler ( EventType :: Ended ( self . registration ( ) . id ( ) ) ) ;
489
- }
490
- }
491
-
492
441
// `MediaStreamRenderer` is internally used by `MediaElementAudioSourceNode` and
493
442
// `MediaStreamAudioSourceNode`.
494
443
struct MediaStreamRenderer < R > {
0 commit comments