diff --git a/source/lime/_internal/backend/native/NativeAudioSource.hx b/source/lime/_internal/backend/native/NativeAudioSource.hx index 773175c6..9a7b46b7 100644 --- a/source/lime/_internal/backend/native/NativeAudioSource.hx +++ b/source/lime/_internal/backend/native/NativeAudioSource.hx @@ -6,7 +6,6 @@ import sys.thread.Mutex; import haxe.Timer; import haxe.Int64; -import lime.app.Application; import lime.media.openal.AL; import lime.media.openal.ALBuffer; import lime.media.openal.ALSource; @@ -129,6 +128,7 @@ class NativeAudioSource { static var streamMutex:Mutex = new Mutex(); static var streamThread:Thread; + static var streamTimer:Timer; var streamRemove:Bool; @@ -491,7 +491,7 @@ class NativeAudioSource { threadRunning = false; } - static function streamUpdate(_:Int) { + static function streamUpdate() { if (!streamMutex.tryAcquire()) return; var i = queuedStreamSources.length, source:NativeAudioSource; @@ -514,7 +514,7 @@ class NativeAudioSource { streamMutex.release(); if (streamSources.length == 0) { - Application.current.onUpdate.remove(streamUpdate); + streamTimer.stop(); if (threadRunning) streamThread.sendMessage(0); } else if (threadRunning || (threadRunning = (streamThread = Thread.create(streamThreadRun)) != null)) @@ -536,7 +536,7 @@ class NativeAudioSource { streamRemove = false; if (!queuedStreamSources.contains(this) && !streamSources.contains(this)) { queuedStreamSources.push(this); - if (!Application.current.onUpdate.has(streamUpdate)) Application.current.onUpdate.add(streamUpdate); + if (streamTimer == null || !streamTimer.mRunning) streamTimer = resetTimer(streamTimer, 0, streamUpdate); } }