mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-06 05:28:31 +09:00
audio:short function to enqueue decoded mp2; playmov:no more choppy audio
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user