mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-11 21:51:50 +09:00
fix: mp2 player would not play the very first frame
This commit is contained in:
@@ -777,7 +777,7 @@ class AudioJSR223Delegate(private val vm: VM) {
|
||||
};
|
||||
// check for valid header: syncword OK, MPEG-Audio Layer 2
|
||||
if ((syspeek(mp2_frame!!) != 0xFF) || ((syspeek(mp2_frame!! +1) and 0xFE) != 0xFC)){
|
||||
throw Error("Invalid header")
|
||||
throw Error("Invalid header at $mp2_frame: ${syspeek(mp2_frame!!).toString(16)} ${syspeek(mp2_frame!! +1).toString(16)}")
|
||||
};
|
||||
|
||||
// set up the bitstream reader
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package net.torvald.tsvm
|
||||
|
||||
import com.badlogic.gdx.utils.Base64Coder
|
||||
import net.torvald.UnsafeHelper
|
||||
|
||||
object Base64Delegate {
|
||||
class Base64Delegate(val vm: VM) {
|
||||
|
||||
fun atob(inputstr: String): ByteArray {
|
||||
return Base64Coder.decode(inputstr)
|
||||
@@ -18,4 +19,11 @@ object Base64Delegate {
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
fun atoptr(inputstr: String): Int {
|
||||
val b = atob(inputstr)
|
||||
val ptr = vm.malloc(b.size)
|
||||
UnsafeHelper.memcpyRaw(b, UnsafeHelper.getArrayOffset(b), null, vm.usermem.ptr + ptr, b.size.toLong())
|
||||
return ptr
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,7 +72,7 @@ object VMRunnerFactory {
|
||||
bind.putMember("graphics", GraphicsJSR223Delegate(vm))
|
||||
bind.putMember("serial", VMSerialDebugger(vm))
|
||||
bind.putMember("gzip", CompressorDelegate(vm))
|
||||
bind.putMember("base64", Base64Delegate)
|
||||
bind.putMember("base64", Base64Delegate(vm))
|
||||
bind.putMember("com", SerialHelperDelegate(vm))
|
||||
bind.putMember("dma", DMADelegate(vm))
|
||||
bind.putMember("audio", AudioJSR223Delegate(vm))
|
||||
|
||||
Reference in New Issue
Block a user