@@ -4,13 +4,18 @@ use std::f32::consts::PI;
44use std:: sync:: { Arc , Mutex , OnceLock } ;
55
66use crate :: context:: { AudioContextRegistration , ConcreteBaseAudioContext } ;
7- use crate :: events:: { ErrorEvent , Event , EventHandler , EventPayload , EventType } ;
7+ use crate :: events:: { ErrorEvent , EventHandler , EventPayload , EventType } ;
88use crate :: message:: ControlMessage ;
99use crate :: render:: {
1010 AudioParamValues , AudioProcessor , AudioRenderQuantum , AudioWorkletGlobalScope ,
1111} ;
1212use crate :: AudioBufferIter ;
1313
14+ // traits
15+ mod scheduled_source;
16+ pub use scheduled_source:: * ;
17+
18+ // nodes
1419mod analyser;
1520pub use analyser:: * ;
1621mod audio_buffer_source;
@@ -53,7 +58,6 @@ mod stereo_panner;
5358pub use stereo_panner:: * ;
5459mod waveshaper;
5560pub use waveshaper:: * ;
56- //use worklet::*;
5761
5862pub ( crate ) const TABLE_LENGTH_USIZE : usize = 8192 ;
5963pub ( crate ) const TABLE_LENGTH_BY_4_USIZE : usize = TABLE_LENGTH_USIZE / 4 ;
@@ -434,61 +438,6 @@ pub trait AudioNode {
434438 }
435439}
436440
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-
492441// `MediaStreamRenderer` is internally used by `MediaElementAudioSourceNode` and
493442// `MediaStreamAudioSourceNode`.
494443struct MediaStreamRenderer < R > {
0 commit comments