@@ -6,7 +6,6 @@ import sys.thread.Mutex;
66import haxe .Timer ;
77import haxe .Int64 ;
88
9- import lime .app .Application ;
109import lime .media .openal .AL ;
1110import lime .media .openal .ALBuffer ;
1211import lime .media .openal .ALSource ;
@@ -129,6 +128,7 @@ class NativeAudioSource {
129128
130129 static var streamMutex : Mutex = new Mutex ();
131130 static var streamThread : Thread ;
131+ static var streamTimer : Timer ;
132132
133133 var streamRemove : Bool ;
134134
@@ -491,7 +491,7 @@ class NativeAudioSource {
491491 threadRunning = false ;
492492 }
493493
494- static function streamUpdate (_ : Int ) {
494+ static function streamUpdate () {
495495 if (! streamMutex .tryAcquire ()) return ;
496496
497497 var i = queuedStreamSources .length , source : NativeAudioSource ;
@@ -514,7 +514,7 @@ class NativeAudioSource {
514514
515515 streamMutex .release ();
516516 if (streamSources .length == 0 ) {
517- Application . current . onUpdate . remove ( streamUpdate );
517+ streamTimer . stop ( );
518518 if (threadRunning ) streamThread .sendMessage (0 );
519519 }
520520 else if (threadRunning || (threadRunning = (streamThread = Thread .create (streamThreadRun )) != null ))
@@ -536,7 +536,7 @@ class NativeAudioSource {
536536 streamRemove = false ;
537537 if (! queuedStreamSources .contains (this ) && ! streamSources .contains (this )) {
538538 queuedStreamSources .push (this );
539- if (! Application . current . onUpdate . has ( streamUpdate )) Application . current . onUpdate . add ( streamUpdate );
539+ if (streamTimer == null || ! streamTimer . mRunning ) streamTimer = resetTimer ( streamTimer , 0 , streamUpdate );
540540 }
541541 }
542542
0 commit comments