mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
fix: app not quitting
This commit is contained in:
@@ -977,6 +977,9 @@ public class App implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
catch (NullPointerException | IllegalArgumentException | GdxRuntimeException | ConcurrentModificationException e) { }
|
catch (NullPointerException | IllegalArgumentException | GdxRuntimeException | ConcurrentModificationException e) { }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// kill the zombies, no matter what
|
||||||
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.backends.lwjgl3.audio.Lwjgl3Audio
|
|||||||
import com.badlogic.gdx.utils.Disposable
|
import com.badlogic.gdx.utils.Disposable
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.ModMgr
|
import net.torvald.terrarum.ModMgr
|
||||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack.Companion.SAMPLING_RATE
|
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack.Companion.SAMPLING_RATE
|
||||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack.Companion.SAMPLING_RATED
|
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack.Companion.SAMPLING_RATED
|
||||||
@@ -89,6 +90,7 @@ object AudioMixer: Disposable {
|
|||||||
var processing = true
|
var processing = true
|
||||||
|
|
||||||
private val processingExecutor = ThreadExecutor()
|
private val processingExecutor = ThreadExecutor()
|
||||||
|
// private lateinit var processingSubthreads: List<Thread>
|
||||||
val processingThread = Thread {
|
val processingThread = Thread {
|
||||||
/*while (processing) {
|
/*while (processing) {
|
||||||
// process
|
// process
|
||||||
@@ -109,32 +111,38 @@ object AudioMixer: Disposable {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
while (processing) {
|
while (processing) {
|
||||||
parallelProcessingSchedule.forEach { tracks ->
|
for (tracks in parallelProcessingSchedule) {
|
||||||
/*val callables = tracks.map { Callable {
|
if (!processing) break
|
||||||
|
|
||||||
|
val callables = tracks.map { Callable {
|
||||||
if (!it.processor.paused) {
|
if (!it.processor.paused) {
|
||||||
it.processor.run()
|
try { it.processor.run() }
|
||||||
|
catch (e: Throwable) { e.printStackTrace() }
|
||||||
}
|
}
|
||||||
} }
|
} }
|
||||||
|
|
||||||
processingExecutor.renew()
|
try {
|
||||||
processingExecutor.submitAll(callables)
|
processingExecutor.renew()
|
||||||
processingExecutor.join()*/
|
processingExecutor.submitAll(callables)
|
||||||
|
processingExecutor.join()
|
||||||
|
}
|
||||||
|
catch (_: Throwable) {}
|
||||||
|
|
||||||
|
|
||||||
val threads = tracks.map { Thread {
|
/*processingSubthreads = tracks.map { Thread {
|
||||||
if (!it.processor.paused) {
|
if (!it.processor.paused) {
|
||||||
it.processor.run()
|
it.processor.run()
|
||||||
}
|
}
|
||||||
}.also { it.priority = MAX_PRIORITY } }
|
}.also { it.priority = MAX_PRIORITY } }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
threads.forEach { it.start() }
|
processingSubthreads.forEach { it.start() }
|
||||||
threads.forEach { it.join() }
|
processingSubthreads.forEach { it.join() }
|
||||||
}
|
}
|
||||||
catch (e: InterruptedException) {}
|
catch (e: InterruptedException) {}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!masterTrack.pcmQueue.isEmpty) {
|
while (processing && !masterTrack.pcmQueue.isEmpty) {
|
||||||
masterTrack.adev!!.writeSamples(masterTrack.pcmQueue.removeFirst()) // it blocks until the queue is consumed
|
masterTrack.adev!!.writeSamples(masterTrack.pcmQueue.removeFirst()) // it blocks until the queue is consumed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,8 +397,10 @@ object AudioMixer: Disposable {
|
|||||||
|
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
processingExecutor.killAll()
|
||||||
|
// processingSubthreads.forEach { it.interrupt() }
|
||||||
processing = false
|
processing = false
|
||||||
processingThread.join()
|
processingThread.interrupt()
|
||||||
// feeder.stop()
|
// feeder.stop()
|
||||||
// feedingThread.join()
|
// feedingThread.join()
|
||||||
tracks.forEach { it.tryDispose() }
|
tracks.forEach { it.tryDispose() }
|
||||||
|
|||||||
Reference in New Issue
Block a user