@@ -621,28 +621,24 @@ class SampleNode {
621621 if ( this . isCanceled ) {
622622 return ;
623623 }
624- this . getPositionWorklet ( ) ;
625- this . _source . connect ( this . _positionWorklet ) ;
624+ this . _source . connect ( this . getPositionWorklet ( ) ) ;
626625 if ( start ) {
627626 this . start ( ) ;
628627 }
629628 }
630629
631630 /**
632- * Get a AudioWorkletProcessor from the pool, or create one if no processor is available.
631+ * Get a AudioWorkletProcessor
632+ * @returns {AudioWorkletNode }
633633 */
634634 getPositionWorklet ( ) {
635635 if ( this . _positionWorklet != null ) {
636- return ;
637- }
638- if ( GodotAudio . audioPositionWorkletPool . length == 0 ) {
639- this . _positionWorklet = new AudioWorkletNode (
640- GodotAudio . ctx ,
641- 'godot-position-reporting-processor'
642- ) ;
643- } else {
644- this . _positionWorklet = GodotAudio . audioPositionWorkletPool . pop ( ) ;
636+ return this . _positionWorklet ;
645637 }
638+ this . _positionWorklet = new AudioWorkletNode (
639+ GodotAudio . ctx ,
640+ 'godot-position-reporting-processor'
641+ ) ;
646642 this . _positionWorklet . port . onmessage = ( event ) => {
647643 switch ( event . data [ 'type' ] ) {
648644 case 'position' :
@@ -652,6 +648,7 @@ class SampleNode {
652648 // Do nothing.
653649 }
654650 } ;
651+ return this . _positionWorklet ;
655652 }
656653
657654 /**
@@ -681,8 +678,7 @@ class SampleNode {
681678 if ( this . _positionWorklet ) {
682679 this . _positionWorklet . disconnect ( ) ;
683680 this . _positionWorklet . port . onmessage = null ;
684- this . _positionWorklet . port . postMessage ( { type : 'clear' } ) ;
685- GodotAudio . audioPositionWorkletPool . push ( this . _positionWorklet ) ;
681+ this . _positionWorklet . port . postMessage ( { type : 'ended' } ) ;
686682 this . _positionWorklet = null ;
687683 }
688684
@@ -1199,7 +1195,6 @@ const _GodotAudio = {
11991195
12001196 /** @type {Promise } */
12011197 audioPositionWorkletPromise : null ,
1202- audioPositionWorkletPool : [ ] ,
12031198
12041199 /**
12051200 * Converts linear volume to Db.
0 commit comments