audio engine: resize buffer without restarting the game

This commit is contained in:
minjaesong
2024-01-16 03:31:22 +09:00
parent 755ced9ea4
commit 2bd1b61a35
20 changed files with 39 additions and 121 deletions

View File

@@ -498,35 +498,6 @@ class AudioMixer(val bufferSize: Int): Disposable {
}, 500L)
}
fun updateBufferSizeChange() {
processing = false
processingThread.interrupt()
dynamicTracks.forEach { it.stop() }
tracks.filter { it.trackType == TrackType.STATIC_SOURCE }.forEach { it.stop() }
masterTrack.volume = 0.0
dynamicTracks.forEach { it.updateBufferSizeChange() }
tracks.forEach { it.updateBufferSizeChange() }
masterTrack.updateBufferSizeChange()
processingThread = createProcessingThread()
processing = true
processingThread.start()
// give some time for the cave bus to decay before ramping the volume up
Timer().schedule(object : TimerTask() {
override fun run() {
masterTrack.volume = 1.0
}
}, 500L)
}
override fun dispose() {
processingExecutor.killAll()
// processingSubthreads.forEach { it.interrupt() }