audio:short function to enqueue decoded mp2; playmov:no more choppy audio

This commit is contained in:
minjaesong
2023-01-21 19:43:11 +09:00
parent b60b5bada6
commit 99212adea3
7 changed files with 18 additions and 48 deletions

View File

@@ -1,5 +1,6 @@
package net.torvald.tsvm
import net.torvald.UnsafeHelper
import net.torvald.tsvm.peripheral.AudioAdapter
import net.torvald.tsvm.peripheral.MP2Env
@@ -84,6 +85,13 @@ class AudioJSR223Delegate(private val vm: VM) {
fun mp2Init() = getFirstSnd()?.mmio_write(40L, 16)
fun mp2Decode() = getFirstSnd()?.mmio_write(40L, 1)
fun mp2InitThenDecode() = getFirstSnd()?.mmio_write(40L, 17)
fun mp2UploadDecoded(playhead: Int) {
getFirstSnd()?.let { snd ->
val ba = ByteArray(2304)
UnsafeHelper.memcpyRaw(null, snd.mediaDecodedBin.ptr, ba, UnsafeHelper.getArrayOffset(ba), 2304)
snd.playheads[playhead].pcmQueue.addLast(ba)
}
}

View File

@@ -82,7 +82,7 @@ class VMJSR223Delegate(private val vm: VM) {
val from = from.toLong()
val to = to.toLong()
val len = len.toLong()
val fromVector = if (from >= 0) 1 else -1
val toVector = if (to >= 0) 1 else -1
val fromDev = getDev(from, len, false)

View File

@@ -69,7 +69,7 @@ private class WriteQueueingRunnable(val playhead: AudioAdapter.Playhead, val pcm
while (!exit) {
playhead.let {
if (it.pcmQueue.size < it.getPcmQueueCapacity() && it.pcmUpload && it.pcmUploadLength > 0) {
if (/*it.pcmQueue.size < it.getPcmQueueCapacity() &&*/ it.pcmUpload && it.pcmUploadLength > 0) {
printdbg("Downloading samples ${it.pcmUploadLength}")
val samples = ByteArray(it.pcmUploadLength)

View File

@@ -47,6 +47,7 @@ import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.roundToInt
class MP2Env(val vm: VM) {
private var mp2_frame: Long? = null; // ptr