adjustable audio buffer size via config

This commit is contained in:
minjaesong
2023-11-26 22:53:36 +09:00
parent 21e0f984be
commit bf64c26e29
6 changed files with 27 additions and 12 deletions

View File

@@ -117,6 +117,7 @@ object AudioMixer: Disposable {
val callables = tracks.map { Callable {
if (!it.processor.paused) {
try { it.processor.run() }
catch (_: InterruptedException) {}
catch (e: Throwable) { e.printStackTrace() }
}
} }
@@ -126,7 +127,8 @@ object AudioMixer: Disposable {
processingExecutor.submitAll(callables)
processingExecutor.join()
}
catch (_: Throwable) {}
catch (_: InterruptedException) {}
catch (e: Throwable) { e.printStackTrace() }
/*processingSubthreads = tracks.map { Thread {

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.backends.lwjgl3.audio.OpenALLwjgl3Audio
import com.badlogic.gdx.utils.Disposable
import com.badlogic.gdx.utils.Queue
import net.torvald.reflection.forceInvoke
import net.torvald.terrarum.App
import net.torvald.terrarum.getHashStr
import net.torvald.terrarum.hashStrMap
import net.torvald.terrarum.modulebasegame.MusicContainer
@@ -20,7 +21,7 @@ class TerrarumAudioMixerTrack(val name: String, val isMaster: Boolean = false, v
const val SAMPLING_RATE = 48000
const val SAMPLING_RATEF = 48000f
const val SAMPLING_RATED = 48000.0
const val BUFFER_SIZE = 256*4 // n ms -> 384 * n
val BUFFER_SIZE = 4 * App.getConfigInt("audiobuffersize") // n ms -> 384 * n
}
val hash = getHashStr()