fix: mp2 384k would cause stack overflow error

This commit is contained in:
minjaesong
2023-01-23 15:34:22 +09:00
parent c1031545ec
commit 8517406d8b
5 changed files with 34 additions and 7 deletions

View File

@@ -233,11 +233,15 @@ class AudioAdapter(val vm: VM) : PeriBase(VM.PERITYPE_SOUND) {
41 -> mp2Busy.toInt().toByte()
in 64..2367 -> mediaDecodedBin[addr - 64]
in 2368..4095 -> mediaFrameBin[addr - 2368]
in 4096..4097 -> 0
in 32768..65535 -> (adi - 32768).let {
cueSheet[it / 16].read(it % 15)
}
in 65536..131071 -> pcmBin[addr - 65536]
else -> mmio_read(addr % 131072)
else -> {
println("[AudioAdapter] Bus mirroring on mmio_reading while trying to read address $addr")
mmio_read(addr % 131072)
}
}
}

View File

@@ -338,7 +338,13 @@ class MP2Env(val vm: VM) {
samplesR[pushSizeR++] = sampleR
}
val ret = _decodeFrame(mp2, framePtr, pcm, pushL, pushR)
val ret = try {
_decodeFrame(mp2, framePtr, pcm, pushL, pushR)
}
catch (e: Throwable) {
e.printStackTrace()
intArrayOf(0, 0)
}
// dither samples and store them to the given "out" pointer
var outPos = out